From 72fc65cae03ac6e2f4c241a88345fc44ae413a3c Mon Sep 17 00:00:00 2001 From: Alinson S Xavier Date: Thu, 5 Mar 2020 12:55:00 -0600 Subject: [PATCH] LazyConstraintsComponent: make threshold configurable --- miplearn/components/lazy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/miplearn/components/lazy.py b/miplearn/components/lazy.py index 036b396..343d6b9 100644 --- a/miplearn/components/lazy.py +++ b/miplearn/components/lazy.py @@ -25,15 +25,17 @@ class LazyConstraintsComponent(Component): A component that predicts which lazy constraints to enforce. """ - def __init__(self): + def __init__(self, + threshold=0.05): self.violations = set() self.count = {} self.n_samples = 0 + self.threshold = threshold def before_solve(self, solver, instance, model): logger.info("Enforcing %d lazy constraints" % len(self.violations)) for v in self.violations: - if self.count[v] < self.n_samples * 0.05: + if self.count[v] < self.n_samples * self.threshold: continue cut = instance.build_lazy_constraint(model, v) solver.internal_solver.add_constraint(cut)