Foundations to Frontier
Tests
A. Mathematical Foundations › A6 Optimization › Advanced

Evolution Strategies and CMA-ES

Evolution strategies optimize by sampling a population of candidate solutions, keeping the best, and adapting the sampling distribution. They need only function values (or even just rankings), parallelize perfectly, and tolerate noise and discontinuities. You will implement the (1+1)-ES with the 1/5th success rule, the covariance matrix adaptation evolution strategy (CMA-ES) that learns the problem's geometry like a derivative-free quasi-Newton method, and OpenAI-style natural evolution strategies to train a robot control policy.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Breed the best

Imagine searching for the best kite design by trial. Build a handful of random variations of your current design, fly them all, and keep the few that flew best. Make your next batch of variations around the winners. If the winners all lean one way (longer tail, smaller wings), vary more in that direction next time. Repeat.

That’s an evolution strategy. The population “learns” where to search, and you never need a formula for how good a kite is: you only fly them and compare.

A population that learns the shape of the valley: CMA-ES
σ = 1.5e+0 · ellipse axis ratio √(λ₁/λ₂) = 1.2 (valley: 10) · best f so far 6.4e-1 · evaluations 54
Green dots: this generation's 6 samples. Orange ellipse: the 2σ contour of the search distribution N(m, σ²C). Grey: the path of the mean. CMA-ES keeps only the ranking of samples, so it's invariant to monotone transformations of f. Its covariance update learns the inverse Hessian's shape, so after a few generations the ellipse stretches along the valley and the search proceeds as if the problem were well conditioned. It's a derivative-free cousin of quasi-Newton methods.
Why engineers care

CMA-ES is the default black-box optimizer for tough continuous problems with tens to hundreds of variables: spacecraft trajectory design, robot gait and controller parameters, antenna and aerodynamic shapes. Evolution strategies also train neural-network control policies with thousands of CPUs in parallel, with no backpropagation needed.

📝 Quick check (Level 0)
0/3 answered
  1. 1. An evolution strategy keeps…
  2. 2. To decide which candidates are best, ES needs…
  3. 3. Evaluating many candidates at once makes ES…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

(1+1)-ES with the 1/5th success rule (Rechenberg, 1973)

Mutate y=x+σzy = x + \sigma z with z∼N(0,I)z\sim\mathcal N(0, I), and keep yy if it’s no worse. Adapt the step size:

  • on success, σ←σe1/3\sigma\leftarrow\sigma e^{1/3};
  • on failure, σ←σe−1/12\sigma\leftarrow\sigma e^{-1/12}.

σ\sigma is stable when about 1 in 5 mutations succeeds. That success rate is near-optimal for progress on simple landscapes.

(μ/μ, λ)-ES and CMA-ES (Hansen and Ostermeier, 2001)

Each generation:

  1. Sample λ\lambda points xi=m+σyix_i = m + \sigma y_i with yi∼N(0,C)y_i\sim\mathcal N(0, C).
  2. Rank them and recombine the best μ\mu with log-rank weights: m←m+σ∑wiyi:λm\leftarrow m + \sigma\sum w_iy_{i:\lambda}.
  3. Update the covariance CC toward the successful steps (rank-μ update) and along the evolution path (rank-1 update).
  4. Update the step size σ\sigma from the length of the conjugate evolution path (cumulative step-size adaptation).

Defaults: λ=4+⌊3ln⁡n⌋\lambda = 4 + \lfloor3\ln n\rfloor and μ=λ/2\mu = \lambda/2. They are almost never tuned.

📝 Quick check (Level 1)
0/3 answered
  1. 1. The 1/5th rule keeps σ stable when the success rate is about…
  2. 2. CMA-ES adapts…
  3. 3. Default population size for n = 5 is…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.

What CMA-ES learns

On a convex quadratic, the covariance CC converges toward a multiple of the inverse Hessian. Sampling from N(m,σ2H−1)\mathcal N(m, \sigma^2H^{-1}) makes the problem look perfectly conditioned, much as quasi-Newton methods (A6.3-5) learn H−1H^{-1} from gradients. CMA-ES learns it from rankings alone.

Invariances

  • Monotone transformations of ff: only ranks are used, so ff, efe^f and log⁡f\log f behave identically.
  • Rotations and affine changes of the search space (with a matching initial CC): there are no axis-aligned assumptions.

These make CMA-ES remarkably robust. Its cost is O(n2)O(n^2) memory and time per sample, and it typically needs about 10n210n^2 evaluations on ill-conditioned problems.

Natural evolution strategies for large n

Salimans et al. (2017) optimize the expected return J(θ)=Eεf(θ+σε)J(\theta) = \mathbb E_\varepsilon f(\theta + \sigma\varepsilon) by gradient ascent with the estimate ∇J≈1nσ∑if(θ+σεi)εi\nabla J\approx\frac1{n\sigma}\sum_if(\theta + \sigma\varepsilon_i)\varepsilon_i. That’s the zeroth-order estimator of A6.4-1. Practical ingredients:

  • antithetic pairs ±ε\pm\varepsilon to reduce variance;
  • rank-based fitness shaping, robust to reward scale and outliers;
  • one shared random seed per worker, so only scalar returns need to be communicated.

It scales to thousands of CPUs and millions of policy parameters.

🐍 Exercise 1: CMA-ES vs an isotropic ES
Implement the (1+1)-ES with the 1/5th rule and a compact CMA-ES. On a rotated ellipsoid with κ = 10⁴ in 5-D, compare results after 6000 evaluations, and check that the learned covariance aligns with the inverse Hessian.
📝 Quick check (Level 2)
0/3 answered
  1. 1. On a quadratic, CMA-ES's covariance approaches…
  2. 2. CMA-ES is invariant to replacing f by…
  3. 3. OpenAI-style ES communicates between workers…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Deriving the 1/5th rule’s balance

With up-factor eae^a on success (probability pp) and down-factor e−be^{-b} on failure, E[Δlog⁡σ]=pa−(1−p)b\mathbb E[\Delta\log\sigma] = pa - (1 - p)b. That’s zero when p=b/(a+b)p = b/(a + b). With a=1/3a = 1/3 and b=1/12b = 1/12: p=(1/12)/(5/12)=1/5p = (1/12)/(5/12) = 1/5. ∎

Why antithetic sampling helps

f(θ+σε)−f(θ−σε)2σε\frac{f(\theta + \sigma\varepsilon) - f(\theta - \sigma\varepsilon)}{2\sigma}\varepsilon: by Taylor, the even-order terms (including f(θ)f(\theta) and the curvature term) cancel, leaving (∇f⊤ε)ε+O(σ2)(\nabla f^\top\varepsilon)\varepsilon + O(\sigma^2). Without mirroring, the term f(θ)ε/σf(\theta)\varepsilon/\sigma has mean zero but huge variance when f(θ)f(\theta) is large. ∎

ES as gradient ascent on a smoothed objective

∇θEεf(θ+σε)=1σE[f(θ+σε)ε]\nabla_\theta\mathbb E_\varepsilon f(\theta + \sigma\varepsilon) = \frac1\sigma\mathbb E[f(\theta + \sigma\varepsilon)\varepsilon] (Stein, A6.4-1). ES ascends the Gaussian-smoothed return, which smooths over discontinuities, contacts and saturation in robot rollouts. When the update is also measured in the Fisher metric of the search distribution, it becomes the natural gradient (Wierstra et al., 2014), linking ES to A6.3-6.

Exercise 3.1: Stationary success rate with up-factor e^(1/2) and down-factor e^(−1/8)

p=(1/8)/(1/2+1/8)=0.2p = (1/8)/(1/2 + 1/8) = 0.2.

📝 Quick check (Level 3)
0/3 answered
  1. 1. With up-factor eᵃ and down-factor e⁻ᵇ, σ is stationary at success probability…
  2. 2. Antithetic sampling cancels…
  3. 3. ES ascends the gradient of…

Level 4: Expert

★★★★★ Expert⏱ 40 minResearchers: original papers and open problems.

Training a control policy without backpropagation

A planar point robot must reach the origin from four starts under saturating acceleration limits. The policy is a linear feedback u=clip⁡(Ks)u = \operatorname{clip}(Ks) with 8 gains. Saturation makes the return non-differentiable in KK. OpenAI-style ES (8 antithetic pairs per iteration, rank shaping, 50 iterations, about 850 episodes) goes from the zero policy’s return of about −21.6 to −5.7. That matches a hand-tuned PD controller and clearly beats random search with the same number of episodes.

🐍 Exercise 2 (research): evolution strategies for a robot policy
Implement episode rollouts of a saturated linear policy, centered-rank fitness shaping and antithetic natural ES. Train the 8 gains and compare with random search at equal budget and with a hand-tuned controller.

Evolution strategies in AI, robotics and aerospace

  • Spacecraft trajectory design: CMA-ES and differential evolution are standard global optimizers in ESA’s pykep/pagmo toolkits (Izzo, 2012).
  • Robot locomotion and morphology: gait and controller parameters (Hansen et al. on walking robots; Lipson and Pollack, 2000, evolving robot bodies).
  • Deep RL alternative: ES scales to thousands of workers on MuJoCo and Atari (Salimans et al., 2017). Augmented random search shows linear policies suffice for many locomotion tasks (Mania, Guy and Recht, 2018).
  • Hyperparameter and architecture search: CMA-ES is a strong baseline for continuous hyperparameters (Loshchilov and Hutter, 2016).

References

  1. I. Rechenberg (1973). Evolutionsstrategie. Frommann-Holzboog.
  2. N. Hansen, A. Ostermeier (2001). “Completely derandomized self-adaptation in evolution strategies.” Evolutionary Computation, 9(2).
  3. N. Hansen (2016). “The CMA evolution strategy: a tutorial.” arXiv:1604.00772.
  4. D. Wierstra et al. (2014). “Natural evolution strategies.” JMLR, 15.
  5. T. Salimans, J. Ho, X. Chen, S. Sidor, I. Sutskever (2017). “Evolution strategies as a scalable alternative to reinforcement learning.” arXiv:1703.03864.
  6. H. Mania, A. Guy, B. Recht (2018). “Simple random search of static linear policies is competitive for reinforcement learning.” NeurIPS.
  7. D. Izzo (2012). “PyGMO and PyKEP: open source tools for massively parallel optimization in astrodynamics.” ICATT.
  8. H. Lipson, J. Pollack (2000). “Automatic design and manufacture of robotic lifeforms.” Nature, 406.
  9. I. Loshchilov, F. Hutter (2016). “CMA-ES for hyperparameter optimization of deep neural networks.” ICLR Workshop.
  10. H.-G. Beyer, H.-P. Schwefel (2002). “Evolution strategies — a comprehensive introduction.” Natural Computing, 1.