Check solving state of model #5
-
I am wondering if it is possible to automatically check the solving status of the model, similar to the examples from from gurobipy import GRB
if model.Status == GRB.INF_OR_UNBD:
pass
if model.Status == GRB.OPTIMAL:
pass
elif model.Status != GRB.INFEASIBLE:
pass I know I can get the solving state via sol_state = model.get_model_attribute(poi.ModelAttribute.TerminationStatus) , but I am unsure what should be compared with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
For the solver-agnostic attribute, the return value of status = model.get_model_attribute(poi.ModelAttribute.TerminationStatus)
if status == poi.TerminationStatusCode.OPTIMAL:
...
elif status == poi.TerminationStatusCode.INFEASIBLE:
...
elif status == poi.TerminationStatusCode.INFEASIBLE_OR_UNBOUNDED
... The concept is the same as JuMP.jl and I have followed the same logic in Gurobi.jl Of course, you can also query the Gurobi-specific status as documented in https://metab0t.github.io/PyOptInterface/gurobi.html#attribute and https://www.gurobi.com/documentation/current/refman/attributes.html#sec:Attributes import pyoptinterface as poi
from pyoptinterface import gurobi
GRB = gurobi.GRB
status = model.get_model_raw_attribute("Status")
if status == GRB.INF_OR_UNBD:
pass
if status == GRB.OPTIMAL:
pass
elif status == GRB.INFEASIBLE:
pass The |
Beta Was this translation helpful? Give feedback.
-
@Zhanwei-Liu I have updated the code and documentation for |
Beta Was this translation helpful? Give feedback.
For the solver-agnostic attribute, the return value of
model.get_model_attribute(poi.ModelAttribute.TerminationStatus)
ispyoptinterface.TerminationStatusCode
as documented in the table.The concept is the same as JuMP.jl and I have followed the same logic in Gurobi.jl
https://jump.dev/JuMP.jl/stable/manual/solutions/#Why-did-the-solver-stop?
https://jump.dev/JuMP.jl/stable/moi/reference/models/#MathOptInterface.TerminationStatusCode