4
$\begingroup$

Suppose $C_1 \ge 0$, $C_2 \ge 0$ are continuous variables and $b_1$, $b_2$ are binary variables.

How could I model the following?

$C_1 = C_2 \implies b_1 = b_2$, the opposite does not hold.

$\endgroup$

2 Answers 2

7
$\begingroup$

Equivalently, you want to enforce the contrapositive $$b_1 \not= b_2 \implies C_1 \not= C_2$$ Because the $b_i$ are binary, this is the same as $$b_1 + b_2 = 1 \implies C_1 \not= C_2$$ Let $\epsilon>0$ be a small constant tolerance, and suppose that $C_i \le M_i$. Introduce binary variables $y_i$ and $z_i$, and impose linear constraints \begin{align} b_1 + b_2 &= 2y_1 + y_2 \tag1\label1 \\ y_2 &\le z_1 + z_2 \tag2\label2 \\ C_1 - C_2 + \epsilon &\le (M_1 + \epsilon) (1-z_1) \tag3\label3 \\ C_2 - C_1 + \epsilon &\le (M_2 + \epsilon) (1-z_2) \tag4\label4 \end{align} Constraint \eqref{1} enforces $b_1 + b_2 = 1 \implies y_2$. Constraint \eqref{2} enforces $y_2 \implies (z_1 \lor z_2)$. Constraint \eqref{3} enforces $z_1 \implies C_1 + \epsilon \le C_2$. Constraint \eqref{4} enforces $z_2 \implies C_2 + \epsilon \le C_1$.

$\endgroup$
2
$\begingroup$

You can try the following
Lets define 3 binary variables $y_1,y_2,z$
Additional constraints with $\delta$ as small positive number
$c_1-c_2 + \delta \le My_1$
$c_2-c_1-\delta \le M(1-y_1)$
$c_2-c_1+\delta \le My_2$
$c_1-c_2-\delta \le M(1-y_2)$
$y_1+y_2 \le 1+z$
$z\le y_1,y_2$
Then
$ b_2+z-1 \le b_1 \le b_2 + 1-z$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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