[Math] Mixed Integer Linear Programming Conditional Constraints

integer programminglinear programminglogicmathematical modelingoperations research

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$.

Best Answer

You can write $$x_1=-\left\lfloor -{x_2+x_3+x_4\over 3}\right\rfloor$$which is equivalent to the following linear constraints:$$-x_1\le -{x_2+x_3+x_4\over 3}<-x_1+1$$or equivalently$$-3x_1+x_2+x_3+x_4\le 0\\-3x_1+x_2+x_3+x_4>-3$$