I am using pyomo with gurobi (and other solvers) to solve some optimization programs. Sometimes these programs don't have a solution and throw an error such as
WARNING: Loading a SolverResults object with a warning status into
model.name="unknown";
- termination condition: infeasible
- message from solver: Model was proven to be infeasible.
ERROR: evaluating object as numeric value: x[0]
(object: <class 'pyomo.core.base.var._GeneralVarData'>)
No value for uninitialized NumericValue object x[0]
ERROR: evaluating object as numeric value: objective
(object: <class 'pyomo.core.base.objective.SimpleObjective'>)
No value for uninitialized NumericValue object x[0]
...
File "pyomo\core\expr\numvalue.pyx", line 246, in pyomo.core.expr.numvalue.value
File "pyomo\core\expr\numvalue.pyx", line 233, in pyomo.core.expr.numvalue.value
ValueError: No value for uninitialized NumericValue object x[0]
In this case, I would like to run a simpler program without some of the constraints, so something like
solve program
if program doesn't have a solution:
solve simpler program
How could I do this?