3
$\begingroup$

I have a continuous variable $z, {-1 < z < 1},$ and a binary variable $w$.

How do I write a conditional constraint which guarantees for $z < 0$, $w = 1$,
and for $z \ge 0$, $w = 0$?

$\endgroup$
2
  • 1
    $\begingroup$ Technically, you cannot do this. The best you can do is either to allow both values of $w$ when $z=0$ (as in the answer by ytsao) or to change the domain of $z$ to $[-1, -\epsilon] \cup [0, 1]$ for some small but strictly positive value of $\epsilon.$ $\endgroup$
    – prubin
    Commented Jul 15 at 15:57
  • $\begingroup$ See cs.stackexchange.com/q/69531/755 and cs.stackexchange.com/q/67163/755 $\endgroup$
    – D.W.
    Commented Jul 15 at 21:43

2 Answers 2

1
$\begingroup$

The following constraints should be work:

$z \leq M(1-w)$

$z \geq -Mw$

$\endgroup$
4
$\begingroup$

Generally, in LP, we do not use strict inequalities. When we consider non-strict inequalities, Ytsao's answer works using $M=1$, $-w \leq z \leq 1-w$.

$\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.