2

I'm new to Gurobi in Python and I am wondering if there is way to code the following constraints:

1- $\sum x_i =0$ for all $i\in A$ OR for all $i \in B$
where A and B are distinch sets of integers and $x_i$ are binary variables.

2- $\sum_{i=0}^{10} x_i =0$ OR $\sum_{i=0}^{10} x_i =1$

Question: Is there a way to express the "Or" in one of the above constraints ?/code in Gurobi (maybe something like addConstrOr instead of addConstr)

My thoughts: maybe something like that would work for (1) and (2), but I am not sure if it is possible

  • model. addConstr (sum( x [ i] for i in A) ==0) or model. addConstr (sum( x [ i] for i in B) ) ==0)

  • model. addConstr (sum( x [ i] for i in range(0,10) ) ==0) or model. addConstr (sum( x [ i] for i in range(0,10) ) ==1)

SecretAgentMan
  • 1,895
  • 2
  • 13
  • 39
M.Badaoui
  • 185
  • 5

0 Answers0