You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I feed pyomo an unfeasible model, I get the following RuntimeError:
A feasible solution was not found, so no solution can be loaded.Please set opt.config.load_solution=False and check results.termination_condition and results.best_feasible_objective before loading a solution.
Following the instructions and setting opt.config.load_solution = False does not stop the RuntimeError from being raised, so I still can't check the termination condition. I would expect that when choosing this setting, no error would be raised and I would be able to look at my results object.
Looking through the stack trace, the final error happens here: https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/appsi/solvers/highs.py#L671
This block of code seems to be indented incorrectly, resulting in unexpected behavior given the provided error message. More specifically, the else statement that raises the RuntimeError is aligned with if has_feasible_solution: on line 661 and not with if config.load_solution: on line 660. Aligning the indent to line 660 induces the expected behavior given the error message provided.
Steps to reproduce the issue
I am using pyomo with the HiGHS solver. I installed the HiGHS solver following the instructions on their website: https://ergo-code.github.io/HiGHS/dev/interfaces/cpp/.
I then locally installed highspy to make sure pyomo could find the solver.
In order to reproduce my output, you need to install pyomo and highspy. Then, run the test.py script presented below with the following command:
$ python -m testTraceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "~/Projects/pyomo-test/test.py", line 17, in <module> results = opt.solve(model) File "~/Projects/pyomo-test/.venv/lib/python3.11/site-packages/pyomo/contrib/appsi/base.py", line 1557, in solve results: Results = super(LegacySolverInterface, self).solve(model) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "~/Projects/pyomo-test/.venv/lib/python3.11/site-packages/pyomo/contrib/appsi/solvers/highs.py", line 250, in solve res = self._solve(timer) ^^^^^^^^^^^^^^^^^^ File "~/Projects/pyomo-test/.venv/lib/python3.11/site-packages/pyomo/contrib/appsi/solvers/highs.py", line 234, in _solve return self._postsolve(timer) ^^^^^^^^^^^^^^^^^^^^^^ File "~/Projects/pyomo-test/.venv/lib/python3.11/site-packages/pyomo/contrib/appsi/solvers/highs.py", line 671, in _postsolve raise RuntimeError(RuntimeError: A feasible solution was not found, so no solution can be loaded.Please set opt.config.load_solution=False and check results.termination_condition and results.best_feasible_objective before loading a solution.
Information on your system
Pyomo version: Pyomo 6.7.0 (CPython 3.11.2 on Linux 6.6.10-76060610-generic)
Python version: 3.11.2
Operating system: Pop!_OS
How Pyomo was installed (PyPI, conda, source): pip (via poetry)
Solver (if applicable): HiGHS (with highspy)
The text was updated successfully, but these errors were encountered:
Thank you for answering, your solution indeed works. I guess the stack trace was a red herring in this case! If you want I can write a PR to make the error message more explicit. I don't want to clutter your PR backlog and couldn't find a "minimum size" of PR to submit but I'll defer to you.
Summary
When I feed pyomo an unfeasible model, I get the following RuntimeError:
A feasible solution was not found, so no solution can be loaded.Please set opt.config.load_solution=False and check results.termination_condition and results.best_feasible_objective before loading a solution.
Following the instructions and setting
opt.config.load_solution = False
does not stop the RuntimeError from being raised, so I still can't check the termination condition. I would expect that when choosing this setting, no error would be raised and I would be able to look at my results object.Looking through the stack trace, the final error happens here: https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/appsi/solvers/highs.py#L671
This block of code seems to be indented incorrectly, resulting in unexpected behavior given the provided error message. More specifically, the else statement that raises the RuntimeError is aligned with
if has_feasible_solution:
on line 661 and not withif config.load_solution:
on line 660. Aligning the indent to line 660 induces the expected behavior given the error message provided.Steps to reproduce the issue
I am using pyomo with the HiGHS solver. I installed the HiGHS solver following the instructions on their website: https://ergo-code.github.io/HiGHS/dev/interfaces/cpp/.
I then locally installed highspy to make sure pyomo could find the solver.
In order to reproduce my output, you need to install pyomo and highspy. Then, run the
test.py
script presented below with the following command:$ pyhton -m test
Here is my example script: (stolen with a small added constraint from https://pyomo.readthedocs.io/en/stable/pyomo_overview/simple_examples.html)
Error Message
Here is the entire stack trace:
Information on your system
Pyomo version: Pyomo 6.7.0 (CPython 3.11.2 on Linux 6.6.10-76060610-generic)
Python version: 3.11.2
Operating system: Pop!_OS
How Pyomo was installed (PyPI, conda, source): pip (via poetry)
Solver (if applicable): HiGHS (with highspy)
The text was updated successfully, but these errors were encountered: