Hierarchy of intermediate shifts
Intermediate shifts are assigned once the minimum staffing requirement is met and sufficient personnel resources are available. The assignment of these shifts follows a specific pattern: we prioritize one shift per day for each weekday, followed by weekend shifts. After that, we aim to assign two shifts on weekdays, and then again on weekends.
In cases where two or more intermediate shifts are scheduled in a single day, the station management will convert them into early and late shifts, as these options tend to be more popular among staff. However, it’s important to note that this conversion process is currently manual and not automated by our application.
Implemented using Google's OR Tools¶
src/cp/constraints/hierarchy_of_intermediate_shifts.py
# Guarantee that shifts on weekdays and weekends are assigned evenly
model.add(max_weekday - min_weekday <= 1)
model.add(max_weekend - min_weekend <= 1)
# Enforce the hierarchy: min(weekdays) <= max(weekends) + 1
model.add(max_weekday <= min_weekend + 1)
model.add(min_weekday >= max_weekend)