Skip to content

Max one shift per day

Each employee is permitted to work only one shift per day. It is important to note that a night shift counts as part of the day on which it begins.

Implemented using Google's OR Tools

src/cp/constraints/max_one_shift_per_day.py
for employee in self._employees:
    if employee.hidden:
        continue

    for day in self._days:
        model.add_at_most_one(
            variables[EmployeeDayShiftVariable.get_key(employee, day, shift)]
            for shift in self._shifts
        )

For each non hidden employee, for each day, allow at most one of the shift variables.