I am trying to formulate indicator-type of constraints. $y$ is binary $0$ or $1$ and $x$ is a continuous variable. $$ y = \begin{cases} 1, & \text{ if } a \leq x \leq b \\ 0, & \text{ Otherwise } \end{cases} $$
The question is how to model this using linear constraints? I have researched and done my homework below with thoughts:
- Define binary $$ y_1 = \begin{cases} 1, & \text{ if } a \leq x \\ 0, & \text{ Otherwise } \end{cases} $$
Define binary $$ y_2 = \begin{cases} 1, & \text{ if } x \leq b \\ 0, & \text{ Otherwise } \end{cases} $$
Big-M methods can be used to define linear constraints for $ x, y_1 $ and $ y_2.$
- Enforce $ y=1 $ if both $ y_1=1 $ and $ y_2=1 $; $ y=0 $ otherwise, as follows: $$ y \leq y_1, y \leq y_2, y \geq y_1+y_2-1 $$
However I ended up with two many ( 4 with Big-M methods and 3 above) constraints. I was wondering if anyone has other more efficient or better approaches?