CMA-ES for Safe Optimization

Kento Uchida, Ryoki Hamano, Masahiro Nomura, Shota Saito, Shinichi Shirakawa · DOI

Abstract

In many real-world optimization scenarios, evaluating a candidate solution that violates safety constraints can lead to catastrophic failure. While Evolutionary Algorithms (EAs) like the Covariance Matrix Adaptation Evolution Strategy (CMA-ES) are highly effective for global optimization, they often lack the mechanisms to guarantee safety during the search process. This paper introduces Safe CMA-ES, an algorithm that integrates Gaussian Process-based safety modeling with the CMA-ES framework. By utilizing transformed Lipschitz estimation and a sample projection mechanism, Safe CMA-ES maintains safety throughout the optimization process while preserving the efficiency of the underlying search strategy.

Introduction

Optimization in engineering and medical domains frequently involves "black-box" functions where the cost of failure is high. For instance, tuning a drone's flight controller or optimizing a patient's treatment plan requires finding an optimal configuration without ever testing a parameter set that causes a crash or adverse health event. This challenge is known as safe optimization.

Existing solutions generally fall into two categories: Bayesian methods (e.g., SafeOpt) and Evolutionary Algorithms. Bayesian methods provide strong safety guarantees but often struggle with high-dimensional spaces or complex landscapes. Conversely, EAs are robust global optimizers but typically rely on simple penalty functions that do not prevent unsafe evaluations. Safe CMA-ES bridges this gap by incorporating a safety "repair" mechanism into the CMA-ES framework, ensuring that every evaluated point is likely to be safe.

Methodology

The core innovation of Safe CMA-ES is a repair mechanism that intercepts and modifies unsafe samples before they are evaluated by the objective function. This mechanism relies on four primary components:

1. Transformed Lipschitz Estimation

The algorithm assumes that safety functions are Lipschitz continuous, meaning there is a limit to how fast the function can change. To maintain the affine invariance of CMA-ES—its ability to handle skewed and rotated landscapes—the safety functions are modeled using Gaussian Process Regression (GPR) within a transformed search space. This transformation aligns the safety model with the current shape of the CMA-ES distribution.

2. Dynamic Safe Region Construction

Using the estimated Lipschitz constants (the "speed limit" of the safety function), the algorithm defines a "safe region" around previously evaluated safe points. This region represents the area where the safety function is predicted to remain within acceptable bounds.

3. Sample Projection

When CMA-ES generates a candidate sample that falls outside the estimated safe region, the algorithm does not discard it. Instead, it projects the sample to the nearest point on the boundary of the safe region using the Mahalanobis distance. This ensures the optimizer stays as close as possible to its intended trajectory while respecting safety constraints.

4. Adaptive Correction

To account for potential inaccuracies in the GPR model, Safe CMA-ES employs adaptive correction factors ($\tau$ and $\rho$). These factors automatically tighten the safety constraints if the algorithm encounters an unsafe point or if the local density of training data is low, providing a self-correcting "safety belt."

Experimental Evaluation

The performance of Safe CMA-ES was evaluated using standard continuous optimization benchmarks modified with safety constraints:

  • Sphere Function: A basic convex problem.
  • Ellipsoid & Reversed Ellipsoid: Functions with highly skewed landscapes to test coordinate adaptation.
  • Rosenbrock Function: A non-convex "banana-shaped" valley problem.

Tests were conducted in both 5-dimensional and 20-dimensional settings to assess the scalability of the safety mechanisms.

Results and Discussion

The experimental results demonstrate that Safe CMA-ES effectively balances exploration and safety:

  • Safety Reliability: In 5D benchmarks, Safe CMA-ES avoided unsafe evaluations in over 75% of trials. In 20D settings, the median number of unsafe evaluations was exactly zero for several difficult functions, including the Reversed Ellipsoid.
  • Efficiency and Scalability: Unlike grid-based Bayesian methods like SafeOpt, which suffer from exponential computational growth in higher dimensions, Safe CMA-ES remains computationally efficient. It outperformed swarm-based safe optimizers on complex landscapes due to its superior landscape estimation.
  • Importance of Invariance: The results confirm that calculating the Lipschitz constant in the transformed space is vital for the algorithm's success, allowing the safety mechanism to scale and rotate alongside the search distribution.

Limitations and Future Work

While Safe CMA-ES represents a significant advancement, it relies on the assumption of smoothness (Lipschitz continuity) in the safety function. Discontinuous "cliff-edge" safety boundaries remain a challenge for future iterations. Additionally, the algorithm requires a set of initial "safe seeds" to begin the search, which may be difficult to obtain in highly restricted environments. Future research will focus on testing the algorithm on physical hardware, such as robotics and chemical process control, to validate its real-world applicability.

Conclusion

Safe CMA-ES provides a robust framework for global optimization under strict safety constraints. By merging the adaptive search capabilities of CMA-ES with a sophisticated GPR-based safety repair mechanism, the algorithm offers a scalable solution for high-dimensional safe optimization problems where failure is not an option.

Summary updated

BibTeX
@inproceedings{uchida2024cma,
  author = {Kento Uchida and Ryoki Hamano and Masahiro Nomura and Shota Saito and Shinichi Shirakawa},
  title = {{CMA-ES for Safe Optimization}},
  booktitle = {GECCO},
  year = {2024},
  doi = {10.1145/3638529.3654193},
}
Figure