0
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ x1 and x2 values are allowed to be any integer such that it could be 1, 2, 3, 4, 5 etc... how would you remodel your constraint to apply to numbers other than 0 and 1? $\endgroup$ – hercules403 Nov 11 at 19:51
  • $\begingroup$ If you have another question you can post a new question. $\endgroup$ – callculus Nov 14 at 15:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.