Nikolaus Hansen, Youhei Akimoto, and Petr Baudis. CMA-ES/pycma on Github. Zenodo, DOI:10.5281/zenodo.2559635, February 2019.
pycma is a Python implementation of CMA-ES and some related numerical optimization tools.
The CMA-ES (Covariance Matrix Adaptation Evolution Strategy) is a randomized derivative-free numerical optimization algorithm for difficult (non-convex, ill-conditioned, multi-modal, rugged, noisy) optimization problems in continuous and mixed-integer search spaces. This package provides an implementation of the CMA-ES algorithm that includes the handling of
'bounds' = [lower, upper] option or the cma.BoundDomainTransform wrapperconstraints argument to fmin2 or fmin_con2noise_handler=True as argument to fmin2'integer_variables'=index_list optionThe notebooks folder provides example code in Jupyter notebooks, namely
Hints for how to use this (kind of) optimization module in practice
In a system shell, type
python -m pip install cma
to install the latest release from the Python Package Index (PyPI).
Type install -U instead of install to upgrade a current installation to the latest release.
The release link also provides more
installation hints and a quick start guide.
The quick way to install the code from, for example, the development branch (this requires git to be installed):
pip install git+https://github.com/CMA-ES/pycma.git@development
The long way:
get the package
git installed, type git clone https://github.com/CMA-ES/pycma.git"install" the package
either copy (or move) the cma source code folder into a folder which is in the
Python path (e.g. the current folder)
or modify the Python path to point
to the folder where the cma package folder can be found.
In both cases, import cma works without any further installation.
or install the cma package by typing
pip install -e .
in the (pycma) folder where the cma package folder can be found.
Moving the cma folder away from its location invalidates this
installation.
It may be necessary to replace pip with python -m pip and/or prefixing
either of these with sudo.
verb_disp_overwrite which now expresses "number of lines"runs attribute in CMAEvolutionStrategyResult2all_stoppings and all_best module attributes with information
collected from restartssigma_adaptation.pyAugmentedLagrangian constraints handler and initialization bug fixcma.evolution_strategy.TPA_dimension = 300 sets TPA as default step-size adaptation
for dimension >= 300.optimization_tools.EvaluationsIterator to compute
non-discretized ERT values from non-f-targeted datas.figpolish and s.grid for convenienceCountWarnings instance deliver_warnings to control the
number of warnings shownbbob-f24 in 10 and 20-D while worsening the performance on bbob-f23 in 10 and
40-D.'TPA_dampfac' analogous to 'CSA_dampfac'.cma.utilities.math.test...more_algorithms sub-package containing purecma and CompactGA.experimentation module (requires import cma.experimentation).comocma):
cma.constraints_handling.BoundTransform class
which was missing since 4.1.0. Note that cma.BoundTransform is the
recommended way to access this classOOOptimizer.optimize on self.resultmatplotlib>3.8.0.cma.fitness_functions.binary_foffset = 0 by default now)fmin2 accepts a constraints function as constraints keyword argumentCMAEvolutionStrategyResult2 class which also contains the best feasible solutionreset_options method which also clears the current termination status.optimize() and of .result_pretty().stop() value displayed with cma.plotask has an ignore_integer_variables argument to not mutate integer variablescma.integer_centering.centering_on (by default True)cma.transformations.RoundIntegerVariables classutils.SolutionDict can behave like a queue toofmin to fmin2numpy scalar type representations at various placesuse_archives flag with archive_sent_solutions
and archive_after_sentBoundDomainTransformmatplotlib, plots display the value of .stop() and the version numbersetup.py with pyproject.toml4.1.0 (already since 5a30571f)
numpy 2.0 (thanks to Sait Cakmak)noise_handler argument which accepts True as valueScaleCoordinates now also with lower and upper value mapping to [0, 1], see issue #210'ftarget' triggers with <= instead of <surrogate attribute (for the record) when calling fmin_lq_surrx_opt=indexbbobbenchmarks without downloadingCMADataLogger.zip allows sharing plotting data more easily by a zip filetolxstagnation termination condition for when the incumbent seems stuckcma.evalution_strategy.all_stoppingsstall_sigma_change_on_divergence_iterations option to stall
sigma change when the median fitness is worseningRelease 3.3.0
implements
CMA_diagonal_decoding, by default still off).fmin_lq_surr2 for running the surrogate assisted
lq-CMA-ES.optimization_tools.ShowInFolder to facilitate rapid experimentation.verb_disp_overwrite option starts to overwrite the last line of the
display output instead of continuing adding lines to avoid screen
flooding with longish runs (off by default).Release 3.2.2
fixes some smallish interface and logging bugs in ConstrainedFitnessAL
and a bug when printing a warning. Polishing mainly in the plotting
functions. Added a notebook for how to use constraints.
Release 3.2.1
fixes plot of principal axes which were shown squared by mistake in version 3.2.0.
Release 3.2.0
provides a new interface for constrained optimization ConstrainedFitnessAL
and fmin_con2 and many other minor fixes and improvements.
Release 3.1.0
fixes the return value of fmin_con, improves its usability and provides
a best_feasible attribute in CMAEvolutionStrategy, in addition to
various other more minor code fixes and improvements.
Release 3.0.3 provides parallelization with OOOptimizer.optimize(..., n_jobs=...) (fix for 3.0.1/2) and improved pickle support.
Release 3.0.0 provides non-linear constraints handling, improved plotting and termination options and better resilience to injecting bad solutions, and further various fixes.
Version 2.7.1 allows for a list of termination callbacks and a light copy of CMAEvolutionStrategy instances.
Release 2.7.0 logger now writes into a folder, new fitness model module, various fixes.
Release 2.6.1 allow possibly much larger condition numbers, fix corner case with growing more-to-write list.
Release 2.6.0 allows initial solution x0 to be a callable.
Version 2.4.2 added the function cma.fmin2 which, similar to cma.purecma.fmin,
returns (x_best:numpy.ndarray, es:cma.CMAEvolutionStrategy) instead of a 10-tuple
like cma.fmin. The result 10-tuple is accessible in es.result:namedtuple.
Version 2.4.1 included bbob testbed.
Version 2.2.0 added VkD CMA-ES to the master branch.
Version 2.* is a multi-file split-up of the original module.
Version 1.x.* is a one file implementation and not available in the history of
this repository. The latest 1.* version 1.1.7 can be found
here.
50 followers · starred Jan 2023
174 followers · starred Mar 2024
48 followers · starred Mar 2020
185 followers · starred May 2019
Nikolaus Hansen, Youhei Akimoto, and Petr Baudis. CMA-ES/pycma on Github. Zenodo, DOI:10.5281/zenodo.2559635, February 2019.
pycma is a Python implementation of CMA-ES and some related numerical optimization tools.
The CMA-ES (Covariance Matrix Adaptation Evolution Strategy) is a randomized derivative-free numerical optimization algorithm for difficult (non-convex, ill-conditioned, multi-modal, rugged, noisy) optimization problems in continuous and mixed-integer search spaces. This package provides an implementation of the CMA-ES algorithm that includes the handling of
'bounds' = [lower, upper] option or the cma.BoundDomainTransform wrapperconstraints argument to fmin2 or fmin_con2noise_handler=True as argument to fmin2'integer_variables'=index_list optionThe notebooks folder provides example code in Jupyter notebooks, namely
Hints for how to use this (kind of) optimization module in practice
In a system shell, type
python -m pip install cma
to install the latest release from the Python Package Index (PyPI).
Type install -U instead of install to upgrade a current installation to the latest release.
The release link also provides more
installation hints and a quick start guide.
The quick way to install the code from, for example, the development branch (this requires git to be installed):
pip install git+https://github.com/CMA-ES/pycma.git@development
The long way:
get the package
git installed, type git clone https://github.com/CMA-ES/pycma.git"install" the package
either copy (or move) the cma source code folder into a folder which is in the
Python path (e.g. the current folder)
or modify the Python path to point
to the folder where the cma package folder can be found.
In both cases, import cma works without any further installation.
or install the cma package by typing
pip install -e .
in the (pycma) folder where the cma package folder can be found.
Moving the cma folder away from its location invalidates this
installation.
It may be necessary to replace pip with python -m pip and/or prefixing
either of these with sudo.
verb_disp_overwrite which now expresses "number of lines"runs attribute in CMAEvolutionStrategyResult2all_stoppings and all_best module attributes with information
collected from restartssigma_adaptation.pyAugmentedLagrangian constraints handler and initialization bug fixcma.evolution_strategy.TPA_dimension = 300 sets TPA as default step-size adaptation
for dimension >= 300.optimization_tools.EvaluationsIterator to compute
non-discretized ERT values from non-f-targeted datas.figpolish and s.grid for convenienceCountWarnings instance deliver_warnings to control the
number of warnings shownbbob-f24 in 10 and 20-D while worsening the performance on bbob-f23 in 10 and
40-D.'TPA_dampfac' analogous to 'CSA_dampfac'.cma.utilities.math.test...more_algorithms sub-package containing purecma and CompactGA.experimentation module (requires import cma.experimentation).comocma):
cma.constraints_handling.BoundTransform class
which was missing since 4.1.0. Note that cma.BoundTransform is the
recommended way to access this classOOOptimizer.optimize on self.resultmatplotlib>3.8.0.cma.fitness_functions.binary_foffset = 0 by default now)fmin2 accepts a constraints function as constraints keyword argumentCMAEvolutionStrategyResult2 class which also contains the best feasible solutionreset_options method which also clears the current termination status.optimize() and of .result_pretty().stop() value displayed with cma.plotask has an ignore_integer_variables argument to not mutate integer variablescma.integer_centering.centering_on (by default True)cma.transformations.RoundIntegerVariables classutils.SolutionDict can behave like a queue toofmin to fmin2numpy scalar type representations at various placesuse_archives flag with archive_sent_solutions
and archive_after_sentBoundDomainTransformmatplotlib, plots display the value of .stop() and the version numbersetup.py with pyproject.toml4.1.0 (already since 5a30571f)
numpy 2.0 (thanks to Sait Cakmak)noise_handler argument which accepts True as valueScaleCoordinates now also with lower and upper value mapping to [0, 1], see issue #210'ftarget' triggers with <= instead of <surrogate attribute (for the record) when calling fmin_lq_surrx_opt=indexbbobbenchmarks without downloadingCMADataLogger.zip allows sharing plotting data more easily by a zip filetolxstagnation termination condition for when the incumbent seems stuckcma.evalution_strategy.all_stoppingsstall_sigma_change_on_divergence_iterations option to stall
sigma change when the median fitness is worseningRelease 3.3.0
implements
CMA_diagonal_decoding, by default still off).fmin_lq_surr2 for running the surrogate assisted
lq-CMA-ES.optimization_tools.ShowInFolder to facilitate rapid experimentation.verb_disp_overwrite option starts to overwrite the last line of the
display output instead of continuing adding lines to avoid screen
flooding with longish runs (off by default).Release 3.2.2
fixes some smallish interface and logging bugs in ConstrainedFitnessAL
and a bug when printing a warning. Polishing mainly in the plotting
functions. Added a notebook for how to use constraints.
Release 3.2.1
fixes plot of principal axes which were shown squared by mistake in version 3.2.0.
Release 3.2.0
provides a new interface for constrained optimization ConstrainedFitnessAL
and fmin_con2 and many other minor fixes and improvements.
Release 3.1.0
fixes the return value of fmin_con, improves its usability and provides
a best_feasible attribute in CMAEvolutionStrategy, in addition to
various other more minor code fixes and improvements.
Release 3.0.3 provides parallelization with OOOptimizer.optimize(..., n_jobs=...) (fix for 3.0.1/2) and improved pickle support.
Release 3.0.0 provides non-linear constraints handling, improved plotting and termination options and better resilience to injecting bad solutions, and further various fixes.
Version 2.7.1 allows for a list of termination callbacks and a light copy of CMAEvolutionStrategy instances.
Release 2.7.0 logger now writes into a folder, new fitness model module, various fixes.
Release 2.6.1 allow possibly much larger condition numbers, fix corner case with growing more-to-write list.
Release 2.6.0 allows initial solution x0 to be a callable.
Version 2.4.2 added the function cma.fmin2 which, similar to cma.purecma.fmin,
returns (x_best:numpy.ndarray, es:cma.CMAEvolutionStrategy) instead of a 10-tuple
like cma.fmin. The result 10-tuple is accessible in es.result:namedtuple.
Version 2.4.1 included bbob testbed.
Version 2.2.0 added VkD CMA-ES to the master branch.
Version 2.* is a multi-file split-up of the original module.
Version 1.x.* is a one file implementation and not available in the history of
this repository. The latest 1.* version 1.1.7 can be found
here.
50 followers · starred Jan 2023
174 followers · starred Mar 2024
48 followers · starred Mar 2020
185 followers · starred May 2019