CMA-anchored LES¶
CMAAnchoredLES ¶
CMAAnchoredLES(population_size: int, solution: Solution, params: PyTree | None = None, params_path: str | None = None, fitness_shaping_fn: Callable = identity_fitness_shaping_fn, metrics_fn: Callable = metrics_fn)
Bases: DistributionBasedAlgorithm
Separable CMA-ES with bounded residuals and bundled meta-trained weights.
A separable CMA-ES core with dimensionless learned gates, adaptive antithetic
sampling, pair-consistent evolution paths, and capped stall re-expansion.
Three small frozen networks modulate the core: a recombination residual
rescales the rank-based weights, global gates scale the step-size and mean
updates, and a per-dimension gate scales the diagonal covariance update.
Every gate is a multiplicative factor in [1/2, 2].
The weights come from params, from a trusted pickle file at params_path,
or, if both are None, from the checkpoint bundled with evosax. params
takes precedence over params_path. The weights are validated against the
fixed network shapes and a ValueError is raised if they do not match.
Checkpoint provenance is packaged beside the bundled weights.
Parameters:
-
population_size(int) –Number of candidate solutions sampled and evaluated per generation.
-
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. Must have at least one dimension. -
params(PyTree | None, default:None) –Learned network weights, a PyTree with the entries
recombination,global_gatesanddimension_gate. IfNone, the weights are loaded fromparams_pathor from the bundled checkpoint. -
params_path(str | None, default:None) –Path to a pickle file with the learned network weights. Only used if
paramsisNone. -
fitness_shaping_fn(Callable, default:identity_fitness_shaping_fn) –Function
(population, fitness, state, params) -> shaped_fitnessapplied 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 intell; its output is returned alongside the new state.
Warning
Pickle loading can execute arbitrary code. Only pass trusted files to
params_path.
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 an initial mean.
Parameters:
-
key(Array) –PRNG key.
-
mean(Solution) –Initial mean of the search distribution, a PyTree with the structure of
solution. -
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(Any) –Current algorithm state.
-
params(Any) –Algorithm hyperparameters.
Returns:
-
tuple[Population, Any]–A tuple
(population, state).populationis a PyTree with the structure ofsolutionand a leading axis of sizepopulation_size.
tell ¶
tell(key: Array, population: Population, fitness: Fitness, state: Any, params: Any) -> tuple[Any, 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
(population_size,). Lower is better. NaN values mark failed evaluations and never become the best solution. -
state(Any) –Algorithm state returned by
ask. -
params(Any) –Algorithm hyperparameters.
Returns:
-
tuple[Any, Metrics]–A tuple
(state, metrics)with the updated state and the output ofmetrics_fn.
get_mean ¶
Return the mean of the search distribution as a solution PyTree.