Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/test_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Modify the problem generators for fast tests
fast_problem_generators = [construct_murder_problem()] # Keep only the smallest problem

problem_generators = [construct_murder_problem(), construct_examtt_simple(), construct_nurse_rostering()]
problem_generators = [construct_murder_problem(), construct_examtt_simple(3,3,3,6), construct_nurse_rostering(3,3,6,1)]

classifiers = [DecisionTreeClassifier(), RandomForestClassifier()]
algorithms = [ca.QuAcq(), ca.MQuAcq(), ca.MQuAcq2(), ca.MineAcq(), ca.PQuAcq(), ca.GenAcq()]
Expand All @@ -33,7 +33,6 @@ def _generate_base_inputs(fast=False):
for comb in combs:
yield comb


def _generate_proba_inputs(fast=False):
if fast:
combs = product(_generate_fast_benchmarks(), fast_tests_algorithms, [DecisionTreeClassifier()]) # Use minimal combinations
Expand Down Expand Up @@ -116,13 +115,15 @@ def test_base_algorithms_with_initial_cl(self, bench, algorithm):
(instance, oracle) = bench
# Create a copy of the instance to avoid modifying the original
instance = instance.copy()
env = ca.ActiveCAEnv()

# Get some constraints from the oracle's constraint set
initial_constraints = oracle.constraints[:len(oracle.constraints)//2] # Take half of the constraints
instance.cl.extend(initial_constraints)
initial_cl_size = len(instance.cl)

ca_system = algorithm
ca_system.env = env
learned_instance = ca_system.learn(instance=instance, oracle=oracle)
assert ca_system.env.metrics.converged
assert learned_instance.get_cpmpy_model().solve()
Expand Down Expand Up @@ -162,7 +163,8 @@ def test_base_algorithms_with_bias(self, bench, algorithm):
(instance, oracle) = bench
# Create a copy of the instance to avoid modifying the original
instance = instance.copy()

env = ca.ActiveCAEnv()

# Generate bias constraints for the instance
instance.construct_bias()
# Separate constraints into those from oracle and others
Expand All @@ -172,6 +174,7 @@ def test_base_algorithms_with_bias(self, bench, algorithm):
instance.bias = list(oracle_constraints) + other_constraints[:len(other_constraints)//2]

ca_system = algorithm
ca_system.env = env
learned_instance = ca_system.learn(instance=instance, oracle=oracle)
assert len(learned_instance.cl) > 0
assert learned_instance.get_cpmpy_model().solve()
Expand Down
File renamed without changes.