# Modeling the sum of binary variables

Suppose $$x_{1},x_{2}, \cdots ,x_{n}$$ are binaries.

I would like to model the following:

IF $$x_{1} + x_{2}+ \cdots +x_{n} \ge 2$$ THEN $$x_{1} + x_{2} = 2$$

IF $$x_{1} + x_{2}+ \cdots +x_{n} \ge 3$$ THEN $$x_{1} + x_{2} + x_{3}= 3$$

and so on.

Is there a better way than asking for the following

$$(x_{1} \ge 1) \lor (x_{1} + x_{2} \ge 2) \lor (x_{1} + x_{2} + x_{3} \ge 3) \cdots$$, which then requires the introduction of additional binaries?

• I think you need another clause in the disjunction: $\sum_{i=1}^n x_i = 0$. Otherwise, $x_1=1$ is forced. – RobPratt May 12 '20 at 20:35
• Yes, you are right! – Clement May 12 '20 at 21:01

Does $$x_i \ge x_{i+1}$$ do what you want?