diff --git a/miplearn/components/dynamic_lazy.py b/miplearn/components/dynamic_lazy.py index a9145ec..9110524 100644 --- a/miplearn/components/dynamic_lazy.py +++ b/miplearn/components/dynamic_lazy.py @@ -36,7 +36,7 @@ class DynamicLazyConstraintsComponent(Component): self.dynamic: DynamicConstraintsComponent = DynamicConstraintsComponent( classifier=classifier, threshold=threshold, - attr="lazy_enforced", + attr="mip_constr_lazy_enforced", ) self.classifiers = self.dynamic.classifiers self.thresholds = self.dynamic.thresholds @@ -78,7 +78,7 @@ class DynamicLazyConstraintsComponent(Component): stats: LearningSolveStats, sample: Sample, ) -> None: - sample.put_set("lazy_enforced", set(self.lazy_enforced)) + sample.put_set("mip_constr_lazy_enforced", set(self.lazy_enforced)) @overrides def iteration_cb( diff --git a/miplearn/components/dynamic_user_cuts.py b/miplearn/components/dynamic_user_cuts.py index b60cc44..5f69b04 100644 --- a/miplearn/components/dynamic_user_cuts.py +++ b/miplearn/components/dynamic_user_cuts.py @@ -32,7 +32,7 @@ class UserCutsComponent(Component): self.dynamic = DynamicConstraintsComponent( classifier=classifier, threshold=threshold, - attr="user_cuts_enforced", + attr="mip_user_cuts_enforced", ) self.enforced: Set[str] = set() self.n_added_in_callback = 0 @@ -87,7 +87,7 @@ class UserCutsComponent(Component): stats: LearningSolveStats, sample: Sample, ) -> None: - sample.put_set("user_cuts_enforced", set(self.enforced)) + sample.put_set("mip_user_cuts_enforced", set(self.enforced)) stats["UserCuts: Added in callback"] = self.n_added_in_callback if self.n_added_in_callback > 0: logger.info(f"{self.n_added_in_callback} user cuts added in callback") diff --git a/miplearn/components/static_lazy.py b/miplearn/components/static_lazy.py index 99aba1c..53a7a7d 100644 --- a/miplearn/components/static_lazy.py +++ b/miplearn/components/static_lazy.py @@ -61,7 +61,7 @@ class StaticLazyConstraintsComponent(Component): stats: LearningSolveStats, sample: Sample, ) -> None: - sample.put_set("lazy_enforced", self.enforced_cids) + sample.put_set("mip_constr_lazy_enforced", self.enforced_cids) stats["LazyStatic: Restored"] = self.n_restored stats["LazyStatic: Iterations"] = self.n_iterations @@ -209,7 +209,7 @@ class StaticLazyConstraintsComponent(Component): constr_names = sample.get_vector("static_constr_names") constr_categories = sample.get_vector("static_constr_categories") constr_lazy = sample.get_vector("static_constr_lazy") - lazy_enforced = sample.get_set("lazy_enforced") + lazy_enforced = sample.get_set("mip_constr_lazy_enforced") if constr_features is None: constr_features = sample.get_vector_list("static_constr_features") diff --git a/tests/components/test_dynamic_lazy.py b/tests/components/test_dynamic_lazy.py index 037b904..cec993e 100644 --- a/tests/components/test_dynamic_lazy.py +++ b/tests/components/test_dynamic_lazy.py @@ -24,13 +24,13 @@ def training_instances() -> List[Instance]: samples_0 = [ MemorySample( { - "lazy_enforced": {"c1", "c2"}, + "mip_constr_lazy_enforced": {"c1", "c2"}, "static_instance_features": [5.0], }, ), MemorySample( { - "lazy_enforced": {"c2", "c3"}, + "mip_constr_lazy_enforced": {"c2", "c3"}, "static_instance_features": [5.0], }, ), @@ -55,7 +55,7 @@ def training_instances() -> List[Instance]: samples_1 = [ MemorySample( { - "lazy_enforced": {"c3", "c4"}, + "mip_constr_lazy_enforced": {"c3", "c4"}, "static_instance_features": [8.0], }, ) diff --git a/tests/components/test_dynamic_user_cuts.py b/tests/components/test_dynamic_user_cuts.py index cfb76c0..44205a6 100644 --- a/tests/components/test_dynamic_user_cuts.py +++ b/tests/components/test_dynamic_user_cuts.py @@ -81,7 +81,7 @@ def test_usage( ) -> None: stats_before = solver.solve(stab_instance) sample = stab_instance.get_samples()[0] - user_cuts_enforced = sample.get_set("user_cuts_enforced") + user_cuts_enforced = sample.get_set("mip_user_cuts_enforced") assert user_cuts_enforced is not None assert len(user_cuts_enforced) > 0 assert stats_before["UserCuts: Added ahead-of-time"] == 0 diff --git a/tests/components/test_static_lazy.py b/tests/components/test_static_lazy.py index 6ef4ec9..385c7cc 100644 --- a/tests/components/test_static_lazy.py +++ b/tests/components/test_static_lazy.py @@ -34,7 +34,7 @@ def sample() -> Sample: "static_constr_lazy": [True, True, True, True, False], "static_constr_names": ["c1", "c2", "c3", "c4", "c5"], "static_instance_features": [5.0], - "lazy_enforced": {"c1", "c2", "c4"}, + "mip_constr_lazy_enforced": {"c1", "c2", "c4"}, "lp_constr_features": [ [1.0, 1.0], [1.0, 2.0], @@ -93,7 +93,7 @@ def test_usage_with_solver(instance: Instance) -> None: stats: LearningSolveStats = {} sample = instance.get_samples()[0] - assert sample.get_set("lazy_enforced") is not None + assert sample.get_set("mip_constr_lazy_enforced") is not None # LearningSolver calls before_solve_mip component.before_solve_mip( @@ -142,7 +142,7 @@ def test_usage_with_solver(instance: Instance) -> None: ) # Should update training sample - assert sample.get_set("lazy_enforced") == {"c1", "c2", "c3", "c4"} + assert sample.get_set("mip_constr_lazy_enforced") == {"c1", "c2", "c3", "c4"} # # Should update stats assert stats["LazyStatic: Removed"] == 1 diff --git a/tests/problems/test_tsp.py b/tests/problems/test_tsp.py index 894fb57..48c9931 100644 --- a/tests/problems/test_tsp.py +++ b/tests/problems/test_tsp.py @@ -65,7 +65,7 @@ def test_subtour() -> None: samples = instance.get_samples() assert len(samples) == 1 sample = samples[0] - lazy_enforced = sample.get_set("lazy_enforced") + lazy_enforced = sample.get_set("mip_constr_lazy_enforced") assert lazy_enforced is not None assert len(lazy_enforced) > 0 assert sample.get_vector("mip_var_values") == [