Write IF THEN constraint in Linear Programming for Non Binary Decision Variable

242 Views Asked by At

$ x_{t} $ is a decision variable bounded by some constraints and $t=1,2,3..24$

If at some point in t, the value of $x_{t}$ changes then the value must not change for ATLEAST the next 3 hours. After that it can be the same or change but if the value changes again then it must not change again for the next 3 hours and the process must continue from time = 1 to 24 to create an optimal solution.

How can we write this constraint in linear programming / MILP

My Current Understanding:

$ \text{IF} ~~ x_{t}\neq x_{t-1} $

$ \text{THEN} ~~ x_{t} = x_{t+1} = x_{t+2}=x_{t+3} $

But i am not sure how to express this in LP

1

There are 1 best solutions below

0
On BEST ANSWER

Introduce a binary variable $y_t$ that is 1 if $x_t \not= x_{t-1}$. Then $$\sum_{s=t}^{t+2} y_s \le 1$$ prevents changing more than once in the three-hour period that starts at time $t$. Now the following "big-M" constraint enforces $y_t=0 \implies x_t = x_{t-1}$: $$-M\ y_t\le x_t - x_{t-1}\le M\ y_t$$