0
$\begingroup$

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.
168k23 gold badges233 silver badges517 bronze badges
asked May 5, 2019 at 19:40
$\endgroup$

1 Answer 1

2
$\begingroup$

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.

answered May 5, 2019 at 21:49
$\endgroup$
1
  • $\begingroup$ I forgot to mention because I thought it was irrelevant but 1<=|a|,|b|<=10. $\endgroup$ Commented May 6, 2019 at 4:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.