# How to modify a model to be cyclic?

I have the following question. I have the following physician problem with the indices $$I$$ (doctor), $$T$$ (days) and $$J$$ (shifts). $$x_{itj}$$ is the decision variable, $$d_{tj}$$ is the demand and $$g$$ is a fixed number. The model is as follows. \begin{align} &\min \sum_{i,t,j}^{}x_{i(\mod (t-1,14)+1)j}\cdot c_j\\ &\sum_{i}^{}x_{i(\mod (t-1,14)+1)j}\ge d_{tj} &&\forall t\in T, j\in J\\\ &\sum_{j}^{}x_{i(\mod (t-1,14)+1)j}\le1 &&\forall i\in I, t\in T\\\ &x_{i(\mod (t-1,14)+1)3}+x_{i(\mod (t,14)+1)1}\le 1 &&\forall I \in I, t\in \{1,\ldots,T-1\}\\\ &\sum_{l=t}^{t+g}\sum_{j}^{}x_{i(\mod (l-1,14)+1)j}\le g &&\forall i\in I, j\in J\\ &x_{i(\mod (t-1,14)+1)j}+x_{i(\mod (t,14)+1)j}+s_{i(t+1)}\le 2&& \forall i\in I,k\in K,t\in\{1,\ldots,T-1\}\\ &x_{i(\mod (t-1,14)+1)j}+\sum_{k\neq j}^{}x_{i(\mod (t,14)+1)k}\le1+s_{i(t+1)}&& \forall i\in I,k\in K,t\in\{1,\ldots,T-1\}\ \end{align}

Now to my question. I currently have 28 days as the planning period. However, I would now like to create cyclical plans, so that after 28 days it starts again from the beginning. How do I have to extend/modify my model, especially with regard to linking the days with $$t+1$$ etc.? And how can I introduce a parameter that controls the number of cycles?

EDIT: I updated the model, as suggested by @RobPratt. Now, i have a a 28 planing horizon, with two cycles a 14 days. Whenever i try to solve this model, i only get solutions for 14 days, regarding $$x_{itj}$$. Why is that?

• "And how can I introduce a parameter that controls the number of cycles?" << If it's truly periodic, why does the number of periods matter? Just pretend it's really a circular cycle with no beginning and no end.
– Stef
Commented Jan 9 at 16:12
• The use of $\mod$ means that the $t$ index of $x$ is always in $\{1,\dots,14\}$. To recover the schedule for the second $14$-day cycle, just copy the solution from the first cycle. Also, you still mistakenly have both $\sum_j$ and $j\in J$ in the $\le g$ constraint. Commented Jan 15 at 15:16

If you want to enforce that $$x_{i,t,j}=x_{i,t+28,j}$$, you can explicitly impose that constraint and let the presolver do the substitution.
Or omit the explicit constraints and do the substitution yourself by replacing $$t$$ with $$\mod(t,28)$$ for each $$x_{i,t,j}$$ variable (assuming $$t$$ starts at $$0$$). It looks like your $$t$$ starts at $$1$$, so you can instead replace $$t$$ with $$\mod(t-1,28)+1$$ for each $$x_{i,t,j}$$ variable.
• Thanks. Do you mean instead of writing $x_{it3}+x_{i(t+1)1}\le 1$ with $x_{i(\mod(t-1,28)+1)3}+x_{i(\mod(t-1,28)+2)1}\le1$ f.e? Commented Jan 9 at 18:53
• Almost. The first one is correct. The second one should instead be $x_{i,\mod(t+1-1,28)+1,1}$. Commented Jan 9 at 19:11
• Thanks. And If I apply that logic to all constraints i can model the cyclic behaviour. That would ensure that the third constraint f.e. also must be fullfilled for $t=28$ in cycle 1 and $t=1$ in cycle 2, correct? Commented Jan 9 at 19:30