0
$\begingroup$

I'm working on a OR project. I have a code which fixes my problem which uses the constraint

((a =< b) or (c =< d) or (e =< f)) = True

I need to rewrite this condition as mathematical expression(s)

I tried

(a-b) * (c-d) * (e-f) =< 0

Which seems to work for most cases but fails when two of them are positive and one of them are negative.

Any help is greatly appreciated.

$\endgroup$
  • 1
    $\begingroup$ Why do you think you need to write this more compactly? Your first condition seems clear to me. $\endgroup$ – Jack M Apr 18 '14 at 23:02
  • $\begingroup$ I need to write down a mathematical model for my code, which got me stuck. $\endgroup$ – Halox Apr 18 '14 at 23:20
  • $\begingroup$ I don't know exactly why you want this but you could do $\frac{b-a}{|b-a|} + \frac{d-c}{|d-c|} + \frac{f-e}{|f-e|} \neq -3$ $\endgroup$ – KSab Apr 18 '14 at 23:31
  • $\begingroup$ WOW! that was brilliant. Thanks. $\endgroup$ – Halox Apr 18 '14 at 23:38
1
$\begingroup$

$\max(b-a,d-c,f-e)\ge 0$.

But really, it already was mathematical.

$\endgroup$
0
$\begingroup$

Another way: $$ (|a - b| + a - b)(|c - d| + c - d)(|e - f| + e - f) \le 0 $$

$\endgroup$
  • $\begingroup$ I think you can use $=0$ instead of $\le 0$ if you want $\endgroup$ – Ross Millikan Apr 19 '14 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.