I have a conceptual question about this scheduling example:
https://github.com/google/or-tools/blob/master/examples/python/shift_scheduling_sat.py
It models the domain problem as a 3-dimensional tensor [employee, shift, day] of boolean flags, indicating assignment of a particular employee to particular shift on a particular day.
Little information is conveyed about shifts themselves (other than whether it's a day off, morning, afternoon or night shift).
It then uses add_soft_sequence_constraint
along with negated_bounded_span
to, for example, limit the number of consecutive days off to a maximum of 1 or 2.
For my problem, I have variable shift lengths which are not predefined -- a key part of the solution is how long each shift is. The general idea is that there are variable coverage requirements throughout the day, e.g. from 8am to 10am only 1 employee is needed, from 10am to 4pm 2 employees are needed and from 4pm to 8pm 1 employee is needed. There is also a list of employees and their requirements: what's their minimum and maximum number of working hours per day, minimum and maximum shift duration they can be assigned to, the maximum number of shifts a day they can be assigned to, minimum time between shifts etc. Shifts for different employees can overlap fully or partially.
I can model this in an analogous fashion similar to above example, where I increase the size of the shift dimension by splitting each day into 24 time windows, each 1 hour long. Employees are assigned to these fixed time windows. A shift is a contiguous sequence of variables assigned to True. To make the shifts adhere to some common sense (e.g. not have somebody come in in the morning for 1h and then for another 1h before midnight), I can use similar approach as in the above example where I require a certain minimum and maximum shift duration (number of consecutive time windows assigned to an employee).
This works but feels force fit into this is-this-employee-assigned-to-this-shift boolean tensor model.
My question is -- is there more natural way to model the constraints using integers, intervals, or some other thing, e.g. modeling as a list of shifts per day, where a "shift" is start and end time and an employee assigned?