For each nurse the number of working weed-ends must be less than or equal to the maximum. How do I model this? I need more general and smarter way

The methods described in Total working week-end do not allow individual staff requirements to be set in the GUI. This chapter describes how to set them using the method of writing the values in the staff property sheet.

A week-end is considered “working” if at least one of the two days (Sat and Sun) is busy for the nurse. We can not synthesize the “working” in GUI, so we use Python.
Then we count and constrain the “working” as follows. See Python Constraint Programming Manual .

import sc3

def weekend_working(person,day):#If he works Sat or Sun, return True
    vsat=sc3.GetShiftVar(person,day,'Y') | sc3.GetShiftVar(person,day,'Annual Leave')
    vsun=sc3.GetShiftVar(person,day+1,'Y') | sc3.GetShiftVar(person,day+1,'Annual Leave')
    v=~vsat | ~vsun
    return v
def weekend_workings(person):
    vlist=[]
    for day in Sat:
        if day<StartDate:
            continue
        vlist.append(weekend_working(person,day))
    #print(person,vlist)
    return vlist#return boolean list of workings on Sat/Sun this month

for person in Max_Total_WeekEnds_Workings:
    print(person)
    v=Max_Total_WeekEnds_Workings[person]
    sc3.AddSoft(sc3.SeqError(0,v,v,weekend_workings(person)),"Working_Weekend "+staffdef[person],4)

We define the maximum total weekends workings as follows.



Do trial and error for changing the values of the table above.



Load the Project File

File → Open Project File from GitHub