Evolutionary Strategy (CMA-ES) — Covariance Matrix Adaptation

Decision Sciences
Introduced by
Nikolaus Hansen & Andreas Ostermeier
Year
2001
Type
Derivative-free continuous black-box optimizer

What does it do?

CMA-ES (Covariance Matrix Adaptation Evolution Strategy) is a derivative-free optimizer for continuous black-box functions.

It maintains a population of candidate solutions sampled from a multivariate normal distribution and updates that distribution's mean, step size, and covariance matrix using the best-ranked candidates. The covariance adaptation scheme was described by Hansen and Ostermeier in their 2001 Evolutionary Computation paper, and the method is used for continuous black-box optimization, including reinforcement-learning policy optimization.

The intuition behind the method

Imagine you are searching for the lowest point in a hilly landscape but you cannot see the terrain — you can only probe individual locations and learn their heights. CMA-ES works like a guided swarm: it drops a cloud of probes around a current best guess, measures how good each probe is, and then reshapes the cloud for the next round. The cloud is not a simple sphere — it learns the elongated, tilted shape of the valley it is descending into by remembering which directions led to improvement. Over successive generations the cloud narrows and tilts to align with the curvature of the loss surface, letting the algorithm navigate long narrow valleys that would trap simpler methods.

History

Evolution strategies, population-based optimizers inspired by biological evolution, are associated with work from the 1970s, for example Rechenberg (1973) and Schwefel (1975). Hansen and Ostermeier's 2001 Evolutionary Computation paper described covariance matrix adaptation as completely derandomized self-adaptation of arbitrary normal mutation distributions; on badly scaled, non-separable test functions the paper reports large speed-ups over evolution strategies without covariance adaptation. Hansen's 2016 tutorial, an arXiv preprint, later presented the algorithm in a consolidated form.

When to use it

Choose CMA-ES when the objective is continuous, possibly non-convex, multimodal or noisy, and when gradients are unavailable or too costly to compute, for example when the objective is a simulator that returns only scalar outputs. The stated ideal range is roughly 10 to 1000 parameters. Below that range simpler methods may be enough, and for very low-dimensional problems the population overhead gives little benefit. Above it, the quadratic memory cost of the full covariance matrix becomes a constraint. Do not use CMA-ES for discrete or combinatorial variables, which the method does not represent directly. No sample-size requirement applies in the statistical sense, because the algorithm generates its own evaluation points. Typical uses include hyperparameter tuning, reinforcement-learning policy optimization and engineering design with black-box simulators.

Limitations and considerations

  • Memory grows with the square of the dimension because the full covariance matrix is stored and updated; beyond the stated range of about 1000 parameters this becomes a constraint, and reduced-memory variants have been proposed for this regime. Sampling also requires working with this matrix, so the cost per generation rises steeply with dimension as well.
  • Without restarts the method converges to a local optimum; for multimodal landscapes, restart variants such as IPOP-CMA-ES or BIPOP-CMA-ES are needed.
  • The method is defined over continuous real-valued vectors, so discrete or categorical variables must be handled outside it, for example by an encoding or by a different method.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Needs no gradient information: it requires only the scalar objective value at each sampled point, so it can be applied to noisy or simulation-based objectives.
  • Covariance adaptation learns correlations between parameters from the history of successful steps, which helps on elongated, badly scaled, non-separable landscapes where methods with fixed search distributions struggle. On badly scaled, non-separable test functions the 2001 paper reports speed-ups of several orders of magnitude relative to evolution strategies without covariance adaptation, while performance is comparable on perfectly scaled functions.
  • Selection uses ranks of candidate values, so the method is invariant to order-preserving transformations of the objective and to rotations of the search space.
  • Its main user-set parameter is the initial step size, and the population size has a default formula, so the number of settings to choose is small.

Applications

  • Hyperparameter tuning for machine-learning models, including reinforcement-learning agents.
  • Reinforcement-learning policy optimization when the policy is parameterized by a continuous vector.
  • Engineering design optimization, such as aerodynamic shape optimization and structural parameter fitting, where only simulator outputs are available.
  • Scientific model calibration when the likelihood is non-differentiable or expensive to evaluate.

How it works

How it works

1

The algorithm is seeded with an initial solution vector and an initial step size (sigma). The covariance matrix starts as the identity matrix, a perfectly spherical search cloud. Population size is set, typically around 4 + floor(3 * ln(dimension)).

2

At each generation a population of candidate solutions is drawn from the current search distribution. Each candidate has the form x_k = m + sigma * y_k, where y_k is drawn from N(0, C), m is the mean vector, sigma is the step size and C is the covariance matrix. Because the distribution is multivariate normal, samples reflect both the current best estimate and the learned shape of the search space.

3

Each candidate solution is passed to the objective function and receives a fitness score. No gradient information is required; only the scalar objective value at each sampled point is needed. This makes CMA-ES suitable for noisy, non-differentiable, and simulation-based objectives.

4

The mean is moved toward the better-ranked solutions, as a weighted recombination of the best samples of the current generation. The covariance matrix is changed by two terms: a rank-one update driven by an evolution path, which accumulates the direction of recent successful steps (the cumulation idea described by Hansen and Ostermeier), and a rank-mu update that uses the selected solutions of the current generation. The step size is adapted separately by cumulative step-size adaptation, which compares the length of the evolution path with its expected length under random selection. Together these make directions that produced improvements more likely to be sampled in the next generation, which is how the algorithm learns the local geometry of the landscape. The full update equations are given in Hansen (2016).

5

The algorithm repeats the sample–evaluate–update cycle until a stopping criterion is met: a maximum number of function evaluations, a tolerance on the change in the mean or step size, or a detected degeneration of the covariance matrix. The best solution found across all generations is returned.

Common pitfalls

  • Setting the initial step size too small traps the search in a narrow neighbourhood and prevents exploration; too large and early generations waste evaluations far from the optimum. A practitioner heuristic, not a formal result, is to set sigma so that the optimum lies within about three sigma of the starting point.
  • Using CMA-ES on very low-dimensional problems is often wasteful: grid search or Nelder-Mead can be sufficient, and the population overhead brings little benefit when there are few parameters.
  • Running only a single CMA-ES instance on a multimodal landscape risks missing the global optimum; use multi-start or restart strategies such as IPOP or BIPOP when the landscape is known to be highly multimodal.
  • Treating the returned best solution as the true global optimum without restart verification is a common mistake; confirm with multiple independent runs when the objective is highly non-convex.

Frequently asked questions

How does CMA-ES differ from a simple genetic algorithm?

A classic genetic algorithm maintains a population and applies crossover and mutation with fixed operators. CMA-ES instead models the population as samples from a multivariate normal distribution and continuously adapts that distribution (its mean, step size, and full covariance matrix) based on which solutions were successful. This allows CMA-ES to learn the shape of the loss landscape and navigate correlated, ill-conditioned spaces far more efficiently than a genetic algorithm with fixed operators.

Does CMA-ES guarantee finding the global optimum?

No. CMA-ES is a local search method in the sense that a single run can converge to a local optimum. For multimodal landscapes, multiple independent restarts, possibly with increasing population sizes (IPOP-CMA-ES), are recommended to improve coverage of the search space.

What is the most important hyperparameter to set?

The initial step size sigma is the single most influential hyperparameter. A practitioner heuristic, not a formal result, is to set it so that the expected optimum lies within roughly three sigma of the starting point. Population size and the maximum number of evaluations are secondary controls; the default population size formula (4 + floor(3 * ln(dimension))) works well in practice.

Can CMA-ES handle noisy objective functions?

To a moderate degree. CMA-ES uses rank-order information from the population rather than absolute function values, so rank-based selection tolerates moderate noise. Strong noise can, however, mislead the covariance adaptation, and rank-based selection does not remove noise. When evaluations are highly noisy, increasing the population size or averaging repeated evaluations per candidate is advisable.

Related methods

Sources

  1. Hansen, N. & Ostermeier, A. (2001). Completely Derandomized Self-Adaptation in Evolutionary Strategies. Evolutionary Computation, 9(2), 159-195.

    Open DOI reference
  2. Hansen, N. (2016). The CMA Evolution Strategy: A Tutorial. arXiv:1604.00772.

    Open publication reference