mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
Organize test fixtures; handle infeasibility in DropRedundant
This commit is contained in:
@@ -32,7 +32,7 @@ class DropRedundantInequalitiesStep(Component):
|
||||
classifier=CountingClassifier(),
|
||||
threshold=0.95,
|
||||
slack_tolerance=1e-5,
|
||||
check_feasibility=False,
|
||||
check_feasibility=True,
|
||||
violation_tolerance=1e-5,
|
||||
max_iterations=3,
|
||||
):
|
||||
@@ -208,6 +208,8 @@ class DropRedundantInequalitiesStep(Component):
|
||||
return False
|
||||
if self.current_iteration >= self.max_iterations:
|
||||
return False
|
||||
if solver.internal_solver.is_infeasible():
|
||||
return False
|
||||
self.current_iteration += 1
|
||||
logger.debug("Checking that dropped constraints are satisfied...")
|
||||
constraints_to_add = []
|
||||
|
||||
@@ -342,7 +342,7 @@ class GurobiSolver(InternalSolver):
|
||||
self.model.remove(constr)
|
||||
return cobj
|
||||
|
||||
def is_constraint_satisfied(self, cobj, tol=1e-5):
|
||||
def is_constraint_satisfied(self, cobj, tol=1e-6):
|
||||
lhs, sense, rhs, name = cobj
|
||||
if self.cb_where is not None:
|
||||
lhs_value = lhs.getConstant()
|
||||
@@ -378,6 +378,7 @@ class GurobiSolver(InternalSolver):
|
||||
|
||||
def relax(self) -> None:
|
||||
assert self.model is not None
|
||||
self.model.update()
|
||||
self.model = self.model.relax()
|
||||
self._update_vars()
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ class InternalSolver(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def is_constraint_satisfied(self, cobj: Constraint) -> bool:
|
||||
def is_constraint_satisfied(self, cobj: Constraint, tol: float = 1e-6) -> bool:
|
||||
"""
|
||||
Returns True if the current solution satisfies the given constraint.
|
||||
"""
|
||||
|
||||
@@ -308,7 +308,7 @@ class BasePyomoSolver(InternalSolver):
|
||||
def extract_constraint(self, cid: str) -> Constraint:
|
||||
raise Exception("Not implemented")
|
||||
|
||||
def is_constraint_satisfied(self, cobj: Constraint) -> bool:
|
||||
def is_constraint_satisfied(self, cobj: Constraint, tol: float = 1e-6) -> bool:
|
||||
raise Exception("Not implemented")
|
||||
|
||||
def is_infeasible(self) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user