0

How to implement v=(a==b) using Linear Programming? $$ v= \begin{cases} True, a=b\\ False, a≠b\\ \end{cases} $$

Until now I tried the big M-Method.

To show a≤b: $$a-b+Mv≤M$$ $$-a+b-Mv≤-1$$

To show b≤a: $$-a+b+Mv≤M$$ $$a-b-Mv≤-1$$

When they are equal everything is okay, but when a≠b it doesn't work.

D.W.
  • 159,275
  • 20
  • 227
  • 470
Adamos2468
  • 41
  • 2

1 Answers1

2

Use Cast to boolean, for integer linear programming, setting $x=a-b$ and $y=v$. This only works if you have a constant upper bound on $|a-b|$. Otherwise, I don't know how to express it in an ILP.

See also Express boolean logic operations in zero-one integer linear programming (ILP), Boolean variable true iff equation is satisfied in ILP, Boolean variable that captures whether an inequality holds.

D.W.
  • 159,275
  • 20
  • 227
  • 470