mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
Improve logging
This commit is contained in:
@@ -32,7 +32,7 @@ class UserCutsComponent(Component):
|
||||
def before_solve(self, solver, instance, model):
|
||||
logger.info("Predicting violated user cuts...")
|
||||
violations = self.predict(instance)
|
||||
logger.info("Enforcing %d cuts..." % len(violations))
|
||||
logger.info("Enforcing %d user cuts..." % len(violations))
|
||||
for v in violations:
|
||||
cut = instance.build_user_cut(model, v)
|
||||
solver.internal_solver.add_constraint(cut)
|
||||
|
||||
@@ -32,7 +32,7 @@ class LazyConstraintsComponent(Component):
|
||||
def before_solve(self, solver, instance, model):
|
||||
logger.info("Predicting violated lazy constraints...")
|
||||
violations = self.predict(instance)
|
||||
logger.info("Enforcing %d constraints..." % len(violations))
|
||||
logger.info("Enforcing %d lazy constraints..." % len(violations))
|
||||
for v in violations:
|
||||
cut = instance.build_lazy_constraint(model, v)
|
||||
solver.internal_solver.add_constraint(cut)
|
||||
|
||||
@@ -23,10 +23,11 @@ class ObjectiveValueComponent(Component):
|
||||
|
||||
def before_solve(self, solver, instance, model):
|
||||
if self.ub_regressor is not None:
|
||||
logger.info("Predicting optimal value...")
|
||||
lb, ub = self.predict([instance])[0]
|
||||
instance.predicted_ub = ub
|
||||
instance.predicted_lb = lb
|
||||
logger.info("Predicted objective: [%.2f, %.2f]" % (lb, ub))
|
||||
logger.info("Predicted values: lb=%.2f, ub=%.2f" % (lb, ub))
|
||||
|
||||
def after_solve(self, solver, instance, model, results):
|
||||
if self.ub_regressor is not None:
|
||||
|
||||
@@ -30,6 +30,7 @@ class PrimalSolutionComponent(Component):
|
||||
self.classifier_prototype = classifier
|
||||
|
||||
def before_solve(self, solver, instance, model):
|
||||
logger.info("Predicting primal solution...")
|
||||
solution = self.predict(instance)
|
||||
if self.mode == "heuristic":
|
||||
solver.internal_solver.fix(solution)
|
||||
|
||||
@@ -156,7 +156,7 @@ class LearningSolver:
|
||||
self.internal_solver.set_instance(instance, model)
|
||||
|
||||
if solve_lp_first:
|
||||
logger.debug("Solving LP relaxation...")
|
||||
logger.info("Solving LP relaxation...")
|
||||
results = self.internal_solver.solve_lp(tee=tee)
|
||||
instance.lp_solution = self.internal_solver.get_solution()
|
||||
instance.lp_value = results["Optimal value"]
|
||||
@@ -171,6 +171,7 @@ class LearningSolver:
|
||||
if relaxation_only:
|
||||
return results
|
||||
|
||||
logger.info("Solving MILP...")
|
||||
results = self.internal_solver.solve(tee=tee)
|
||||
results["LP value"] = instance.lp_value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user