How to check conditional constraints added to the model?
回答済みHi 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
-
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
サインインしてコメントを残してください。
コメント
1件のコメント