# On if then condition in linear programming?

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.

• This may give some idea. – Sanjay Chandlekar Apr 11 '18 at 5:50
• LP feasible region is convex. Your region for $a,b \in R$ is not. Maybe you are looking for Integer Programming formulation? – Eugene Apr 11 '18 at 17:36
• @Eugene can you explain why? – T.... Apr 11 '18 at 22:51
• 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. – D.W. Apr 11 '18 at 23:28
• @d.w. ok I will change. – T.... Apr 12 '18 at 0:19

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

• how large should M be? also this takes $b\in\mathbb Z$. – T.... Apr 11 '18 at 16:33
• I assumed that $b$ is binary. For $M$, it depends on $a$. See my edits. – zdm Apr 11 '18 at 17:03
• 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$? – T.... Apr 11 '18 at 17:19