Variable lb and ub active based on a binary variable
AnsweredRecently I was building an FBA model as part of my research. The variable is \(v_j\), it has lower and upper bounds, the LB and UB are dictionaries.
In the first approach, I set the lb and ub as:
model.addConstrs((LB[j] <= v[j] for j in list ), name='LB')
model.addConstrs((v[j] <= UB[j] for j in list), name='UB')
The result was not as I expected as the model gave me zeros or unbounded, Later I change the lb and ub when adding the variables as:
model.addVars(v, lb=LB,ub=UB, name='v')
This gave the answer I was looking for, but it raised a question if my lb and ub are defined something like this
\(LB*(1-y_j) <= v_j <= UB*(1-y_j)\)
Where \(y_j\) is binary, How can these bounds be added to my variable \(v_j\)?
Thanks!
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
As you can see in the documentation, you cannot simply add a constraint `a \leq x \leq b` is not permissible. Therefore you need to split the constraint you are describing into two.
In addition, note that these are not bounds in the strict sense, as they feature variables in the right-hand side.
0
Post is closed for comments.
Comments
2 comments