0

I would like to express if then else statement in a set of constraints using Gurobi via Python API where B and A are binary decision variables.

Here is the statement I am stuck on :

If (B[r,u,v,x,y]) then A[r,u,x] or A[r,v,y]

Else set the value of B[r,u,v,x,y] == 0 when A[r,u,x] =1 and A[r,v,x]

I know how to express the first part of if then as :

B[r,u,v,x,y] >= A[r,u,x]

B[r,u,v,x,y] >= A[r,v,u]

But not sure how to formulate into constraints : when B[r,u,v,x,y] to be 0 if A[r,u,x] and A[r,v,y] are set to 1 in the else part.

Thanks

7
  • Written like that it's ambiguous if not nonsense. Try to write it more formally, e.g by using pure propositional calculus (and state if those are binary-variables or integers; the else-line is unclear about that) Commented Oct 18, 2017 at 22:20
  • @sascha I edited my post, hopefully now it is more clear. thanks :) Commented Oct 19, 2017 at 2:28
  • 1
    Still unclear, but maybe it does not matter (if you know what to formulate): just follow propositional logic in your else too; and ignore the fact it's an else in your case! Just treat it as new expression: something like (prototype): (a_0 & a_1) -> B < DeMorgan-> (not a_0 or not a_1) or B. If needed you can create some auxiliary-variable for the first subexpression (not a_0 or not a_1 == new_var) (where not is for binaries a (1-var) and an equality are two implications. Commented Oct 19, 2017 at 2:32
  • thanks @sascha. I mean when A[r,u,x] =1 and A[r,v,x]=1 as I put the same index x I need to force B[r,u,v,x,y] to be 0, so do you suggest to follow the propositional logic ? Commented Oct 19, 2017 at 2:57
  • 1
    Yes. Given it's an implication it's just (1-A0) + (1-A1) + (1-B) >= 1 Commented Oct 19, 2017 at 10:47

0

Your Answer

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.