I would like to linearize a conditional constraint as follow:
0 <= x1 <= 1.
If 0 <= x1 < 1, then x2 = 1, else x2 = 0.
I find it very difficult because it is not a typical If...then constraint. Any suggestions or answers are greatly appreciated. Thanks!
JZ
Let $\epsilon>0$ be a small constant. You can linearize the relationship as follows: $$1-x_2 \le x_1 \le 1-\epsilon x_2$$
Just check the two cases for $x_2 \in\{0,1\}$.
More generally, if you want to enforce $x_1 \in [a,b] \cup [c,d]$, you can use $$a x_2 + c (1-x_2) \le x_1 \le b x_2 + d (1-x_2).$$ Your problem corresponds to $(a,b,c,d)=(0,1-\epsilon,1,1)$.
Even more generally, see Decision variable must lie in union of multiple disjoint intervals.