CMA-ES

Also known as: Covariance matrix adaptation evolution strategy

On this page 7

CMA-ES, the covariance matrix adaptation evolution strategy, is a stochastic, derivative-free algorithm for numerical optimization of continuous functions that samples candidate solutions from a multivariate normal distribution and adapts the mean, step size and full covariance matrix of that distribution from generation to generation. Within evolutionary computation, a branch of artificial intelligence, it is widely regarded as the state-of-the-art evolution strategy for difficult, non-separable and ill-conditioned problems of moderate dimension.

Developed mainly by Nikolaus Hansen and Andreas Ostermeier in the 1990s, CMA-ES learns the shape of the fitness landscape without computing gradients. Its update rules are closely related to a natural gradient step on the parameters of the search distribution, which explains why it is both robust and largely invariant to rotations and monotone transformations of the objective function.

How CMA-ES samples and updates its search distribution

Each generation, CMA-ES draws lambda offspring from a normal distribution with mean m, global step size sigma and covariance matrix C. It evaluates their fitness, ranks them and keeps the best mu individuals. Only the ranking is used, never the raw fitness values, which makes the method rank-based and insensitive to scaling of the objective.

The new mean is a weighted recombination of the selected individuals, with larger weights for better ranks. The covariance matrix is then updated with two complementary terms, and the step size is adapted separately. The table below summarizes the main update mechanisms.

MechanismWhat it updatesPurpose
Weighted recombinationDistribution meanMoves the search toward better regions
Rank-one updateCovariance matrixReinforces the direction of recent progress via the evolution path
Rank-mu updateCovariance matrixUses information from all selected steps in one generation
Cumulative step-size adaptationStep size sigmaLengthens or shortens steps by comparing path length with its expected value
Evolution pathsAccumulated mean shiftsCaptures correlations between consecutive generations
Core update mechanisms of CMA-ES

Over time, C approximates the inverse Hessian of the objective near the optimum, up to a scalar factor. In effect, CMA-ES learns a variable metric, similar to quasi-Newton methods such as BFGS, but from ranked samples instead of gradients.

Key parameters and default settings

A major practical strength of CMA-ES is that it is almost parameter-free. Learning rates and weights have carefully derived defaults that depend only on the problem dimension n, so users normally set just the initial mean and the initial step size.

ParameterDefault or typical valueEffect
Population size lambda4 + floor(3 ln n)Larger values improve global search but cost more evaluations
Parent number muAbout lambda / 2Controls selection pressure in recombination
Initial step size sigmaAbout 0.3 of the search rangeSets the initial exploration radius
Initial meanUser-chosen starting pointDetermines where the search begins
Covariance learning rateRoughly 2 / n squared for rank-oneSlower adaptation in high dimensions
Typical CMA-ES parameters

Because the covariance learning rates scale with one over n squared, adapting a full matrix requires on the order of n squared function evaluations. This is why CMA-ES performs best for problems with roughly 3 to a few hundred variables; beyond that, restricted variants become necessary.

Variants for restarts, constraints and large scale

Several well-established variants extend the basic algorithm to multimodal, noisy or high-dimensional problems. The most widely used ones are summarized here.

  • IPOP-CMA-ES restarts the search with a doubled population size whenever progress stalls, which greatly improves performance on multimodal functions.
  • BIPOP-CMA-ES alternates between large and small population regimes to balance global and local search.
  • Separable CMA-ES adapts only the diagonal of C, which reduces cost to linear time per sample at the price of ignoring correlations.
  • Limited-memory and low-rank variants such as LM-CMA and VD-CMA scale the idea to thousands of variables.
  • MO-CMA-ES applies covariance adaptation to multi-objective optimization.

Constraint handling is not built into the original method. Common approaches include penalty functions, repair of infeasible samples and boundary transformations, each of which can distort the learned covariance if applied carelessly.

How CMA-ES compares with other evolutionary methods

CMA-ES belongs to the family of evolution strategies, but its explicit modeling of the search distribution also links it to estimation of distribution algorithms. The comparison below positions it against close neighbors in the Topic.

MethodSearch representationMain strengthMain weakness
CMA-ESFull covariance normal distributionHandles ill-conditioned, rotated problemsQuadratic cost in dimension
Simple evolution strategyIsotropic or diagonal mutationCheap and easy to implementSlow on correlated variables
Differential evolutionDifference vectors of the populationSimple, good global explorationSensitive to control parameters
Genetic algorithmEncoded chromosomes with crossoverFlexible for discrete problemsWeak on continuous ill-conditioned functions
Particle swarm optimizationParticles with velocitiesFast early progressProne to premature convergence
CMA-ES compared with related optimizers

On standard benchmark suites such as COCO and BBOB, CMA-ES and its restart variants are consistently among the best general-purpose black-box optimizers for moderate budgets, although specialized surrogate-based methods can win when evaluations are extremely expensive.

Limitations and practical cautions

CMA-ES is powerful but not universal. Its main limitations concern dimension, budget and problem type, and they explain most disappointing results in practice.

SymptomLikely causeRemedy
Converges to a poor local optimumPopulation too small for a multimodal landscapeUse IPOP or BIPOP restarts
Very slow progress at startInitial step size far too smallSet sigma to about a third of the range
Excessive runtime per generationDimension in the thousandsUse separable or low-rank variants
Erratic behavior on noisy objectiveNoise disturbs rankingIncrease population or use noise handling
Typical problems and remedies

The method is also unsuitable for purely discrete or combinatorial problems without a continuous encoding, and when gradients are cheap and reliable, gradient-based optimizers are usually far more efficient.

The simple explanation

Imagine searching for the lowest point in a foggy valley. You throw a handful of stones around you. You see which ones land lowest. Then you move toward them.

CMA-ES does the same with numbers. It also learns which directions are promising. Over time, its throws stretch along the valley floor and shrink across it. It needs only scores, not slopes, so it works on problems where formulas are unknown.

How it is used in practice

A robotics team needs to tune 24 parameters of a walking controller for a four-legged robot in simulation. The objective is distance walked in ten seconds without falling, which is noisy and has no usable gradient. The team starts CMA-ES from hand-tuned values with an initial step size of 0.3 in normalized units and the default population of 13 candidates per generation.

After about 6,000 simulated trials, which run overnight on a workstation, the learned covariance reveals strong correlations between hip and knee timing parameters that manual tuning had missed. The resulting gait walks roughly 40 percent farther than the hand-tuned baseline. The team then uses IPOP restarts to check that no clearly better gait family exists before transferring the controller to the physical robot.