metaheuristic_designer.strategies.classic.CMA_ES module#
CMA-ES (Covariance Matrix Adaptation Evolution Strategy) implementation.
Warning
The current implementation is architecturally a temporary solution. It will be refactored once the EDA (Distribution-based) interface is finalized.
- class CMA_ES(initializer, survivor_sel=None, name='CMA-ES', offspring_size=None, rng=None, mean=None, sigma=None, cond_tol=100000000.0, sigma_tol=1e-10, **kwargs)[source]#
Bases:
EDAStrategyCovariance Matrix Adaptation Evolution Strategy (CMA-ES).
This is a population-based algorithm that samples new solutions from a multivariate normal distribution whose mean and covariance are adapted each generation based on the best individuals.
Note
The architecture of this class is provisional. It currently overrides
initialize()andperturb()directly. Once the distribution-based (EDA) abstraction is in place, CMA-ES will be rewritten to use that common interface.- Parameters:
- initializerInitializer
Provides population size and genotype shape, but does not generate the initial solutions.
- survivor_selSurvivorSelection, optional
How survivors are selected. Defaults to the strategy’s default (generational).
- namestr, optional
Display name (default
"CMA-ES").- offspring_sizeint or SchedulableParameter, optional
Number of offspring per generation. If
None, the initializer’s population size is used.- rngRNGLike, optional
Random number generator.
- meanVectorLike, optional
Initial mean vector. If not given, it is computed from the objective’s bounds (or randomly if no bounds exist).
- sigmaVectorLike, optional
Initial step size. If not given, a default is computed.
- **kwargs
Forwarded to
VariablePopulation.
- Attributes:
paramsAccess parameter values by attribute-style lookup.
population_sizeGets the amount of individuals in the population.
- Parameters:
initializer (Initializer)
survivor_sel (SurvivorSelection)
name (str)
offspring_size (Optional[int | SchedulableParameter])
mean (Optional[VectorLike])
sigma (Optional[VectorLike])
cond_tol (float)
sigma_tol (float)
Methods
estimate_parameters(population)Update the distribution parameters
extra_report()Hook called at the end of the optimization (intended for subclasses).
extra_step_info()Hook called after each generation (intended for subclasses).
gather_parameters()Collect the current parameters from all sub-components.
get_params()Return a copy of the current parameter dictionary.
get_state()Gets the current state of the search strategy as a dictionary.
initialize(objfunc)Create the initial population by sampling from the current distribution.
step(prev_population, objfunc)Performs a single iteration of the algorithm on a given population.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Advances the state of the search by one iteration.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
reset
- initialize(objfunc)[source]#
Create the initial population by sampling from the current distribution.
- Return type:
- Parameters:
- objfuncObjectiveFunc
The objective function, used to infer bounds if mean or sigma are not provided.
- Returns:
- Population
A freshly sampled population with unevaluated fitness.
- Parameters:
objfunc (ObjectiveFunc)
- estimate_parameters(population)[source]#
Update the distribution parameters
The parents (the best μ individuals from the previous generation) are used to update mean, sigma, covariance, and the evolution paths.
- Parameters:
- populationPopulation
The selected parents (must be already evaluated).
- Returns:
- Population
Offspring population of size offspring_size.