Skip to content

Commit bb152f2

Browse files
committed
Implemented number of dimensions-dependent population size in diff_evo
1 parent f31f67c commit bb152f2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

kernel_tuner/strategies/diff_evo.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
_options = dict(
1313
popsize=("population size", 50),
14-
maxiter=("maximum number of generations", 1e12), # very large to avoid early stopping (stopping is managed by StopCriterionReached)
14+
popsize_times_dimensions=("multiply population size with number of dimensions (True/False)", False),
15+
maxiter=("maximum number of generations", int(1e15)), # very large to avoid early stopping (stopping is managed by StopCriterionReached)
1516
F=("mutation factor (differential weight)", 1.3),
1617
CR=("crossover rate", 0.9),
1718
method=("method", "best1bin"),
@@ -39,7 +40,10 @@ def tune(searchspace: Searchspace, runner, tuning_options):
3940
bounds = cost_func.get_bounds()
4041

4142
options = tuning_options.strategy_options
42-
popsize, maxiter, F, CR, method, constraint_aware = common.get_options(options, _options)
43+
popsize, popsize_times_dimensions, maxiter, F, CR, method, constraint_aware = common.get_options(options, _options)
44+
if popsize_times_dimensions:
45+
popsize *= min(len(searchspace.get_true_tunable_params()), searchspace.size)
46+
maxiter = min(maxiter, searchspace.size)
4347

4448
if method not in supported_methods:
4549
raise ValueError(f"Error {method} not supported, {supported_methods=}")

0 commit comments

Comments
 (0)