Pyomo / pyomo

An object-oriented algebraic modeling language in Python for structured optimization problems.
https://www.pyomo.org
Other
2.01k stars 518 forks source link

Unknown attribute `time` for solver appsi_highs #2664

Open alejandro-yousef opened 1 year ago

alejandro-yousef commented 1 year ago

Summary

After solving an optimization model with appsi_highs I get an AttributeError when trying to access the solver execution time. This attribute does exist with other solvers (e.g., glpk, cbc,...).

Steps to reproduce the issue

import pyomo.environ as pe

opt_solver = pe.SolverFactory("appsi_highs")
results = opt_solver.solve(model)

print(results.solver.time)

Error Message

    print(results.solver.time)
  File "C\pyomo\opt\results\container.py", line 175, in __getattr__
    return getattr(self._list[0], name)
  File "C:\pyomo\opt\results\container.py", line 284, in __getattr__
    raise AttributeError("Unknown attribute `"+str(name)+"' for object with type "+str(type(self)))
AttributeError: Unknown attribute `time' for object with type <class 'pyomo.opt.results.solver.SolverInformation'>

Information on your system

Pyomo version: 6.4.4 Python version: 3.9 Operating system: Windows10 How Pyomo was installed (PyPI, conda, source): PyPI Solver (if applicable): appsi_highs

michaelbynum commented 1 year ago

I'll get this fixed. This is an issue with the wrapper. The following should currently work:

opt = appsi.solvers.Highs()
res = opt.solve(m)
print(res.wallclock_time)

but this uses the new interface without the wrapper, so there are some subtle differences to the interface.