In my Linear Program, I'm trying to express that a decision variable $x \in R$ can only lie in certain intervals, e.g. $x \in [0,2] \cup [5,8] \cup [9,15]$.
I'm aware of that you can model either constraint 1 OR constraint 2 with a Big M trick (e.g. explained here in section 7.3 and asked here, but do not see directly how this could solve my question. Any ideas?
Asked
Active
Viewed 389 times
2
Ottavio
- 2,367
2 Answers
3
With the same binary variables $z_i$ as in @MichalAdamaszek's answer, a tighter formulation is \begin{align} \sum_i a_i z_i \le x &\le \sum_i b_i z_i \\ \sum_i z_i &= 1 \end{align}
RobPratt
- 50,938
-
1Nice answer. Used it at http://ask.cvxr.com/t/multi-bound-variable/9837/3 – Mark L. Stone Mar 20 '22 at 23:45
1
If $[a_i,b_i]$ is the $i$-th interval then for a binary variable $z_i$ the inequality
$$a_iz_i-(1-z_i)M\leq x\leq b_iz_i+(1-z_i)M$$
gives $x\in[a_i,b_i]$ when $z_i=1$ and is "free" ($x\in [-M,M]$) when $z_i=0$. So a family of such constraints together with
$$\sum z_i= 1$$
models the membership in a union of intervals $x\in\bigcup_i[a_i,b_i]$.
Michal Adamaszek
- 4,147