Rotate shifts forwards
The forward shift rotation constraint requires employees to transition from earlier shifts to later shifts, promoting better health and reducing fatigue. An employee's weekly schedule should progress from early shifts to late shifts and then to night shifts, not the other way around.
Implemented using Google's OR Tools¶
src/cp/objectives/rotate_shifts_forward.py
model.add_bool_and(
[current_shift_variable, next_desired_shift_variable]
).only_enforce_if(rotation_variable)
model.add_bool_or(
[
current_shift_variable.Not(),
next_desired_shift_variable.Not(),
]
).only_enforce_if(rotation_variable.Not())
...
return sum(possible_rotation_variables) * -1 * self.weight
Rotating the shifts forward is rewarded with a positive score in the objective function.