I've asked this question also on Math Stack Exchange.
It's a custom nurse rostering problem:
- $N$ is a set of nurses;
- $S$ is the set of shift-type (morning, afternoon, night, rest)
- $n_\mathrm{Morning}$ is the number of nurses required every day to cover a morning;
- $n_\mathrm{Afternoon}$ is the number of nurses required every day to cover an afternoon;
- $n_\mathrm{Night}$ is the number of nurses required every day to cover a night;
- Every shift lasts $8$ hours;
- Every nurse can work only for one shift in a day;
- After every night a nurse must have a rest day;
- Rest at the weekend and on holiday have to be balanced between all nurses;
- I would like that after every morning there will be an afternoon, after an afternoon a night and after a night a rest day.
- I would like to plan shifts with a month frequency.
What are the decision variables and the objective function that I have to use? Can anyone help me to write it?
I can define the quantity $x_{ijk}=1$, if nurse $i$ works on shift $j$ on day $k$, and $0$ elsewhere. But how can I balance holiday and rest days between other nurses?
UPDATE (16/01/2020)
This is the actual model that I have formulated, is this right for covering constraints $3$ to $5$?
- $j$ is an element of $S$, coded as: $0=\rm Morning$, $1=\rm Afternoon$ and $2=\rm Night$;
- $k$ is an element of the set of days of January.
\begin{alignat}2\min&\quad\sum_{i=0}^n\sum_{j=0}^2\sum_{k=1}^{31}x_{ijk}\\\text{s.t.}&\quad\sum_{i=0}^nx_{i0k}=n_{\rm Morning}&\quad\forall k\\&\quad\sum_{i=0}^nx_{i1k}=n_{\rm Afternoon}&\quad\forall k\\&\quad\sum_{i=0}^nx_{i2k}=n_{\rm Night}&\quad\forall k\end{alignat}
UPDATE (17/01/2020) - Thanks to @lonzaleggiera on Math Stack Exchange.
Let $W$ be a set of weekend days and $H$ be a set of holidays. The actual model is given by \begin{alignat}2\min&\quad\sum_{j=0}^1\sum_{i=0}^n\sum_{k=1}^{30}x_{ijk}\left(1-x_{i(j+1)(k+1)}\right)\\\text{s.t.}&\quad\sum_{i=0}^nx_{i0k}=n_\text{Morning}&\forall k\\&\quad\sum_{i=0}^nx_{i1k}=n_\text{Afternoon}&\forall k\\&\quad\sum_{i=0}^nx_{i2k}=n_\text{Night}&\forall k\\&\quad\sum_{j=0}^2x_{ijk}\leq1&\forall i,k\\&\quad x_{i2k}+\sum_{j=0}^2x_{ij(k+1)}\leq1&\forall i,k\\&\quad\sum_{k\in W}\left(1-\sum_{j=0}^2x_{i_1jk}\right)=\sum_{k\in W}\left(1-\sum_{j=0}^2x_{i_2jk}\right)&\forall i_1,i_2\\&\quad\sum_{k\in H}\left(1-\sum_{j=0}^2x_{i_1jk}\right)=\sum_{k\in H}\left(1-\sum_{j=0}^2x_{i_2jk}\right)&\forall i_1,i_2.\end{alignat}
These are my current doubts:
- For the last two hard constraints to balance weekend and holidays, the problem will probably become infeasible. To integrate them in the current objective function, do I have to multiply the current objective function with the maximum difference between the two sides?
- If I find an empty polyhedron replacing the two hard constraints can I replace $=$ (points $3$, $4$ and $5$) with $>$?
- If I solve this model every month, how can I remember the past decisions to have continuous balancing?