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