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:
return
assert self.constrs_ is not None
model.cuts_aot_ = self.predict("Predicting cutting planes...", test_h5)
stats["Cuts: AOT"] = len(model.cuts_aot_)
cuts = self.predict("Predicting cutting planes...", test_h5)
model.set_cuts(cuts)
stats["Cuts: AOT"] = len(cuts)

@ -82,3 +82,6 @@ class AbstractModel(ABC):
@abstractmethod
def write(self, filename: str) -> None:
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
assert x_test.shape == (1, 50)
# Should set cuts_aot_
assert model.cuts_aot_ is not None
assert len(model.cuts_aot_) == 256
# Should call set_cuts
model.set_cuts.assert_called()
(cuts_aot_,) = model.set_cuts.call_args.args
assert cuts_aot_ is not None
assert len(cuts_aot_) == 256
def test_usage_stab(

Loading…
Cancel
Save