Skip to content

Commit

Permalink
Update error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmundt committed Feb 19, 2024
1 parent bc1b3e9 commit ac7ce8b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pyomo/contrib/solver/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pyomo.core.base.var import _GeneralVarData
from pyomo.core.expr import value
from pyomo.common.collections import ComponentMap
from pyomo.common.errors import DeveloperError
from pyomo.core.staleflag import StaleFlagManager
from pyomo.contrib.solver.sol_reader import SolFileData
from pyomo.repn.plugins.nl_writer import NLWriterInfo
Expand Down Expand Up @@ -146,7 +147,7 @@ def load_vars(
if self._nl_info is None:
raise RuntimeError(
'Solution loader does not currently have a valid solution. Please '
'check the termination condition.'
'check results.TerminationCondition and/or results.SolutionStatus.'
)
if self._sol_data is None:
assert len(self._nl_info.variables) == 0
Expand All @@ -173,7 +174,7 @@ def get_primals(
if self._nl_info is None:
raise RuntimeError(
'Solution loader does not currently have a valid solution. Please '
'check the termination condition.'
'check results.TerminationCondition and/or results.SolutionStatus.'
)
val_map = dict()
if self._sol_data is None:
Expand Down Expand Up @@ -209,13 +210,18 @@ def get_duals(
if self._nl_info is None:
raise RuntimeError(
'Solution loader does not currently have a valid solution. Please '
'check the termination condition.'
'check results.TerminationCondition and/or results.SolutionStatus.'
)
if len(self._nl_info.eliminated_vars) > 0:
raise NotImplementedError(
'For now, turn presolve off (opt.config.writer_config.linear_presolve=False) to get dual variable values.'
'For now, turn presolve off (opt.config.writer_config.linear_presolve=False) '
'to get dual variable values.'
)
if self._sol_data is None:
raise DeveloperError(
"Solution data is empty. This should not "
"have happened. Report this error to the Pyomo Developers."
)
assert self._sol_data is not None, "report this to the Pyomo developers"
res = dict()
if self._nl_info.scaling is None:
scale_list = [1] * len(self._nl_info.constraints)
Expand Down

0 comments on commit ac7ce8b

Please sign in to comment.