class documentation

class CMAAdaptSigmaCSA(CMAAdaptSigmaBase):

Constructor: CMAAdaptSigmaCSA(**kwargs)

View In Hierarchy

CSA cumulative step-size adaptation AKA path length control.

As of 2026, CSA is considered as the default step-size control method within CMA-ES. It's most notable case of poor performance is with a large neutral subspace dimensionality (a large number of "ineffective dimensions"), say Neff < N/2.

Details: only method hsig is used from the CMAAdaptSigmaBase class.

Method __init__ postpone initialization to a method call where dimension and mueff are known
Method compute_cs return a new computation for the decay parameter cs,
Method compute_damps return re-computed damps.
Method damp_mueff_exponent return damping inner exponent to compute damps
Method initialize set parameters and state variables
Method initialize_settings set attributes cs, damps and others,
Method update call self._update_ps(es) and update es.sigma.
Method update2 call self._update_ps(es) and update self.delta.
Instance Variable cs CMAAdaptSigmaBase.hsig uses this attribute value too
Instance Variable dampdown_fac Asymmetric damping parameter read from module variable csa_dampdown_fac (this may change in future)
Instance Variable damps Undocumented
Instance Variable delta cumulated effect of adaptation
Instance Variable is_initialized Undocumented
Instance Variable max_delta_log_sigma Undocumented
Instance Variable ps Undocumented
Method _update_ps update path with isotropic delta mean, possibly clipped.
Instance Variable _es_opts Undocumented
Instance Variable _lam_mirr Undocumented
Instance Variable _last_multiplier Undocumented
Instance Variable _popsize Undocumented
Instance Variable _ps_updated_iteration Undocumented

Inherited from CMAAdaptSigmaBase:

Method check_consistency make consistency checks with a CMAEvolutionStrategy instance as input
Method hsig return "OK-signal" for rank-one update.
Method initialize_base set parameters and state variable based on dimension, mueff and possibly further options.
Instance Variable is_initialized_base Undocumented
def __init__(self, **kwargs):

postpone initialization to a method call where dimension and mueff are known

def compute_cs(self, N, mueff):

return a new computation for the decay parameter cs,

based on the input parameters dimension and mu_w and _CSA_cs_sqrt.

Details: In Akimoto & Hansen 2020, c_c (not c_sigma) depends on c1 and mueff.

sum((1-c)**i for i = 0,1,...) = 1/c Last contributes half when c = 1/2 (1 = 1/c/2) Last two contribute half when c = 0.29289322 (1 + (1 - c) = 1/c/2 => c = 1 - sqrt(2) / 2) Alternating contributions: 1 + (1-c)^2 + ... = alpha * 1 / c:

c     alpha  ratio of contributions   bias from order
1/2   2/3      2:1                      1/3
0.3   0.588    1.426:1 < 3:2            0.176
def compute_damps(self, N, mueff, popsize=None, lam_mirr=None, damp_fac=None):

return re-computed damps.

Keyword arguments popsize and lam_mirr are not optional in the first call.

Depends on the input parameters, on self.cs, on the method damp_mueff_exponent, and on the module settings _CSA_dampfac_mueff_inner, _CSA_dampfac_mueff_attenuation_dimension.

def damp_mueff_exponent(self, opts=None):

return damping inner exponent to compute damps

def initialize(self, es, reset=False):

set parameters and state variables

based on dimension, mueff and possibly further options. Attributes are not overwritten unless their value is None or bool(reset) is True. This prevents to overwrite manual settings with late initialization.

>>> import cma  # test value of damps and reset behavior (minor)
>>> es = cma.CMAEvolutionStrategy(4 * [1], 1, {'verbose':-9})
>>> assert 1.479176368423 < es.adapt_sigma.damps < 1.479176368424, es.adapt_sigma.__dict__
>>> es = cma.CMAEvolutionStrategy(2 * [1], 1, {'verbose':-9})
>>> assert 1.5 <= es.adapt_sigma.damps < 1.57317317, es.adapt_sigma.__dict__
>>> es.adapt_sigma.damps = 1.234
>>> _ = es.adapt_sigma.initialize(es)
>>> assert es.adapt_sigma.damps == 1.234, es.adapt_sigma.__dict__
>>> _ = es.adapt_sigma.initialize(es)
>>> assert es.adapt_sigma.damps == 1.234, es.adapt_sigma.__dict__
>>> es.adapt_sigma.is_initialized = False
>>> _ = es.adapt_sigma.initialize(es)
>>> assert es.adapt_sigma.damps == 1.234, es.adapt_sigma.__dict__
>>> _ = es.adapt_sigma.initialize(es, reset=True)  # reset everything
>>> assert 1.5 <= es.adapt_sigma.damps < 1.57317317, es.adapt_sigma.__dict__
>>> es.adapt_sigma.damps = 1.234
>>> _ = es.optimize(cma.ff.elli, iterations = 4)
>>> assert es.adapt_sigma.damps == 1.234, es.adapt_sigma.__dict__
def initialize_settings(self, es, reset=False):

set attributes cs, damps and others,

namely exponent, disregard_length_setting, max_delta_log_sigma.

Attributes are not overwritten when they already exist unless their value is None or bool(reset) is True.

Details: We don't need to adjust for a change of cs? A changed cs is used in the decay and in the sigma update, hence the latter already adjusts for the change in decay. The latter does not adjust the change in the entry weight sqrt(cs * (2 - cs)) as both change the same way which seems correct too.

def update(self, es, **kwargs):

call self._update_ps(es) and update es.sigma.

Legacy method replaced by update2.

def update2(self, es, **kwargs):

call self._update_ps(es) and update self.delta.

Return change factor of self.delta stored in ._last_multiplier.

From input es, attributes opts, countiter, path_for_sigma_update, and sometimes _path_for_invariant_update, sp.cc are used.

dampdown_fac =

Asymmetric damping parameter read from module variable csa_dampdown_fac (this may change in future)

damps =

Undocumented

delta: int =

cumulated effect of adaptation

is_initialized: bool =

Undocumented

max_delta_log_sigma: int =

Undocumented

def _update_ps(self, es):

update path with isotropic delta mean, possibly clipped.

From input argument es, the attributes isotropic_mean_shift, opts['CSA_clip_length_value'], countiter, sp.weights.mueff, path_mask are used. opts['CSA_clip_length_value'] can be a single value, the upper bound factor, such that:

max_len = sqrt(N) + opts['CSA_clip_length_value'] * N / (N+2)

or a list with a lower and an upper factor.

_es_opts =

Undocumented

_lam_mirr =

Undocumented

_last_multiplier =

Undocumented

_popsize =

Undocumented

_ps_updated_iteration =