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? The constraints should not only create a lower bound, but also an upper bound. It should not be compared to the previous period, but to the time $t$ when the last time a product was serviced by a machine. In another thread I already found the solution for a switch compared to previous day, but I would like to have it compared to the last day with a machining. My idea would be to somehow remember the status, but I have no idea how to do it.
My constraints so far (adopted from post mentioned above): $$d_{ptm}-d_{p(t+1)m}\le\rho_{p(t+1)} \\ d_{ptm}+d_{p(t+1)m}+\rho_{p(t+1)}\le 2$$
EDIT: Model shift change using $w_{ptm}$: \begin{align} &d_{ptm}+\sum_{j \neq m} w_{ptj}\le \rho_{pt}+1~&\forall p \in P, m\in M, t\in\{2,\ldots,T\}\\ &w_{ptm}+d_{ptm}+\rho_{pt}\le 2~&\forall p \in P, m\in M, t\in\{2,\ldots,T\} \end{align} Definition of $w_{ptm}$: \begin{align} &w_{ptm}\ge d_{p(t-1)m}~&\forall p\in P, m\in M, t\in\{2,\ldots,T\} \\ &w_{ptm}\ge w_{p(t-1)m}-\sum_{j \in M\setminus\left\{ m \right\}} d_{p(t-1)j} ~&\forall p\in P,m\in M, t\in\{2,\ldots,T\}\\ &\sum_m w_{ptm} = 1 ~&\forall p\in P, t\in \{2,\ldots,T\} \end{align}