From 3c3dc351e80cc1f0e34d302294f62b8c37d957d7 Mon Sep 17 00:00:00 2001 From: Dimos Tsouros Date: Fri, 20 Mar 2026 14:44:05 +0200 Subject: [PATCH 1/6] fix initial bias in growacq handling --- pycona/active_algorithms/growacq.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pycona/active_algorithms/growacq.py b/pycona/active_algorithms/growacq.py index a1bdbfe..7be03ec 100644 --- a/pycona/active_algorithms/growacq.py +++ b/pycona/active_algorithms/growacq.py @@ -51,14 +51,23 @@ def learn(self, instance: ProblemInstance, oracle: Oracle = UserOracle(), verbos self.inner_algorithm.env = copy.copy(self.env) Y = [] + init_bias = list(self.env.instance.bias) + init_bias_provided = len(init_bias) > 0 n_vars = len(X) for x in X: - # we 'grow' the inner bias by adding one extra variable at a time + # we 'grow' the considered part of the problem by adding one extra variable at a time Y.append(x) - # add the constraints involving x and other added variables - if len(self.env.instance.bias) == 0: + # Add candidate constraints for the new frontier. + # - If an initial bias is provided, only reveal newly visible constraints + # - Otherwise, generate constraints incrementally from the language + if init_bias_provided: + visible_now = set(get_con_subset(init_bias, Y)) + self.env.instance.bias = list(visible_now) + init_bias = set(init_bias) - visible_now + else: self.env.instance.construct_bias_for_vars(x, Y) + if verbose >= 3: print(f"Added variable {x} in GrowAcq") print("size of B in growacq: ", len(self.env.instance.bias)) From 882a7311549fa44d443703405ad2f2f03746063b Mon Sep 17 00:00:00 2001 From: Dimos Tsouros Date: Fri, 20 Mar 2026 14:47:43 +0200 Subject: [PATCH 2/6] time limit in findscope --- pycona/find_scope/findscope2.py | 2 +- pycona/find_scope/findscope_obj.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pycona/find_scope/findscope2.py b/pycona/find_scope/findscope2.py index 0fb3739..de180d4 100644 --- a/pycona/find_scope/findscope2.py +++ b/pycona/find_scope/findscope2.py @@ -78,7 +78,7 @@ def _find_scope(self, R, Y): # Create Y1, Y2 ------------------------- proba = self.ca.bias_proba if hasattr(self.ca, 'bias_proba') else [] - Y1, Y2 = self.split_func(Y=Y, R=R, kappaB=kappaBRY, P_c=proba) + Y1, Y2 = self.split_func(Y=Y, R=R, kappaB=kappaBRY, P_c=proba, time_limit=self.time_limit) S1 = set() S2 = set() diff --git a/pycona/find_scope/findscope_obj.py b/pycona/find_scope/findscope_obj.py index d1d664d..6f1cb91 100644 --- a/pycona/find_scope/findscope_obj.py +++ b/pycona/find_scope/findscope_obj.py @@ -31,6 +31,8 @@ def split_proba(Y, R, kappaB, P_c, **kwargs): if len(kappaB) > 10000: return split_half(Y) + time_limit = kwargs.get('time_limit', 1) + hashY = [hash(y) for y in Y] hashR = [hash(r) for r in R] @@ -50,7 +52,7 @@ def split_proba(Y, R, kappaB, P_c, **kwargs): model.maximize(constraints_Y1) - model.solve(time_limit=1) + model.solve(time_limit=time_limit) Y1 = [Y[i] for i in range(len(Y)) if x[i].value()] Y2 = list(set(Y) - set(Y1)) From d3d0a25b06e9dac5c7ecef488c19af4e6a2a6c3f Mon Sep 17 00:00:00 2001 From: Dimos Tsouros Date: Fri, 20 Mar 2026 14:51:46 +0200 Subject: [PATCH 3/6] genacq fix for variable groups --- pycona/active_algorithms/genacq.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pycona/active_algorithms/genacq.py b/pycona/active_algorithms/genacq.py index 34cb48c..2dbd041 100644 --- a/pycona/active_algorithms/genacq.py +++ b/pycona/active_algorithms/genacq.py @@ -68,6 +68,7 @@ def learn(self, instance: ProblemInstance, oracle: Oracle = UserOracle(), verbos if self.env.verbose >= 1: print(f"\nLearned {self.env.metrics.cl} constraints in " f"{self.env.metrics.total_queries} queries.") + self.env.instance.bias = [] return self.env.instance self.env.metrics.increase_generation_time(gen_end - gen_start) @@ -108,7 +109,7 @@ def generalize(self, r, c): for var in scope_vars: var_types = [] for type_group in self._types: - if var.name in type_group: + if var in type_group: var_types.append(type_group) type_sequences.append(var_types) @@ -139,6 +140,7 @@ def generalize(self, r, c): all_type_sequences.sort(key=lambda seq: len(set().union(*seq))) while len(all_type_sequences) > 0 and gq_counter < self._qg_max: + Y = all_type_sequences.pop(0) # Instead of getting constraints from bias, generate them for this type sequence From 42e392e83053f0b9114ef03563816d4b69e177b0 Mon Sep 17 00:00:00 2001 From: Dimos Tsouros Date: Fri, 20 Mar 2026 14:54:29 +0200 Subject: [PATCH 4/6] pqgen reset partial use in init_state --- pycona/ca_environment/active_ca.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pycona/ca_environment/active_ca.py b/pycona/ca_environment/active_ca.py index fbabcf3..4f8694c 100644 --- a/pycona/ca_environment/active_ca.py +++ b/pycona/ca_environment/active_ca.py @@ -50,6 +50,10 @@ def init_state(self, instance, oracle, verbose, metrics=None): self.find_scope.ca = self self.findc.ca = self + # Reset optional query-generator internal state between independent runs + if hasattr(self.qgen, "reset_partial") and callable(self.qgen.reset_partial): + self.qgen.reset_partial() + def run_query_generation(self, Y=None): """ Run the query generation process. """ Y = self.qgen.generate(Y) From c4b058e89baf9af36b7cda8fc154dcda44c28633 Mon Sep 17 00:00:00 2001 From: Dimos Tsouros Date: Fri, 20 Mar 2026 14:57:30 +0200 Subject: [PATCH 5/6] Update findscope.py --- pycona/find_scope/findscope.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycona/find_scope/findscope.py b/pycona/find_scope/findscope.py index d9bc85e..83f1b06 100644 --- a/pycona/find_scope/findscope.py +++ b/pycona/find_scope/findscope.py @@ -26,7 +26,7 @@ def run(self, Y): :return: The scope of the partial example. """ assert self.ca is not None - scope = self._find_scope(set(), Y, do_ask=False) + scope = self._find_scope(set(), list(Y), do_ask=False) return scope def _find_scope(self, R, Y, do_ask): From 688f38cdab22f08464aa872fcbf29b4d01927ab6 Mon Sep 17 00:00:00 2001 From: Dimos Tsouros Date: Mon, 23 Mar 2026 13:28:45 +0200 Subject: [PATCH 6/6] Update feature_representation.py --- pycona/predictor/feature_representation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycona/predictor/feature_representation.py b/pycona/predictor/feature_representation.py index fb60ac9..ecae6c8 100644 --- a/pycona/predictor/feature_representation.py +++ b/pycona/predictor/feature_representation.py @@ -157,7 +157,7 @@ def featurize_constraint(self, c): features.append(dimj_diff) else: features.append(True) - for _ in range(4): + for _ in range(3): features.append(0) features.append(0.0)