Skip to content

Free day after night shift phase

Likelihood of Confusion

Different then the constraint Free days after Night Shift Phase.

According to recommendations for the healthy organization of night and shift work, workers should have at least 24 hours of free time after a night shift. This ensures that workers have sufficient rest after a night shift. Therefore, if an employee works the night shift today and does not work the night shift tomorrow, they must take the day off.

Bug

In the final presentation of our project a bug was found, possibly regarding this implementation. One other constraint could also be the source of this bug. More details can be found in this open issue.

Implemented using Google's OR Tools

src/cp/constraints/free_day_after_night_shift_phase.py
model.add(day_tomorrow_variable == 0).only_enforce_if(
    [night_shift_today_variable, night_shift_tomorrow_variable.Not()]
)

For each non hidden employee and each day we enforce the next day to be free (day_tomorrow_variable == 0) if we got a night shift today, but not tomorrow, meaning the night shift phase ends.