SV-CMA-ES¶
SV_CMA_ES ¶
SV_CMA_ES(population_size: int, num_populations: int, solution: Solution, kernel: Callable = kernel_rbf, fitness_shaping_fn: Callable = weights_fitness_shaping_fn, metrics_fn: Callable = metrics_fn)
Stein Variational CMA-ES (SV-CMA-ES).
Runs num_populations CMA-ES search distributions in parallel. The mean
update of each distribution adds the gradient of the kernel between the
means, scaled by params.alpha, to the CMA-ES step.
Parameters:
-
population_size(int) –Number of candidate solutions sampled per search distribution in each generation.
-
num_populations(int) –Number of search distributions run in parallel.
-
solution(Solution) –Example solution PyTree. Only its structure and leaf shapes are used: they set the number of search dimensions and how flat search vectors are unravelled into the PyTrees returned by
ask. -
kernel(Callable, default:kernel_rbf) –Function
(x, y, params) -> similaritybetween the means of two search distributions. Seeevosax.core.kernel. -
fitness_shaping_fn(Callable, default:weights_fitness_shaping_fn) –Function
(population, fitness, state, params) -> shaped_fitnessapplied per search distribution to the raw fitness intellbefore the algorithm update. Seeevosax.core.fitness_shaping. -
metrics_fn(Callable, default:metrics_fn) –Function
(key, population, fitness, state, params) -> metricsevaluated per search distribution intell; its output is returned alongside the new state.
References
default_params
property
¶
Default hyperparameters of the algorithm.
Returns a Params dataclass. Use params.replace(...) to override
individual hyperparameters before passing it to init, ask and tell.
init ¶
Initialize the algorithm state from one initial mean per distribution.
Parameters:
-
key(Array) –PRNG key.
-
means(Solution) –Initial means, a PyTree with the structure of
solutionand a leading axis of sizenum_populationson every leaf. -
params(Params) –Algorithm hyperparameters, e.g.
default_params.
Returns:
-
State–The initial algorithm state.
ask ¶
Ask for a population of candidate solutions to evaluate.
Parameters:
-
key(Array) –PRNG key.
-
state(State) –Current algorithm state.
-
params(Params) –Algorithm hyperparameters.
Returns:
-
tuple[Population, State]–A tuple
(population, state).populationis a PyTree with the structure ofsolutionand a leading axis of sizenum_populations * population_size.
tell ¶
tell(key: Array, population: Population, fitness: Fitness, state: State, params: Params) -> tuple[State, Metrics]
Update the algorithm state with the fitness of a population.
Parameters:
-
key(Array) –PRNG key.
-
population(Population) –Population returned by
ask. -
fitness(Fitness) –Fitness of each population member, shape
(num_populations * population_size,). Lower is better. -
state(State) –Algorithm state returned by
ask. -
params(Params) –Algorithm hyperparameters.
Returns:
-
tuple[State, Metrics]–A tuple
(state, metrics)with the updated state and the output ofmetrics_fnfor each search distribution.
get_mean ¶
Return the means of all search distributions as a PyTree.
Every leaf has a leading axis of size num_populations.