How to ensure that working hours for employee i come right after each other?

41 Views Asked by At

I am very sorry if this question looks confusing. I have tried to solve it but unfortunately I always end up with the same problem.

Introduction to the problem:

I have a binary variable $x_{i,h,l}$ which is 1 if employee $i$ works on hour $h$ (basically I have shifts that have a length of one hour) on day $l$ and 0 otherwise.

I need to write up a linear constraint to ensure that if $x_{i,h,l}=1$ and $x_{i,(h+j),l} = 1$ then j = 1 (here j is integer and is between 1 and h-1).

In words I want to ensure that if employee $i$ works on day $l$ and he works for hour $h$ then if he needs to work for more than 1 hour on day l the hours have to come right after i.e. if $x_{i,h,l}=1$ then $x_{i,h+1,l}=1$ but only if he is needed for more hours.

I initially wrote the constraint as

$$x_{i,h,l} \leq x_{i,h+1,l}$$

but the problem is that by writting it up like this I am stating that if $x_{i,h,l}=1$ then he actually has to work for the rest of the day. This is not what I want.

The employees have to be able to work for example for three hours in the middle of the day.

I am very sorry, it is hard to explain. Pleas ask if anything is unclear.

Best Husky

1

There are 1 best solutions below

0
On

Now, you want to avoid two worked hours with a non-worked hour in between, so for all triples of hours $h<j<k$, we should have $x_{i,h,\ell}-x_{i,j,\ell}+x_{i,k,\ell}\le1$. If any of these quantities equaled $2$, then we'd have working at hour $h$ and hour $k$ but no working at hour $j$ in between.