Skip to content

Minimum rest time

According to Occupational Health and Safety Law (Arbeitsschutzgesetz) the minimum rest time for normal employees need to be at least 11 hours. In hospitals there can be exception to this rule. We did not implement a solution that can vary the minimum rest time, but we just do not allow an early shift following a late shift, because then the rest time would only be 9 hours.

Implemented using Google's OR Tools

src/cp/constraints/min_rest_time.py
late_today = variables[
    EmployeeDayShiftVariable.get_key(
        employee, day, self._shifts[Shift.LATE]
    )
]
not_early_tomorrow = variables[
    EmployeeDayShiftVariable.get_key(
        employee, day + timedelta(1), self._shifts[Shift.EARLY]
    )
].Not()
model.add_implication(late_today, not_early_tomorrow)

If late_today is true, then also not_early_tomorrow needs to be true.