Pyomo / pyomo

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

Multiple solvers are missing a config_block method #2703

Open MKuranowski opened 1 year ago

MKuranowski commented 1 year ago

Summary

Steps to reproduce the issue

$ pip3 install -U "pyomo[optional]"
$ pyomo solve some_model.py --solver=gdpopt
Traceback (most recent call last):
  File "/tmp/foo/.venv/bin/pyomo", line 8, in <module>
    sys.exit(main_console_script())
  File "/tmp/foo/.venv/lib/python3.10/site-packages/pyomo/scripting/pyomo_main.py", line 93, in main_console_script
    ans = main()
  File "/tmp/foo/.venv/lib/python3.10/site-packages/pyomo/scripting/pyomo_main.py", line 85, in main
    retval = _options.func(_options, _unparsed)
  File "/tmp/foo/.venv/lib/python3.10/site-packages/pyomo/scripting/plugins/solve.py", line 191, in solve_exec
    config = opt.config_block()
AttributeError: 'GDPoptSolver' object has no attribute 'config_block'
$ pyomo solve some_model.py --solver="mindtpy"
Traceback (most recent call last):
  File "/tmp/foo/.venv/bin/pyomo", line 8, in <module>
    sys.exit(main_console_script())
  File "/tmp/foo/.venv/lib/python3.10/site-packages/pyomo/scripting/pyomo_main.py", line 93, in main_console_script
    ans = main()
  File "/tmp/foo/.venv/lib/python3.10/site-packages/pyomo/scripting/pyomo_main.py", line 85, in main
    retval = _options.func(_options, _unparsed)
  File "/tmp/foo/.venv/lib/python3.10/site-packages/pyomo/scripting/plugins/solve.py", line 191, in solve_exec
    config = opt.config_block()
AttributeError: 'MindtPySolver' object has no attribute 'config_block'
$ pyomo solve some_model.py --solver="scipy.fsolve"
Traceback (most recent call last):
  File "/tmp/foo/.venv/bin/pyomo", line 8, in <module>
    sys.exit(main_console_script())
  File "/tmp/foo/.venv/lib/python3.10/site-packages/pyomo/scripting/pyomo_main.py", line 93, in main_console_script
    ans = main()
  File "/tmp/foo/.venv/lib/python3.10/site-packages/pyomo/scripting/pyomo_main.py", line 85, in main
    retval = _options.func(_options, _unparsed)
  File "/tmp/foo/.venv/lib/python3.10/site-packages/pyomo/scripting/plugins/solve.py", line 191, in solve_exec
    config = opt.config_block()
AttributeError: 'PyomoFsolveSolver' object has no attribute 'config_block'

Information on your system

Pyomo version: 6.4.4 Python version: 3.10.9 Operating system: Debian Testing How Pyomo was installed (PyPI, conda, source): PyPI through a virtual environment Solver (if applicable):

emma58 commented 1 year ago

Note that all of the solvers you mention are in contrib, so they don't necessarily make promises about being fully integrated with the rest of pyomo. Here, it looks like the pyomo command assumes config_block exists, but the issue runs deeper because the pyomo command also makes assumptions on what config options solvers have. Several solvers in contrib violate these assumptions as well.

@MKuranowski, I would recommend transitioning to scripting rather than using the pyomo command, if you want to use these solvers.

mrmundt commented 1 year ago

@MKuranowski - I will also note, just for posterity, that we have wild machinations to eventually rework the solver interfaces overall to make it easier to introduce new interfaces. That, unfortunately, is not the highest priority on the backlog.