Cuts: Call set_cuts instead of setting cuts_aot_ directly

dev
Alinson S. Xavier 2 years ago
parent 281508f44c
commit 60c7222fbe

@ -110,5 +110,6 @@ class MemorizingCutsComponent(_BaseMemorizingConstrComponent):
if model.cuts_enforce is None: if model.cuts_enforce is None:
return return
assert self.constrs_ is not None assert self.constrs_ is not None
model.cuts_aot_ = self.predict("Predicting cutting planes...", test_h5) cuts = self.predict("Predicting cutting planes...", test_h5)
stats["Cuts: AOT"] = len(model.cuts_aot_) model.set_cuts(cuts)
stats["Cuts: AOT"] = len(cuts)

@ -82,3 +82,6 @@ class AbstractModel(ABC):
@abstractmethod @abstractmethod
def write(self, filename: str) -> None: def write(self, filename: str) -> None:
pass pass
def set_cuts(self, cuts: List) -> None:
self.cuts_aot_ = cuts

@ -50,9 +50,11 @@ def test_mem_component_gp(
(x_test,) = clf.predict.call_args.args (x_test,) = clf.predict.call_args.args
assert x_test.shape == (1, 50) assert x_test.shape == (1, 50)
# Should set cuts_aot_ # Should call set_cuts
assert model.cuts_aot_ is not None model.set_cuts.assert_called()
assert len(model.cuts_aot_) == 256 (cuts_aot_,) = model.set_cuts.call_args.args
assert cuts_aot_ is not None
assert len(cuts_aot_) == 256
def test_usage_stab( def test_usage_stab(

Loading…
Cancel
Save