I am fairly new to linear programming since I came across this topic at university this semester. We mainly focus on nurse rostering. In the lecture, we created a very basic rostering model with an objective function and two constraints. Nr. 1 is the demand constraint and nr.2 is the individual working constraint. I now want to build upon this model and add a few constraints.

In our model, we have two binary variables: $a_{its}$ indicates if nurse $i$ works the shift $s$ on day $t$. $b_{it}$ indicates if nurse $i$ works on day $t$. The index goes from $i;t;s \in \{1,\dots,I;T;S\}$. I now want to model the following:

  1. A nurse must work at least $E_\min$ days at a stretch. To avoid off-on-off patterns so to speak.
  2. A nurse may work a maximum of $E_\max$ days at a stretch. My suggestion would be: $\sum_{j=t}^{j+E_\max}b_{ij}\le E_\max~\forall i\in I, t\in \{1,\dots,|T| -E_\max\}$
  3. A break between work sequences must always be exactly 2 days.

How do I model those linear constraints?

  • 1
    $\begingroup$ For the first and second, it seems you would need to limit the LB and UB of the constraints with your predefined parameters. E.g. $\{\sum_{s,t} x_{i,s,t} = u_{i}, \quad \forall i \}$, $ \{E_{min} \leq u_{i} \leq E_{max}, \quad \forall i \}$. And for the third the conditional expression $\{(y_{i,t} \land y_{i,t+1}) \implies (\lnot y_{i,t+2}), \quad \forall i,t \}$. I hope it helps. $\endgroup$
    – A.Omidi
    Commented May 31, 2023 at 13:06
  • $\begingroup$ or.stackexchange.com/questions/9819/… $\endgroup$
    – RobPratt
    Commented May 31, 2023 at 13:24

1 Answer 1


$ E_{min}b_{i,t-1} - \sum_{k=1}^{t-1}b_{i,k} \le E_{max}b_{i,t}$

$ \sum_t b_{i,t} \le E_{max}b_{i,t-1} - \sum_{k=1}^{t-1}b_{i,k}$

$ b_{i,t} \le 1 + b_{i,t-1} - b_{i,t-2}$

and ofcourse
$ b_{i,t} \le \sum_s a_{i,s,t} \le Tb_{i,t}$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.