[BibTeX] cite as:
Nikolaus Hansen, Youhei Akimoto, and Petr Baudis. CMA-ES/pycma on Github. Zenodo, DOI:10.5281/zenodo.2559634, February 2019.
pycma
is a Python implementation of CMA-ES and a few related numerical optimization tools.
The Covariance Matrix Adaptation Evolution Strategy (CMA-ES) is a stochastic derivative-free numerical optimization algorithm for difficult (non-convex, ill-conditioned, multi-modal, rugged, noisy) optimization problems in continuous search spaces.
Useful links:
-
The above
notebooks
folder has some example code in Jupyter notebooks -
Hints for how to use this (kind of) optimization module in practice
Installation of the latest release
In a system shell, type
python -m pip install cma
to install the latest release from the Python Package Index (PyPI). The release link also provides more installation hints and a quick start guide.
conda install --channel cma-es cma
installs from the conda cloud channel cma-es
. CAVEAT: this distribution is currently not updated!
The quick way (this requires git
to be installed): to install the code from, for example, the master
branch, copy-paste
pip install git+https://github.com/CMA-ES/pycma.git@master
The long way:
-
get the package
- either download and unzip the code by clicking the green button above
- or, with
git
installed, typegit 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 typingpip install -e cma
in the folder where the
cma
package folder can be found. Moving thecma
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
.
-
- fix compatibility to
numpy
2.0 (thanks to Sait Cakmak) - improved interface to
noise_handler
argument which acceptsTrue
as value - improved interface to
ScaleCoordinates
now also with lower and upper value mapping to [0, 1], see issue #210 - changed:
'ftarget'
triggers with <= instead of < - assign
surrogate
attribute (for the record) when callingfmin_lq_surr
- various (minor) bug fixes
- various (small) improvements of the plots and their usability
- display iterations, evaluations and population size and termination criteria in the plots
- subtract any recorded x from the plotted x-values by
x_opt=index
- plots are now versus iteration number instead of evaluations by default
- provide legacy
bbobbenchmarks
without downloading - new:
CMADataLogger.zip
allows sharing plotting data more easily by a zip file - new:
tolxstagnation
termination condition for when the incumbent seems stuck - new: collect restart terminations in
cma.evalution_strategy.all_stoppings
- new:
stall_sigma_change_on_divergence_iterations
option to stallsigma
change when the median fitness is worsening - new: limit active C update for integer variables
- new: provide a COCO single function
- fix compatibility to
-
Release
3.3.0
implements- diagonal acceleration via diagonal decoding (option
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).- various smallish improvements, bug fixes and additional features and functions.
- diagonal acceleration via diagonal decoding (option
-
Release
3.2.2
fixes some smallish interface and logging bugs inConstrainedFitnessAL
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 optimizationConstrainedFitnessAL
andfmin_con2
and many other minor fixes and improvements. -
Release
3.1.0
fixes the return value offmin_con
, improves its usability and provides abest_feasible
attribute inCMAEvolutionStrategy
, in addition to various other more minor code fixes and improvements. -
Release
3.0.3
provides parallelization withOOOptimizer.optimize(..., n_jobs=...)
(fix for3.0.1/2
) and improvedpickle
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 ofCMAEvolutionStrategy
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 solutionx0
to be a callable. -
Version
2.4.2
added the functioncma.fmin2
which, similar tocma.purecma.fmin
, returns(x_best:numpy.ndarray, es:cma.CMAEvolutionStrategy)
instead of a 10-tuple likecma.fmin
. The result 10-tuple is accessible ines.result
:
namedtuple
. -
Version
2.4.1
includedbbob
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 latest1.*
version1.1.7
can be found here.