Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix scip results processing #3023

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelbynum would you mind adding a short comment here explaining why this is needed or when you would end up here? Is this from a difference in solver versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Sorry - I was in a hurry yesterday.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I only added comments to the PR. Now, I've added comments to the code.

"""
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