Skip to content

Commit

Permalink
feat(handle-termination-condition): Checks for non optimal barrier
Browse files Browse the repository at this point in the history
- Added for Barrier solve with no cross solve which may terminate in a result that is not optimal but still a valid result
  • Loading branch information
WilliamJBland authored and williamjblandflex committed Feb 5, 2025
1 parent 91f2063 commit 822d569
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyomo/contrib/appsi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class TerminationCondition(enum.Enum):
licensingProblems = 13
"""The solver exited due to licensing problems"""

barrierNonOptimal = 14
"""Barrier Non-optimal"""


class SolverConfig(ConfigDict):
"""
Expand Down
2 changes: 2 additions & 0 deletions pyomo/contrib/appsi/solvers/cplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ def _postsolve(self, timer: HierarchicalTimer, solve_time):
results.termination_condition = TerminationCondition.maxIterations
elif status in [11, 25, 107, 131]:
results.termination_condition = TerminationCondition.maxTimeLimit
elif status in {6}:
results.termination_condition = TerminationCondition.barrierNonOptimal
else:
results.termination_condition = TerminationCondition.unknown

Expand Down
2 changes: 2 additions & 0 deletions pyomo/opt/results/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class TerminationCondition(str, enum.Enum):
# optimizer
licensingProblems='licensingProblems' # Problem accessing solver license

barrierNonOptimal='barrierNonOptimal' # Barrier - Non-optimal

# Overloading __str__ is needed to match the behavior of the old
# pyutilib.enum class (removed June 2020). There are spots in the
# code base that expect the string representation for items in the
Expand Down
4 changes: 4 additions & 0 deletions pyomo/solvers/plugins/solvers/CPLEX.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ def process_logfile(self):
TerminationCondition.maxTimeLimit,
TerminationCondition.noSolution,
TerminationCondition.unbounded,
TerminationCondition.barrierNonOptimal
}
):
# If we have already determined the termination condition, reduce it to a warning.
Expand Down Expand Up @@ -606,6 +607,9 @@ def process_logfile(self):
elif len(tokens) >= 4 and tokens[0] == "Barrier" and tokens[2] == "Optimal:":
results.solver.termination_condition = TerminationCondition.optimal
results.solver.termination_message = ' '.join(tokens)
elif len(tokens) >= 4 and tokens[0] == "Barrier" and tokens[2] == "Non-optimal:":
results.solver.termination_condition = TerminationCondition.barrierNonOptimal
results.solver.termination_message = ' '.join(tokens)
elif len(tokens) >= 4 and tokens[0] == "Dual" and tokens[3] == "Infeasible:":
results.solver.termination_condition = TerminationCondition.infeasible
results.solver.termination_message = ' '.join(tokens)
Expand Down

0 comments on commit 822d569

Please sign in to comment.