How to distinguish the scenarios between "TIMEOUT with feasible solution" and "TIMEOUT without feasible solution"?
AnsweredHi,
I'm trying to distinguish the scenarios mentioned in the title, in Python.
More specifically, I have code like:
...
m.optimize()
res = {}
# In this case, I clearly know there is not solution
if m.Status == GRB.INFEASIBLE:
return res, m
# However, in other cases, I want to extract as much information
# as I can
res['LB'] = m.ObjBound # It has a bound
res['UB'] = m.ObjVar # It has a feasible solution
res['decisions'] = m.getAttr(...) # Extract decision variables
...
return res, m
Is there any way to distinguish these cases without running into `GurobiError` or `AttributeError`? (We'd prefer not to use try-catch here for some reasons)
Thanks.
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 Shizhe,
I expect checking that the result of Model.SolCount() is non-zero will solve your problem.
- Riley
0
Post is closed for comments.
Comments
2 comments