I've asked this question also on Operations Research 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}^n x_{i0k} = n{\rm Morning}&\quad\forall k\\&\quad\sum_{i=0}^n x_{i1k} = n{\rm Afternoon}&\quad\forall k\\&\quad\sum_{i=0}^n x_{i2k} = n{\rm Night}&\quad\forall k\end{alignat}
UPDATE (17/01/2020) thanks to @lonza leggiera
Let $\ W\ $ a set of weekend days and $\ H\ $ a set of holidays. Actual model: $$ \text{mimimize } \sum_{j=0}^1\sum_{i=0}^n \sum_{k=1}^{30} x_{ijk}\left(1-x_{i(j+1)(k+1)}\right)\ $$
$$ \sum_{i=0}^{n} x_{i0k}=nMorning \forall k $$
$$ \sum_{i=0}^{n} x_{i1k}=nAfternoon \forall k $$
$$ \sum_{i=0}^{n} x_{i2k}=nNight \forall k $$
$$ \sum_{j=0}^{2} x_{ijk}<=1 \forall i,k $$
$$ x_{i2k} + \sum_{j=0}^{2} x_{ij(k+1)}<=1 \forall i,k $$
$$ \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)\ \ \text{ for all }\ i_1,i_2\\ \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)\ \ \text{ for all }\ i_1,i_2\ . $$
You've correctly formulated the constraints corresponding to dot points $3$ to $5$ in your description of the problem. However: