Skip to content

Vacation days and free shifts

Vacation days must remain free, and the day before a vacation day no night shift is allowed. This vacation days are automatically read from the database / TimeOffice.

Implemented using Google's OR Tools

This might be one of the easiest constraints. If an employee is unavailable for a day or shift, the corresponding variables EmployeeDayVariable or EmployeeDayShiftVariable is set to 0 (not assigned).

src/cp/constraints/vacation_days_and_shifts.py
if employee.unavailable(day):
    day_variable = variables[EmployeeDayVariable.get_key(employee, day)]
    model.add(day_variable == 0)
src/cp/constraints/vacation_days_and_shifts.py
for shift in self._shifts:
    if employee.unavailable(day, shift):
        shift_variable = variables[
            EmployeeDayShiftVariable.get_key(employee, day, shift)
        ]
        model.add(shift_variable == 0)