There are 9 persons. On every weekend two of them has to be on-call. I want to create on-call calendar so that
- every person will have at least two free weekends after an on-call weekend
- on-call pairs will always change
Possible pairs are (persons are 1...9), total 36 different pairs: 12 13 14 15 16 17 18 19 23 24 25 26 27 28 29 34 35 36 37 38 39 45 46 47 48 49 56 57 58 59 67 68 69 78 79 89
How can i solve this with Excel solver, or GLPK?
Again, it is in my opinion impossible to do this as an LP. However we can try a MIP formulation.
Let's use the following notation:
The obvious constraints on $y$ are:
$$\begin{align} &\sum_{(i,j) \in P} y_{i,j,t} = 1 & \forall t \>\>& \text{(one pair per weekend)} \\ &\sum_t y_{i,j,t} \le 1 & \forall (i,j) \in P \>\> & \text{(no repeats of pairs)}\end{align}$$
The constraint on $x$ is that we need $x_{i,t}=1 \implies x_{i,t+1}=x_{i,t+2}=0 $ . This we can formulate surprisingly simple as: $$ x_{i,t}+x_{i,t+1}+x_{i,t+2} \le 1 \>\> \forall i,t $$ (The equivalence of these two requires a bit of thought).
Finally we need to connect $x$ and $y$. This is done by $y_{i,j,t}=x_{i,t} \cdot x_{j,t}$. This binary multiplication can be linearized as:
$$\begin{align} & y_{i,j,t} \le x_{i,t} & \forall (i,j) \in P, \forall t\\ & y_{i,j,t} \le x_{j,t} & \forall (i,j) \in P, \forall t\\ & y_{i,j,t} \ge x_{i,t}+x_{j,t}-1 & \forall (i,j) \in P, \forall t \end{align}$$
There is no objective. This MIP model can be solved with any MIP solver (although Excel solver has size limits that are probably too small for this problem). As there is no objective the solver will stop at the first integer feasible point. A constraint programming (CP) solver would make the model simpler to express.