Dynamic “work stretch” period for shift start time difference rules (reset on days off)
R
Roni
Problem
The shift start time difference rule (shiftStartTimeDifferenceInMinutesMax) only works over fixed periods (WEEK, MONTH, SCHEDULE, or custom named periods). For transit operators, start times only need to stay consistent within a run of consecutive working days. After a day off, the driver can switch to a different start time with no ill effect. A fixed period like WEEK doesn’t match this:
It applies the limit across a day off, where it isn’t needed, which over-constrains the solver.
It resets in the middle of a work stretch, where the limit is needed, which under-constrains it.
This problem describe the issue for start time rule - but it can be any type of rule
Example
An employee is off on Tuesday this week and Wednesday next week. The desired behaviour is:
Start times stay within X minutes of each other up to this Tuesday.
Start times stay within X minutes of each other from this Wednesday to next Tuesday.
Start times stay within X minutes of each other from next Wednesday on.
Our current contract, for reference:
{
"id": "startTimeHomogeneityContract",
"periodRules": [
{ "id": "startTime_WEEK_0.5", "period": "WEEK", "excludeShiftTags": ["SPARE"], "shiftStartTimeDifferenceInMinutesMax": 30 },
{ "id": "startTime_SCHEDULE_1", "period": "SCHEDULE", "excludeShiftTags": ["SPARE"], "shiftStartTimeDifferenceInMinutesMax": 60 }
]
}
Requested capability
A new dynamic period type, for example period: "CONSECUTIVE_WORKING_DAYS". Its bounds would be calculated from the gaps between assigned shifts, not from calendar boundaries. The rule would reset whenever an employee has a day with no assigned shift. It should support:
Static days off: days off provided in the input, such as unavailability or fixed weekly days off.
Dynamic days off: days off that come from the solver’s own shift assignments while it respects the other rules.
Optionally, a configurable minimum gap length, such as one day or more than 24 hours, to decide what counts as a break.
Current workaround and why it falls short
We can build named custom periods per employee around known days off. That only works for static days off. It also pushes period-building logic onto our side and makes the input larger and more fragile. It can’t work when the solver decides the days off.
Impact
Start-time consistency matters for driver wellbeing and is required for duty and roster quality. A work-stretch-based rule would remove the need for custom-period generation and allow more flexible rosters to be optimised in one pass.
Log In