Skip to content

Commit ee07a4f

Browse files
authored
Accept objectives in findscope2 (#11)
* accept objectives in findscope2 * determine the default split function based on the env
1 parent 69d679e commit ee07a4f

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

pycona/find_scope/findscope2.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
from ..ca_environment.active_ca import ActiveCAEnv
2+
from ..ca_environment.acive_ca_proba import ProbaActiveCAEnv
23
from .findscope_core import FindScopeBase
34
from ..utils import get_kappa, get_con_subset
4-
5+
from ..find_scope.findscope_obj import split_proba, split_half
56

67
class FindScope2(FindScopeBase):
78
"""
89
This is the version of the FindScope function that was presented in
910
Bessiere, Christian, et al., "Learning constraints through partial queries", AIJ 2023
1011
"""
1112

12-
def __init__(self, ca_env: ActiveCAEnv = None, time_limit=0.2):
13+
def __init__(self, ca_env: ActiveCAEnv = None, split_func=None, time_limit=0.2):
1314
"""
1415
Initialize the FindScope2 class.
1516
1617
:param ca_env: The constraint acquisition environment.
1718
:param time_limit: The time limit for findscope query generation.
19+
:param split_func: The function used to split the variables in findscope.
1820
"""
19-
super().__init__(ca_env, time_limit)
21+
22+
if split_func is None:
23+
split_func = split_proba if isinstance(ca_env, ProbaActiveCAEnv) else split_half
24+
25+
super().__init__(ca_env, time_limit, split_func=split_func)
2026
self._kappaB = []
2127

2228
def run(self, Y, kappa=None):
@@ -72,7 +78,7 @@ def _find_scope(self, R, Y):
7278

7379
# Create Y1, Y2 -------------------------
7480
proba = self.ca.bias_proba if hasattr(self.ca, 'bias_proba') else []
75-
Y1, Y2 = self.split_func(Y=Y, R=R, kappaB=kappaBRY, proba=proba)
81+
Y1, Y2 = self.split_func(Y=Y, R=R, kappaB=kappaBRY, P_c=proba)
7682

7783
S1 = set()
7884
S2 = set()

0 commit comments

Comments
 (0)