How to manage Consecutive shifts constrains?

31 views Asked by At

I'm trying to build an optimization scheduling program but I'm having troubles defining constrains for consecutive lunch time. It is easy to define a constrain setting that in a day of 8 hours, every worker must have at least 3 hours for lunch. With hrs being the model binary options for each hour, it would be something like Sum(hrs) >= 3

But for defining that those 3 hours must be consecutive I cant think of a way to set the constrain. I am starting to use disjuncts and so, but I dont know if it is the best way. Right now I am trying all of this with pyomo.

1

There are 1 answers

0
Erwin Kalvelagen On
 startlunch[t] >= lunch[t]-lunch[t-1]
 sum(startlunch) <= 1
 sum(lunch) >= 3
 lunch, startlunch: binary variables

Intuition: startlunch[t]=1 is when we start lunch. We go from lunch[t-1]=0 to lunch[t]=1.

  1. You probably can assume lunch[-1]=0.
  2. You can add a worker index to the variables.