this is a follow-up question to this post here and to @RobPratt's answer. I have implemented the whole thing, and now it happened that on day 1 the machine did not run and was only used for the first time on day 2, but a shift change was modeled, even though there was actually none. What could be the reason for this and how do I have to adjust the constraints to prevent this from happening? That is the answer:
\begin{align} \rho_{ptm} &\le 1-s_{ptm} &&\text{for all $p,t,m$} \\ \rho_{ptm} &\le d_{ptm} &&\text{for all $p,t,m$} \\ \rho_{ptm} &\ge d_{ptm} - s_{ptm} &&\text{for all $p,t,m$}\\ \sum_m d_{ptm} + x_{pt} &= 1 &&\text{for all $p,t$} \\ s_{p,t+1,m} &= d_{ptm} + y_{ptm} &&\text{for all $p,t\not=T,m$} \\ y_{ptm} &\le s_{ptm} &&\text{for all $p,t,m$} \\ y_{ptm} &\le x_{pt} &&\text{for all $p,t,m$} \\ y_{ptm} &\ge s_{ptm} + x_{pt} - 1 &&\text{for all $p,t,m$} \end{align}
The variables are defined as:
- $d_{ptm}$: Binary variable indicating if product $p$ was serviced by machine $m$ in period $t$
- $\rho_{ptm}$: Binary variable indicating if there was a switch in machines for product $p$ in period $t$ to machine $m$
- $s_{ptm}$: State variable indicating if the last servicing of product $p$ prior to period $t$ was by machine $m$
- $y_{ptm}$: Auxiliary variable to assist in defining constraints related to $s_{ptm}$ and $x_{pt}$
- $x_{pt}$: Binary variable indicating if product $p$ is not being serviced in period $t$
And that is the original question:
I have the following question / concern. I have a modeling problem with the decision variable $d_{ptm}$ which indicates whether product $p$ was serviced by machine $m$ in period $t$. It takes the value 1 if so, and 0 otherwise. A product can be serviced by different machine in different periods. In addition, a product may not be serviced for two days and then again, possibly by a different machine. I now want to introduce a binary variable $\rho$ that indicates such a switch in machines a product was serviced by. It should take the value = 1 if there was a machine switch from the last time a product was serviced till the current period. How can I model this?