I have a set of integer $\{0,1\}$ variables $x_1$,$y_1$,$x_2$,$y_2$,$x_3$,$y_3$,$x_4$,$y_4$
I want a conditional constraint such that if any of the $x$ variables is equal to 1, I want the sum of the subsequent $y$ variables to be $2$.
For example
- if $x_1==1$ then $y_2+y_3+y_4=2$,
- if $x_2==1$ then $y_3+y_4=2$
- if $x_3==1$ then $y_4=2$
The objective function is just the sum of all the variables. There are additional constraints such as: $x_1+x_2+x_3+x_4=2$ and $y_1+y_2+y_3+y_4=2$.
The solution here would be: $1 0 1 0 0 1 0 1$
I have figured out the answer to this. The constraints:
can also be formulated as:
Hence the constraints can be written as such:
Where $M$ is a very large integer.