How to check conditional constraints added to the model?
AnsweredHi Gurobi Community,
I want to know how I can check constraints like https://www.gurobi.com/documentation/current/refman/py_model_agc_indicator.html in my model using something like model.disply() function. E.g. for the following dummy example:
import gurobipy as gp
model = gp.Model()
x = model.addVar(vtype=gp.GRB.BINARY, name="x")
y = model.addVar(vtype=gp.GRB.BINARY, name="y")
a = model.addVar(vtype=gp.GRB.BINARY, name="a")
z = model.addVar(vtype=gp.GRB.CONTINUOUS, name="z", ub=30)
model.addGenConstrAnd(a, [x, y], "andconstr")
model.update()
# constr1 = model.addConstr(z <= 20)
constr2 = model.addConstr((a == 0) >> (z <= 5))
model.setObjective(z+x+y+a, gp.GRB.MAXIMIZE)
model.update()
# Solve the model
model.optimize()
model.display()
calling model.display() will only show me the following:
Maximize
x + y + a + z
Subject To
Bounds
0 <= z <= 30
Binaries
['x', 'y', 'a']
and it dos not show anything regarding:
model.addGenConstrAnd(a, [x, y], "andconstr")
or:
constr2 = model.addConstr((a == 0) >> (z <= 5))
Is there a way to see such information in Gurobi model.display() or some similar function?
0
-
Official comment
This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Saeid,
The Model.display() function is not documented, and may possibly be removed in the near future.
The best approach is to write the model out to LP:
model.write("my_model.lp")and then inspect the output in a text editor.
- Riley
0
Post is closed for comments.
Comments
2 comments