Skip to content

Commit

Permalink
Merge pull request Pyomo#3023 from michaelbynum/scip
Browse files Browse the repository at this point in the history
fix scip results processing
  • Loading branch information
blnicho authored Oct 31, 2023
2 parents 2458a8f + f400b5e commit 00e9324
Showing 1 changed file with 26 additions and 18 deletions.
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 00e9324

Please sign in to comment.