-1

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

Jayyu
  • 133

1 Answers1

0

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.

RobPratt
  • 50,938
  • That works! Thanks a lot! – Jayyu Dec 28 '20 at 14:57
  • Glad to help. Please mark my answer as accepted. – RobPratt Dec 28 '20 at 15:00
  • I would like to know more about the procedure for linearizing such logical constraints. Could you elaborate on how you did that or recommend some references? I think showing the way will be even more helpful. Thanks! – Jayyu Dec 28 '20 at 15:34
  • I added more detail to the answer. You can learn more by reading posts from https://or.stackexchange.com/questions/tagged/linearization. – RobPratt Dec 28 '20 at 16:14