Converting if else constraints into linear ones

1.3k Views Asked by At

I have the following two constraints:

$$ x_1 \leq x_2 \leq x_3 \qquad \mbox{if } x_1 \leq x_3 \\ x_1 > x_2 > x_3 \qquad \mbox{otherwise} $$

Is there a way to get rid of the two conditions and end up with linear constraint(s) only?

1

There are 1 best solutions below

0
On

One solution, perhaps not the most efficient, can be as follows: your constraint can be rewritten as:

$$ \min(x_1, x_3) \leq x_2 \leq \max(x_1,x_3) $$

therefore, you can introduce two positive variables $t$ and $k$ such that:

$$ t \leq x_1 \\ t \leq x_3 \\ k \geq x_1\\ k \geq x_3 $$

Putting $t$ and $k$ in the objective function with suitable coefficients, you can end up with $t = \min(x_1,x_3)$ and $k = \max(x_1,x_3)$. So, your constraint becomes: $$ t \leq x_2 \leq k$$