Skip to content

Commit f52d573

Browse files
committed
Improve GA constraint-awareness differentiation
1 parent d121da6 commit f52d573

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel_tuner/strategies/genetic_algorithm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def tune(searchspace: Searchspace, runner, tuning_options):
3636
population = GA.generate_population()
3737

3838
for generation in range(generations):
39-
if any([not searchspace.is_param_config_valid(tuple(dna)) for dna in population]):
39+
if constraint_aware and any([not searchspace.is_param_config_valid(tuple(dna)) for dna in population]):
4040
raise ValueError(f"Generation {generation}/{generations}, population validity: {[searchspace.is_param_config_valid(tuple(dna)) for dna in population]}")
4141

4242
# determine fitness of population members
@@ -77,7 +77,7 @@ def tune(searchspace: Searchspace, runner, tuning_options):
7777
for child in children:
7878
child = GA.mutate(child)
7979

80-
if child not in population and searchspace.is_param_config_valid(tuple(child)):
80+
if child not in population and (not constraint_aware or searchspace.is_param_config_valid(tuple(child))):
8181
population.append(child)
8282

8383
if len(population) >= pop_size:

0 commit comments

Comments
 (0)