Assume I'm starting with the nurse scheduling problem.
To make sure I get a result I've gutted all the constraints except "Each shift is assigned to exactly one nurse in the schedule period", and I've also commented out all optimizations.
I simply want to add one constraint such that the 4 nurses have days off:
nurse_days_off = [
[0,2], [1], [1,2], []
]
I've tried playing with AddForbiddenAssignments but it takes tuples and I wasn't able to figure out or find any examples or detailed descriptions of content of tuples and what that would look like in this case.
I also can make a binary mask (0,1 list, like here) but haven't been able to figure out how to apply. I don't see an AddBoolNand or AddMask to filter out the potential solutions in shift[n,d,s)].
Apologies if this is a stupid question, but I'm brand new to constraints programming and didn't find a lot of relevant code examples after a lot of searching around.
TIA
I figured it out, with help from the example: Assignment with Teams of Workers.
forbidden_nurse_days_off = []
for n in all_nurses:
for d in all_days:
for s in all_shifts:
if d in nurse_days_off[n]:
forbidden_nurse_days_off.append(shifts[(n,d,s)])
model.Add(sum(forbidden_nurse_days_off) == 0)