Continuous and binary variable question

83 Views Asked by At

For $y_1$ and $y_2$ as continuous variables

how can this statement be reformed in binary and continuous variables with linear constraints

Either $|y_1 - y_2| = 2$ or $|y_1 - y_2| = 4$

1

There are 1 best solutions below

0
On

\begin{align} t_1,t_2 &\in \{0,1\}\\ |y_1-y_2|&=2t_1 + 4t_2\\ t_1 + t_2 &= 1 \end{align}

The first constraint states that the variables are binary. Second one allows the LHS to be either 0,2,4 or 6 (depending on $t_1$ and $t_2$). The third one prevents the sum required term from being $0$ or $6$.