I have variables $a,b\in\mathbb R$ and if $a>1$ I want $b=1$ or else $b=0$. Can this be encoded by linear programming (no integer variables)? Even $b<0.5$ and $b>0.5$ is ok.
$\begingroup$
$\endgroup$
5
-
$\begingroup$ This may give some idea. $\endgroup$– Sanjay ChandlekarCommented Apr 11, 2018 at 5:50
-
2$\begingroup$ LP feasible region is convex. Your region for $a,b \in R$ is not. Maybe you are looking for Integer Programming formulation? $\endgroup$– EugeneCommented Apr 11, 2018 at 17:36
-
$\begingroup$ @Eugene can you explain why? $\endgroup$– TurboCommented Apr 11, 2018 at 22:51
-
1$\begingroup$ You changed the question to a different one, in a way that invalidates the existing answer. That's not very polite to the person who took the time to write an answer to the original question. $\endgroup$– D.W. ♦Commented Apr 11, 2018 at 23:28
-
$\begingroup$ @d.w. ok I will change. $\endgroup$– TurboCommented Apr 12, 2018 at 0:19
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
3
The if then contraints can be written equivalently as
- If $b = 0$, then $a < 1$; and
- If $b = 1$, then $a \geq 1$.
Introduce a large number $M$ and add the following constraints:
$$b(M+1)-M \le a < b(M+1)+1.$$
EDIT: I assumed that $b$ is binary. If $a$ is bounded $a\in[L,U)$, we can write the constraints as:
$$b(-L+1)+L \le a < b(U-1)+1.$$
-
$\begingroup$ how large should M be? also this takes $b\in\mathbb Z$. $\endgroup$– TurboCommented Apr 11, 2018 at 16:33
-
$\begingroup$ I assumed that $b$ is binary. For $M$, it depends on $a$. See my edits. $\endgroup$– zdmCommented Apr 11, 2018 at 17:03
-
$\begingroup$ there is an issue i think $a>1$ not $a\geq1$. What if $b=0\iff a\in[0,1]$ and $b=1\iff a>1$? $\endgroup$– TurboCommented Apr 11, 2018 at 17:19