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 = employee_works_on_day_variables[employee][day]
model.add(day_variable == 0)
src/cp/constraints/vacation_days_and_shifts.py
if employee.unavailable(day, shift):
shift_variable = shift_assignment_variables[employee][day][shift]
model.add(shift_variable == 0)