Covariance Matrix Adaptation Evolution Strategy (CMAES)
- class pypop7.optimizers.es.cmaes.CMAES(problem, options)[source]
Covariance Matrix Adaptation Evolution Strategy (CMAES).
Note
CMAES is widely recognized as one of State-Of-The-Art (SOTA) evolutionary algorithms for continuous black-box optimization (BBO), according to the well-recognized Nature review of Evolutionary Computation.
For some (rather all) interesting applications of CMA-ES, please refer to e.g., [ICLR-2024 Spotlight], [TMRB-2024], [LWC-2024], [RSIF-2024], [MNRAS-2024], [Medical Physics-2024], [Wolff, 2024], [Jankowski et al., 2024], [Martin, 2024, Ph.D. Dissertation (Harvard University)], [Milekovic et al., 2023, Nature Medicine], [Chen et al., 2023, Science Robotics], [Falk et al., 2023, PNAS], [Thamm&Rosenow, 2023, PRL], [Brea et al., 2023, Nature Communications], [Ghafouri&Biros, 2023], [Barral, 2023, Ph.D. Dissertation (University of Oxford)], [Slade et al., 2022, Nature], [Rudolph et al., 2022, Nature Communications], [Cazenille et al., 2022, Bioinspiration & Biomimetics], [Franks et al., 2021], [Yuan et al., 2021, MNRAS], [Löffler et al., 2021, Nature Communications], [Papadopoulou et al., 2021, JPCB], [Schmucker et al., 2021, PLoS Comput Biol], [Barkley, 2021, Ph.D. Dissertation (Harvard University)], [Fernandes, 2021, Ph.D. Dissertation (Harvard University)], [Quinlivan, 2021, Ph.D. Dissertation (Harvard University)], [Vasios et al., 2020, Soft Robotics], [Pal et al., 2020], [Lei, 2020, Ph.D. Dissertation (University of Oxford)], [Pisaroni et al., 2019, Journal of Aircraft], [Yang et al., 2019, Journal of Aircraft], [Ong et al., 2019, PLOS Computational Biology], [Zhang et al., 2017, Science], [Wei&Mahadevan, 2016, Soft Matter], [Loshchilov&Hutter, 2016], [Molinari et al., 2014, AIAAJ], [Melton, 2014, Acta Astronautica], [Khaira et al., 2014, ACS Macro Lett.], to name a few.
- Parameters:
problem (dict) –
- problem arguments with the following common settings (keys):
’fitness_function’ - objective function to be minimized (func),
’ndim_problem’ - number of dimensionality (int),
’upper_boundary’ - upper boundary of search range (array_like),
’lower_boundary’ - lower boundary of search range (array_like).
options (dict) –
- optimizer options with the following common settings (keys):
’max_function_evaluations’ - maximum of function evaluations (int, default: np.inf),
’max_runtime’ - maximal runtime to be allowed (float, default: np.inf),
’seed_rng’ - seed for random number generation needed to be explicitly set (int);
- and with the following particular settings (keys):
’sigma’ - initial global step-size, aka mutation strength (float),
’mean’ - initial (starting) point, aka mean of Gaussian search distribution (array_like),
if not given, it will draw a random sample from the uniform distribution whose search range is bounded by problem[‘lower_boundary’] and problem[‘upper_boundary’].
’n_individuals’ - number of offspring, aka offspring population size (int, default: 4 + int(3*np.log(problem[‘ndim_problem’]))),
’n_parents’ - number of parents, aka parental population size (int, default: int(options[‘n_individuals’]/2)).
Examples
Use the black-box optimizer CMAES to minimize the well-known test function Rosenbrock:
1>>> import numpy # engine for numerical computing 2>>> from pypop7.benchmarks.base_functions import rosenbrock # function to be minimized 3>>> from pypop7.optimizers.es.cmaes import CMAES 4>>> problem = {'fitness_function': rosenbrock, # to define problem arguments 5... 'ndim_problem': 2, 6... 'lower_boundary': -5.0*numpy.ones((2,)), 7... 'upper_boundary': 5.0*numpy.ones((2,))} 8>>> options = {'max_function_evaluations': 5000, # to set optimizer options 9... 'seed_rng': 2022, 10... 'mean': 3.0*numpy.ones((2,)), 11... 'sigma': 3.0} # global step-size may need to be fine-tuned for better performance 12>>> cmaes = CMAES(problem, options) # to initialize the optimizer class 13>>> results = cmaes.optimize() # to run the optimization/evolution process 14>>> print(f"CMAES: {results['n_function_evaluations']}, {results['best_so_far_y']}") 15CMAES: 5000, 0.0017
For its correctness checking of Python coding, please refer to this code-based repeatability report for all details. For pytest-based automatic testing, please see test_cmaes.py.
- best_so_far_x
final best-so-far solution found during entire optimization.
- Type:
array_like
- best_so_far_y
final best-so-far fitness found during entire optimization.
- Type:
array_like
- mean
initial (starting) point, aka mean of Gaussian search distribution.
- Type:
array_like
- n_individuals
number of offspring, aka offspring population size / sample size.
- Type:
int
- n_parents
number of parents, aka parental population size / number of positively selected search points.
- Type:
int
- sigma
final global step-size, aka mutation strength (updated during optimization).
- Type:
float
References
Hansen, N., 2023. The CMA evolution strategy: A tutorial. arXiv preprint arXiv:1604.00772.
Ollivier, Y., Arnold, L., Auger, A. and Hansen, N., 2017. Information-geometric optimization algorithms: A unifying picture via invariance principles. Journal of Machine Learning Research, 18(18), pp.1-65.
Hansen, N., Atamna, A. and Auger, A., 2014, September. How to assess step-size adaptation mechanisms in randomised search. In International Conference on Parallel Problem Solving From Nature (pp. 60-69). Springer, Cham.
Kern, S., Müller, S.D., Hansen, N., Büche, D., Ocenasek, J. and Koumoutsakos, P., 2004. Learning probability distributions in continuous evolutionary algorithms–a comparative review. Natural Computing, 3, pp.77-112.
Hansen, N., Müller, S.D. and Koumoutsakos, P., 2003. Reducing the time complexity of the derandomized evolution strategy with covariance matrix adaptation (CMA-ES). Evolutionary Computation, 11(1), pp.1-18.
Hansen, N. and Ostermeier, A., 2001. Completely derandomized self-adaptation in evolution strategies. Evolutionary Computation, 9(2), pp.159-195.
Hansen, N. and Ostermeier, A., 1996, May. Adapting arbitrary normal mutation distributions in evolution strategies: The covariance matrix adaptation. In Proceedings of IEEE International Conference on Evolutionary Computation (pp. 312-317). IEEE.
Please refer to its lightweight Python implementation from cyberagent.ai: https://github.com/CyberAgentAILab/cmaes
Please refer to its official Python implementation from Hansen, N.: https://github.com/CMA-ES/pycma
Basic Information of CMA-ES
RoboCup 3D Simulation League Competition Champions.
[SIMULIA > CST Studio Suite > Automatic Optimization (Dassault Systèmes)] * Covariance Matrix Adaptation Evolutionary Strategy, Trust Region Framework (TRF), Genetic Algorithm, Particle Swarm Optimization, Nelder Mead Simplex Algorithm, Interpolated Quasi-Newton, Classic Powell, Decap Optimization (Last Access in 18 June, 2025)
Some of High-Quality Tutorials for CMA-ES
Some Applications of CMA-ES
[2024 in Proceedings of the National Academy of Sciences]: National University of Singapore, University of Pennsylvania, University of Minnesota, ByteDance, Rutgers University, Yale University, Kandang Kerbau Women’s and Children’s Hospital, Singapore Institute for Clinical Sciences, University of Auckland, McGill University, Universitat Pompeu Fabra, Universitat Barcelona, Massachusetts General Hopstial
[2024 in Nature Communications]: Freie Universität Berlin, Fraunhofer Heinrich Hertz Institute, Helmholtz-Zentrum Berlin für Materialien und Energie
[2024 in NeurIPS]: University of Michigan (Ann Arbor), National University of Singapore, Carnegie Mellon University
[2022 in Nature]: Delft University of Technology, Aix Marseille Université
[2022 in IEEE Transactions on Robotics]: Electronics and Telecommunications Research Institute, Korea Advanced Institute of Science and Technology
[2016 in ICLR Workshop]: Univesity of Freiburg
[2015 in International Journal of Robotics Research]: ETH Zürich, Inria, CNRS, Université de Lorraine
“46 cores”
[2014 in ACS Macro Letters]: University of Chicago, A Western Digital Company, Argonne National Laboratory
[2013 in Physics in Medicine & Biology]: Johns Hopkins University, Siemens Healthcare
[2010 in ACM Transactions on Graphics (TOG)]: University of Toronto
“Noisy optimization”
“Parallel sampling (20 CPUs)”
[2009 in ACM Transactions on Graphics (TOG)]: University of Washington
“In discontinuous spaces”
[2001 in AIAA Journal]: Swiss Federal Institute of Technology
Some Interesting Applications in Robotics
[CoRL 2025]: Carnegie Mellon University, Google DeepMind
[Nature Medicine 2023]: EPFL et al.