Table of Contents
Fetching ...

cmaes: A Simple yet Practical Python Library for CMA-ES

Masahiro Nomura, Masashi Shibata, Ryoki Hamano

TL;DR

This paper presents cmaes, a simple yet practical Python library implementing CMA-ES with a focus on readability and easy integration into real-world workflows. It combines core CMA-ES mechanics with modern enhancements—learning-rate adaptation (LRA-CMA), transfer learning (WS-CMA), mixed-variable handling (CMAwM/CatCMAwM), and multi-objective support (COMO-CatCMAwM)—through user-friendly APIs and an ask-and-tell interface. The authors also emphasize software quality through fuzz testing, animated visualizations, and real-world integration (e.g., Optuna), while acknowledging current limitations relative to larger libraries like pycma and COCO. Overall, cmaes aims to bridge theory and practice, offering practitioners a lightweight, extensible foundation for robust CMA-ES optimization across continuous, mixed, and multi-objective problems.

Abstract

The covariance matrix adaptation evolution strategy (CMA-ES) has been highly effective in black-box continuous optimization, as demonstrated by its success in both benchmark problems and various real-world applications. To address the need for an accessible and powerful tool in this domain, we developed cmaes, a simple and practical Python library for CMA-ES. cmaes is characterized by its simplicity, offering intuitive use and high code readability. This makes it suitable for quick use of CMA-ES, as well as for educational purposes and seamless integration into other libraries. Despite its simple design, cmaes maintains advanced functionality. It incorporates recent advancements in CMA-ES, such as learning rate adaptation for challenging scenarios, transfer learning, mixed-variable optimization, and multi-objective optimization capabilities. These advanced features are accessible through a user-friendly API, ensuring that cmaes can be easily adopted in practical applications. We present cmaes as a strong candidate for a practical Python CMA-ES library aimed at practitioners. The software is available under the MIT license at https://github.com/CyberAgentAILab/cmaes.

cmaes: A Simple yet Practical Python Library for CMA-ES

TL;DR

This paper presents cmaes, a simple yet practical Python library implementing CMA-ES with a focus on readability and easy integration into real-world workflows. It combines core CMA-ES mechanics with modern enhancements—learning-rate adaptation (LRA-CMA), transfer learning (WS-CMA), mixed-variable handling (CMAwM/CatCMAwM), and multi-objective support (COMO-CatCMAwM)—through user-friendly APIs and an ask-and-tell interface. The authors also emphasize software quality through fuzz testing, animated visualizations, and real-world integration (e.g., Optuna), while acknowledging current limitations relative to larger libraries like pycma and COCO. Overall, cmaes aims to bridge theory and practice, offering practitioners a lightweight, extensible foundation for robust CMA-ES optimization across continuous, mixed, and multi-objective problems.

Abstract

The covariance matrix adaptation evolution strategy (CMA-ES) has been highly effective in black-box continuous optimization, as demonstrated by its success in both benchmark problems and various real-world applications. To address the need for an accessible and powerful tool in this domain, we developed cmaes, a simple and practical Python library for CMA-ES. cmaes is characterized by its simplicity, offering intuitive use and high code readability. This makes it suitable for quick use of CMA-ES, as well as for educational purposes and seamless integration into other libraries. Despite its simple design, cmaes maintains advanced functionality. It incorporates recent advancements in CMA-ES, such as learning rate adaptation for challenging scenarios, transfer learning, mixed-variable optimization, and multi-objective optimization capabilities. These advanced features are accessible through a user-friendly API, ensuring that cmaes can be easily adopted in practical applications. We present cmaes as a strong candidate for a practical Python CMA-ES library aimed at practitioners. The software is available under the MIT license at https://github.com/CyberAgentAILab/cmaes.
Paper Structure (32 sections, 4 equations, 8 figures)

This paper contains 32 sections, 4 equations, 8 figures.

Figures (8)

  • Figure 1: Example of CMA-ES optimizing $f(x) = f_{\rm Ellipsoid}(R x)$, where $f_{\rm Ellipsoid}(x) = x_1^2 + (10 x_2)^2$ and $R \in \mathbb{R}^{2 \times 2}$ is a rotation matrix rotating $\pi / 6$ around the origin. Population size $\lambda = 15$ and the initial distribution $m^{(0)} = [1.0, 1.0], \sigma^{(0)} = 1.0, C^{(0)} = I$. Ellipse represents the distribution of CMA-ES and the red points represent the sampled solutions. CMA-ES efficiently addresses ill-conditioned and non-separable problems by adapting the distribution parameters.
  • Figure 2: Output example of animated visualization. (Left) Contour lines and sampled solutions. (Right) Multivariate Gaussian distribution in CMA-ES.
  • Figure 3: Comparison of the serialization size for the CMA-ES objects after one generation using pickle in pycma and cmaes.
  • Figure 4: Comparison between vanilla CMA-ES and LRA-CMA on the 40-D Rastrigin function. Initial distribution is $m^{(0} = [3.0, \ldots, 3.0], \sigma^{(0)} = 2.0, C^{(0)} = I$. Population size is set as the recommended value, i.e., $\lambda = 4 + \lfloor 3 \log (d) \rfloor = 15$. Vanilla CMA-ES gets trapped in local optima, whereas LRA-CMA succeeds in finding global optima without any hyperparameter tuning.
  • Figure 5: Visualizations of function landscape. In noisy problems, although function value of each point is technically random variable, it can be treated as scalar value from optimizer's perspective in continuous space.
  • ...and 3 more figures