I'm trying to add the constraint that the nurse will work at least two days in a row. Code: https://developers.google.com/optimization/scheduling/employee_scheduling#program2
My idea is: "If there is working shift and before was not then add working shift next day"
for n in all_nurses:
for d in range(1,6): #Because use d-1 and d+1
for s in all_shifts:
#1-st try model.AddImplication(shifts[(n, d-1, s)]==0 and shifts[(n, d, s)]==1, shifts[(n, d+1, s)]==1)
#2-nd try: model.Add(shifts[(n, d+1, s)]==1).OnlyEnforceIf(shifts[(n, d-1, s)]==0 and shifts[(n, d, s)]==1)
1-st: throw TypeError: NotSupported: model.GetOrMakeBooleanIndex(shift_n0d2s0 == 1)
2-nd: throw: AttributeError: 'BoundedLinearExpression' object has no attribute 'Index'