Description
Summary
I am using the CPLEXPersistent solver interface for my problem. Here is what I do:
- I build a pyomo concrete model and solve it
- I update the model objective and do the solver.set_instance(model) to update the model
- I solve it again.
When I solve it again, the cplex solver log clearly shows that cplex solved the model but then I get an error saying:
ValueError: Cannot load a SolverResults object with bad status
I am very sure that the CPLEX is able to solve the model to optimality (there is no infeasibility or unboundedness or any other error).
To troubleshoot, I replace the cplex_persistent solver with gurobi_persistent and the error goes away. So it's fair to think that the issue is with the cplex_persistent plugin and not with my model.
Also, one more important thing to mention: This error doesn't appear 100% of time, I did 10 runs of my code and it was successful 6 times.
Steps to reproduce the issue
from pyomo.opt import SolverFactory
solver = SolverFactory("cplex_persistent")
model: pyo.ConcreteModel = get_model(input_data=data)
solver.set_instance(model)
result = solver.solve(model)
model = update_model(model)
solver.set_instance(model)
result = solver.solve(model)
Since, this error doesn't happen all the time, I would recommend running it multiple times.
Error Message
ValueError: Cannot load a SolverResults object with bad status`
$ # Output message here, including entire stack trace, if available
line 98, in main
result = solver.solve(model, report_timing=False)
File "C:\Users\xxx\Downloads\.venv\lib\site-packages\pyomo\solvers\plugins\solvers\persistent_solver.py", line 567, in solve
_model.solutions.load_from(
File "C:\Users\xxx\Downloads\.venv\lib\site-packages\pyomo\core\base\PyomoModel.py", line 228, in load_from
raise ValueError(
ValueError: Cannot load a SolverResults object with bad status: error
Information on your system
Pyomo version: Pyomo 6.7.3 (CPython 3.8.0 on Windows 10)
Python version: Python 3.8.0
Operating system: Windows 10
How Pyomo was installed (PyPI, conda, source): pip
Solver (if applicable): cplex_persistent (cplex version 20.1.0.0)
Additional information
This error doesn't appear 100% of time, I did 10 runs of my code and it was successful 6 times. When I replace the cplex_persistent solver with gurobi_persistent the error goes away. So it's fair to think that the issue is with the cplex_persistent solve solution load APU and not with my model.