2

I've been studying the OR-Tools Employee Scheduling example and would like to change it so that the model would allow employees to be assigned to multiple shifts per day and at the same time give preference to solutions where an employee is assigned consecutive shifts within the span of a given day. Allowing multiple shifts seems straightforward, but how can I define an objective function that would prefer consecutive shifts? I don't want consecutiveness to be a hard constraint for the solution.

marko
  • 622
  • 1
  • 6
  • 16
  • The shift scheduling sat example is designed for daily shifts. Not consecutive hours in the same day. – Laurent Perron Feb 19 '22 at 15:11
  • @LaurentPerron The example model seems to assume that "each day is divided into three 8-hour shifts" and "every day, each shift is assigned to a single nurse, and no nurse works more than one shift". AFAIK it looks relatively easy to relax the latter two constraints and also to add multiple shifts for a particular day, and so IMO the sample could be adapted to multiple, consecutive shifts per day. Do you see some specific issues in adapting the example to this model? – marko Feb 19 '22 at 16:47
  • @LaurentPerron More generally, would you have any hints or pointers more on what would be the best approach to model this type of scenario? – marko Feb 19 '22 at 16:59

1 Answers1

1

First, ignore the nurse rostering example, look at the shift_scheduling_sat.py example.

You can try having more types of shifts.

If you really want flexible shifts, define a maximum number of continuous shifts, each with start and end.

Order them: start1 <= end1 < start2 <= end2 ....

Force each empty shifts to be midnight -> midnight. Then start from there. But I would recommend more sets of fixed shifts.

Laurent Perron
  • 8,594
  • 1
  • 8
  • 22