How to model 24 hours demand into a daily shift schedule?

I am working on a weekly staff scheduling optimization problem with 24/7 demand.

The binary decision variable is: $$X_{\text{staff},\,\text{day},\,\text{shift}}$$ whether to assign the staff $$s$$ to day $$d$$ shift $$\text{sh}$$.

There are several shift sets for everyday like 8-17 for full time. 14-19 for part time, and 20-6 for night shift.

The 0-1 shift/hour matrix is: $$\text{ShiftHourMap}_{\text{shift},\,\text{hour}}$$ which has 24 hours as columns, shifts as rows.

The demand is formulated as: $$\text{Demand}_{\text{day},\,\text{hour}}$$.

The current constraints are:

1. weekly upper/lower limit of total hours for every staff.

2. The demand coverage constraint is : $$\sum_{\text{staff}}X_{\text{staff},\,\text{day},\,\text{shift}}\cdot \text{ShiftHourMap}_{\text{shift},\,\text{hour}}\ge\text{Demand}_{\text{day},\,\text{hour}}\,\forall{\text{day},\,\text{hour},\,\text{shift}}$$

The constraint like no assignment of daily shift after a night shift is not necessary, because the night shift is basically sleeping on site and staff sometimes is willing to pick a morning shift right after the overnight shift.

This would be fine if there's no overnight shift. How do I model the constraint to consider the overnight shift? And also, how to model the next Monday's early morning demand (last shift of Sunday)?

Do I model as 24 * 7 hours and use the hour as index?

I can use MiniZinc or Pyomo.

• Would you see this or this. They may not be exactly as you want, but they may be useful. Sep 4 '19 at 4:24

I'm not sure I understand what the questions are. In your demand constraint, you should also include a term for $$X_{\text{staff},\,\text{day} - 1, \,\text{overnight}}$$ on every day other than day 1. On day 1, the equivalent tweak is to adjust the demand by the staff level of the overnight shift from the last day of the previous week (which you presumably know).