Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/adjust-mps-structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael-D-F-Gomes authored Nov 1, 2023
2 parents 9e6f996 + 00e9324 commit 8d741d4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
13 changes: 13 additions & 0 deletions pyomo/core/base/units_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,19 @@ def __getattribute__(self, attr):
# present, at which point this instance __class__ will fall back
# to PyomoUnitsContainer (where this method is not declared, OR
# pint is not available and an ImportError will be raised.
#
# We need special case handling for __class__: gurobipy
# interrogates things by looking at their __class__ during
# python shutdown. Unfortunately, interrogating this
# singleton's __class__ evaluates `pint_available`, which - if
# DASK is installed - imports dask. Importing dask creates
# threading objects. Unfortunately, creating threading objects
# during interpreter shutdown generates a RuntimeError. So, our
# solution is to special-case the resolution of __class__ here
# to avoid accidentally triggering the imports.
if attr == "__class__":
return _DeferredUnitsSingleton
#
if pint_available:
# If the first thing that is being called is
# "units.set_pint_registry(...)", then we will call __init__
Expand Down
44 changes: 26 additions & 18 deletions pyomo/solvers/plugins/solvers/SCIPAMPL.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,115 +288,123 @@ def _postsolve(self):

# UNKNOWN # unknown='unknown' # An uninitialized value

if results.solver.message == "unknown":
if "unknown" in results.solver.message:
results.solver.status = SolverStatus.unknown
results.solver.termination_condition = TerminationCondition.unknown
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.unknown

# ABORTED # userInterrupt='userInterrupt' # Interrupt signal generated by user

elif results.solver.message == "user interrupt":
elif "user interrupt" in results.solver.message:
results.solver.status = SolverStatus.aborted
results.solver.termination_condition = TerminationCondition.userInterrupt
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.unknown

# OK # maxEvaluations='maxEvaluations' # Exceeded maximum number of problem evaluations

elif results.solver.message == "node limit reached":
elif "node limit reached" in results.solver.message:
results.solver.status = SolverStatus.ok
results.solver.termination_condition = TerminationCondition.maxEvaluations
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.stoppedByLimit

# OK # maxEvaluations='maxEvaluations' # Exceeded maximum number of problem evaluations

elif results.solver.message == "total node limit reached":
elif "total node limit reached" in results.solver.message:
results.solver.status = SolverStatus.ok
results.solver.termination_condition = TerminationCondition.maxEvaluations
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.stoppedByLimit

# OK # maxEvaluations='maxEvaluations' # Exceeded maximum number of problem evaluations

elif results.solver.message == "stall node limit reached":
elif "stall node limit reached" in results.solver.message:
results.solver.status = SolverStatus.ok
results.solver.termination_condition = TerminationCondition.maxEvaluations
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.stoppedByLimit

# OK # maxTimeLimit='maxTimeLimit' # Exceeded maximum time limited allowed by user but having return a feasible solution

elif results.solver.message == "time limit reached":
elif "time limit reached" in results.solver.message:
results.solver.status = SolverStatus.ok
results.solver.termination_condition = TerminationCondition.maxTimeLimit
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.stoppedByLimit

# OK # other='other' # Other, uncategorized normal termination

elif results.solver.message == "memory limit reached":
elif "memory limit reached" in results.solver.message:
results.solver.status = SolverStatus.ok
results.solver.termination_condition = TerminationCondition.other
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.stoppedByLimit

# OK # other='other' # Other, uncategorized normal termination

elif results.solver.message == "gap limit reached":
elif "gap limit reached" in results.solver.message:
results.solver.status = SolverStatus.ok
results.solver.termination_condition = TerminationCondition.other
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.stoppedByLimit

# OK # other='other' # Other, uncategorized normal termination

elif results.solver.message == "solution limit reached":
elif "solution limit reached" in results.solver.message:
results.solver.status = SolverStatus.ok
results.solver.termination_condition = TerminationCondition.other
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.stoppedByLimit

# OK # other='other' # Other, uncategorized normal termination

elif results.solver.message == "solution improvement limit reached":
elif "solution improvement limit reached" in results.solver.message:
results.solver.status = SolverStatus.ok
results.solver.termination_condition = TerminationCondition.other
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.stoppedByLimit

# OK # optimal='optimal' # Found an optimal solution

elif results.solver.message == "optimal solution found":
elif "optimal solution" in results.solver.message:
results.solver.status = SolverStatus.ok
results.solver.termination_condition = TerminationCondition.optimal
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.optimal
if results.problem.sense == ProblemSense.minimize:
results.problem.lower_bound = results.solver.primal_bound
else:
results.problem.upper_bound = results.solver.primal_bound
try:
if results.problem.sense == ProblemSense.minimize:
results.problem.lower_bound = results.solver.primal_bound
else:
results.problem.upper_bound = results.solver.primal_bound
except AttributeError:
"""
This may occur if SCIP solves the problem during presolve. In that case,
the log file may not get parsed correctly (self.read_scip_log), and
results.solver.primal_bound will not be populated.
"""
pass

# WARNING # infeasible='infeasible' # Demonstrated that the problem is infeasible

elif results.solver.message == "infeasible":
elif "infeasible" in results.solver.message:
results.solver.status = SolverStatus.warning
results.solver.termination_condition = TerminationCondition.infeasible
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.infeasible

# WARNING # unbounded='unbounded' # Demonstrated that problem is unbounded

elif results.solver.message == "unbounded":
elif "unbounded" in results.solver.message:
results.solver.status = SolverStatus.warning
results.solver.termination_condition = TerminationCondition.unbounded
if len(results.solution) > 0:
results.solution(0).status = SolutionStatus.unbounded

# WARNING # infeasibleOrUnbounded='infeasibleOrUnbounded' # Problem is either infeasible or unbounded

elif results.solver.message == "infeasible or unbounded":
elif "infeasible or unbounded" in results.solver.message:
results.solver.status = SolverStatus.warning
results.solver.termination_condition = (
TerminationCondition.infeasibleOrUnbounded
Expand Down

0 comments on commit 8d741d4

Please sign in to comment.