# Two conditional constraints (either or neither) for integer binary programming [closed]

Not sure how to go on about finding this constraint. The constraint asks for; either both or neither of $$x_1$$ and $$x_2$$ should appear.

What I have so far is that y can be either binary values $$0$$ or $$1$$. When the value is $$0$$, then neither $$x_1$$ nor $$x_2$$ appear. When the value is $$1$$, $$x_1$$ and $$x_2$$ must both appear (they must be one or greater).

When $$y=0$$, then $$x_1+x_2=0$$. When $$y=1$$, then $$x_1\times x_2\geq 1$$. The issue is I'm having trouble incorporating the y into these constraints.

The constraint asks for either both or neither of $$x_1$$ and $$x_2$$ should appear.
If you ask just for this constraint there is no need to introduce a variable $$y$$. You can use the difference:
\begin{equation} \begin{aligned} & x_1-x_2=0\\ &x_1,x_2 \in \{0,1\}\\ \end{aligned} \end{equation}
Only two combinations are valid: $$x_1=x_2=0$$ and $$x_1=x_2=1$$. The combinations $$x_1=0,x_2=1$$ and $$x_1=1, x_2=0$$ are not possible.