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$?
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$?
The following constraints should be work:
$z \leq M(1-w)$
$z \geq -Mw$
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$.