Skip to content

Commit 1a4c439

Browse files
committed
Adjusted GA popsize to only be adjusted when necessary
1 parent e9797e2 commit 1a4c439

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel_tuner/strategies/genetic_algorithm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def tune(searchspace: Searchspace, runner, tuning_options):
2424
pop_size, generations, method, mutation_chance, constraint_aware = common.get_options(options, _options)
2525

2626
# if necessary adjust the popsize to a sensible value based on search space size
27-
pop_size = min(round((searchspace.size / generations) * 3), pop_size)
27+
if pop_size < 2 or pop_size > np.floor(searchspace.size / 2):
28+
pop_size = min(max(round((searchspace.size / generations) * 3), 2), pop_size)
2829

2930
GA = GeneticAlgorithm(pop_size, searchspace, method, mutation_chance, constraint_aware)
3031

0 commit comments

Comments
 (0)