Skip to content

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
# rotation_var is True when employee works from_shift on day1
    model.add_bool_and([from_shift_var, to_shift_var]).only_enforce_if(rotation_var)
    model.add_bool_or([from_shift_var.Not(), to_shift_var.Not()]).only_enforce_if(
        rotation_var.Not()
    )

return sum(possible_rotation_variables) * -1 * self.weight

Rotating the shifts forward is rewarded in the objective function.