0
votes

I am making a scheduling program using Google OR-tools. In this the workers have a minimum shift length (lets say here its 2), any shift length less than this is not allowed (similarly to or-tools provided examples). So, for example:

working - working - working - not working, is allowed but:

not working - working - not working, is not allowed

This is behaviour I want. However, I have implemented multiple roles into my model and, if necessary, would like my employees to be able to switch between them. The issue for the is that if I have 2 roles (R1 and R2) I would like to be able to allow a situation like this:

R1: working - not working - not working

R2: not working - working - working

Here, between the 2 roles the employee has worked more than the minimum. It seems though that this is not an allowed sequence, since during the time working role 1 the employee is working less than the minimum shift length.

I cannot think of a way to constrain the shifts if your are only working one role, but allow that constraint to be relaxed if you are to work 2. You could have it always as a soft constraint, but if you are only working 1 role in a day you really have to obey the min shift length rule. Is there a way to "contradict" one specific hard constraint? Ie, a way for me to construct sequences off all the possible role switches and allow them to be included in the optimisers search?

1
In the shift_scheduliing_sat example, it only constrain sequence with at least one worked shift. So R1 should be allowed. - Laurent Perron

1 Answers

0
votes

For each employee, create a BoolVar that is true if he only works as 1 role, then add OnlyEnforceIf to your contraint with the created BoolVar