Mixed Integer Programming - variable that equals the sign of an expression

34 Views Asked by At

I want to define the following:

y = 1 if x<=th

= 0 otherwise

Currently I'm doing the following:

Let's say we know the lower and upper bound of x-th. i.e. L <= x-th <= U

Then I am adding the following two constraints:

x-th >= L*y

x-th <= U*(1-y)

This works mostly, but when x-th=0, y could be both 1 or 0. How do I handle this scenario when x-th=0. I want y to be 1 not 0.

1

There are 1 best solutions below

1
On BEST ANSWER

Let $\epsilon>0$ be a small constant tolerance and impose $$Ly + \epsilon(1-y) \le x - \text{th} \le 0y + U(1-y)$$ Then $y = 1 \implies L \le x-\text{th} \le 0$, and $y = 0 \implies \epsilon \le x - \text{th} \le U$.