Linearize if else constraint in a MILP

207 Views Asked by At

How can you write the following if/else condition in a linear form?

If S ≥ 3, then X ≤ 1,

else X = 0

with S ∈{0, 1, 2, 3}

X ∈{0, 1}

I've seen some examples where X is forced to a value in the if condition, but I haven't found an example where X may (i.e. ≤) have a value.

1

There are 1 best solutions below

1
On BEST ANSWER

You want to enforce $S \le 2 \implies X = 0$, equivalently, its contrapositive $X = 1 \implies S \ge 3$. The standard big-M formulation is $$3 - S \le M (1 - X).$$ Because $S \ge 0$, you can take $M = 3 - 0 = 3$: $$3 - S \le 3 (1 - X),$$ which simplifies to $3X \le S$, as suggested by @MichalAdamaszek in the comments.