How to compute the objective and feasibility of a manually given solution?
回答済みSuppose "sol" is a list that consists of the value of each variable.(sol is given by user)
How to compute the objective and feasiblity of sol
0
-
One easy way is to fix every variable to its sol value. The following pseudo code should give you an idea
sol = ... # given solution values
for var in model.getVars():
# fix variable to its sol value
var.lb = sol[var]
var.ub = sol[var]
# optimize model
model.optimize()
if model.status == GRB.OPTIMAL:
print(model.ObjVal) # print objective value
print(model.MaxVio) # print maximum violation of the solution
if model.status == GRB.INFEASIBLE:
# if given sol values are infeasible generate an IIS file called iis.ilp
# to easily check why it is infeasible
model.computeIIS()
model.write("iis.ilp")For additional information please refer to the Attributes documentation and How does Gurobi compute the IIS for infeasible models?
Best regards,
Jaromił0
サインインしてコメントを残してください。
コメント
1件のコメント