Mixed Integer Linear Programming Conditional Constraints

I have a set of variables: $x_1,x_2,x_3,x_4$

$x_1$ is a binary integer variable while the rest are real numbers all between $0$ and $1$.

I want a constraint such that:

if $x_2+x_3+x_4>0$ then $x_1=1$,

and

if $x_2+x_3+x_4=0$ then $x_1=0$.

This looks like a fixed cost problem, and it is easy to model if you have an objective function such as $$Min \quad x_1$$ If so, all you have to do is add the following constraint: $$x_2+x_3+x_4\le x_1 \\ x_1 \in \{0,1\}$$

Indeed, if $x_2+x_3+x_4>0$, then necessarily you will have $x_1=1$. Otherwise, the objective function will "pull down" $x_1$ to $0$.

• What about my answer? Also, what's up with the last line? I think your constraint applies only to the first statement ($x_2+x_3+x_4 > 0 \to x_1=1$)? – BCLC May 11 '16 at 17:45

Here is my suggestion: $$0.001 x_1 \le x_2+x_3+x_4 \le 3x_1$$ This will work because:

• if $x_1=0$ then $0\le x_2+x_3+x_4 \le 0$, so $x_2+x_3+x_4 = 0$
• if $x_1=1$ then $0.001 \le x_2+x_3+x_4 \le 3$, and thus $x_2+x_3+x_4 > 0$

You may need to split the sandwich equation into two inequalities to make it acceptable as input for your LP solver.

• What about my answer? Also, your answer seems to exclude certain possibilities like $x_2 = x_3 = x_4 = 0.0000000001$? – BCLC May 11 '16 at 17:48
• which part is wrong? – BCLC May 12 '16 at 13:45
• you've gotta be kidding me. Contrapositive? I triple checked – BCLC May 12 '16 at 15:00
• why did you delete your comments? – BCLC May 18 '16 at 20:04

You can think about it logically:

If $x_2 + x_3 + x_4 > 0$, then $x_1 = 1$

$\iff$

$x_2 + x_3 + x_4 = 0$ if $x_1 = 0$

$\iff$

$x_2 + x_3 + x_4 = 0$ or $x_1 = 1$

$\iff$

$x_2 = x_3 = x_4 = 0$ or $x_1 = 1$

$\iff$

$x_2 = x_3 = x_4 = 0$ or $x_1 = 1$

$\iff$

$[x_2 = 0 \ and \ x_3 = 0 \ and \ x_4 = 0]$ or $x_1 = 1$

$\iff$

$x_2 = 0 \ or \ x_1 = 1$

and

$x_3 = 0 \ or \ x_1 = 1$

and

$x_4 = 0 \ or \ x_1 = 1$

$\iff$

$1-x_2 = 1 \ or \ x_1 = 1$

and

$1-x_3 = 1 \ or \ x_1 = 1$

and

$1-x_4 = 1 \ or \ x_1 = 1$

$\iff$

$1-x_2 + x_1 \ge 1$

and

$1-x_3 + x_1 \ge 1$

and

$1-x_4 + x_1 \ge 1$

$$x_2+x_3+x_4 \le M(x_1)$$

What Kuifje said.

If $x_2 + x_3 + x_4 = 0$, then $x_1 = 0$

$\iff$

$x_2 + x_3 + x_4 > 0$ if $x_1 = 1$

$\iff$

$x_2 > 0 \ or \ x_3 > 0 \ or \ x_4 > 0$ if $x_1 = 1$

$\iff$

$x_2 > 0 \ or \ x_3 > 0 \ or \ x_4 > 0 \ or \ 1 - x_1 = 1$

$\iff$

$x_2 > 0 \ or \ x_3 > 0 \ or \ x_4 > 0 \ or \ 1 - x_1 > 0$

$\iff$

$x_2 + x_3 + x_4 + 1 - x_1 > 0$

$\iff$

$x_2 + x_3 + x_4 > x_1 - 1$

$$-(x_2+x_3+x_4) < M(1-x_1)$$

Don't forget

$$x_1 \in \{0,1\}$$

$$1 \ge x_2, x_3, x_4 \ge 0$$

According to you $x_1$ is a binary decision variable. So the constraints will look like this

[ $x_1$= \begin{cases} 1,& \text{if } x_2+x_3+x_4>0\\ 0, & \text{if } x_2+x_3+x_4 =0 \end{cases} ]

I think this constraint suitable for MILP.