I have two variables. $g$ is a binary variable and $s$ is a continuous variable. Goal is to linearize this $gs \geq0$ a.k.a if $s \geq 0, g = 1\:\: \text{or}\:\: s\leq0, g = 0$. How can I linearize this ?
Asked
Active
Viewed 39 times
0
-
When $s\ge 0$, $gs\ge 0$ is satisfied by both $g=1$ and $g=0$. Is that what you want, or do you want the following: $s>0 \implies g=1$; $s<0 \implies g=0$; $s=0$ implies nothing about $g$ (which could be either 0 or 1)? – prubin Dec 13 '18 at 16:38
-
Sorry about the confusion. $s > 0 \Rightarrow g = 1; s \leq 0 \Rightarrow g = 0 $, a.k.a I want get $ g = 0$ if $s = 0$. Thank you for your reply. – Jinghan Yang Dec 14 '18 at 22:01
-
You cannot get exactly what you want. In order to get $g=0$ when $s=0$, you would have to settle for $s\ge \epsilon \implies g=1$ and $0 < s < \epsilon$ infeasible, for some $\epsilon > 0$. $\epsilon$ can be small but not too small (i.e., not small enough that it is within rounding tolerance of 0 from the solver's perspective). Is that acceptable? – prubin Dec 16 '18 at 16:01