Gurobi solvetime in pyomo
AnsweredI encountered an issue while using Pyomo 6.9.2 with Gurobi 12.0.3 in Python 3.10. When attempting to retrieve solver time using results.solver.time, I received the error:
AttributeError: Unknown attribute 'time' for object with type <class 'pyomo.opt.results.solver.SolverInformation'>.
However, when I reverted to Python 3.8 with Pyomo 6.8.0 and Gurobi 11.0.3, the same approach worked correctly. Could this indicate that newer Pyomo versions or Gurobi versions have changed how solver time is accessed? Any insights would be appreciated.
-
Hi Zhiyu,
I've had a look and this issue is independent of Gurobi version.
The exact change that causes the difference in behavior was introduced in this commit:
https://github.com/Pyomo/pyomo/commit/35877632ef13c2a80aff01c7de479405ce0de777
This commit is not directly related to the “Time” attribute, but causes Pyomo to call Gurobi in a different way, and the Time attribute is not added.
To me it looks like the “Time” attribute is a mistake and should never have been there. It's also not clear what the time is referring to, but it is certainly not the optimization time. To me it looks like accessing the optimization time should be done via
results.solver.wall_time- Riley
0 -
Pyomo devs are refactoring the solver interfaces.
You can now use the latests Gurobi interface with:
from pyomo.contrib.solver.solvers.gurobi_direct import GurobiDirect opt = GurobiDirect() results = opt.solve(model) wall_time = results.timing_info["wall_time"]1
Please sign in to leave a comment.
Comments
2 comments