Linearize a variable in a range
Occasionally, I encountered a linearization problem where a variable takes one value in a certain region and another value elsewhere, i.e.,
- If $ m_1 \leq x \leq m_2 $, then $ y = x $; otherwise, $ y = 0 $.
The linearization of this problem is as follows:
- Introduce a binary variable ( z ) and a sufficiently large constant ( M ).
[ \begin{aligned} x&\geq m_1-zM
x&\leq m_2+zM
y-x&\geq -zM
y-x&\leq zM
y&\leq (1-z)M
y&\geq -(1-z)M \end{aligned} ]
Enjoy Reading This Article?
Here are some more articles you might like to read next: