PyBADS: Fast and robust black-box optimization in Python

Gurjeet Sangra Singh, Luigi AcerbiJ. Open Source Softw 2024 · DBLP

Abstract

PyBADS is a Python library implementing the Bayesian Adaptive Direct Search (BADS) algorithm. It is designed for "mildly expensive" black-box functions where gradients are unavailable and evaluations take 0.1 to several seconds. By hybridizing Bayesian Optimization with Mesh Adaptive Direct Search, PyBADS achieves high sample efficiency while maintaining the robustness of direct-search methods.

Introduction

In scientific research, particularly in fields like neuroscience and robotics, investigators frequently encounter "black-box" optimization problems. These are scenarios where the internal mechanics of a function are unknown, gradient information is unavailable, and evaluations are computationally "mildly expensive"—taking anywhere from 0.1 to several seconds. Traditional methods often struggle here: direct-search algorithms like Mesh Adaptive Direct Search (MADS) are robust but sample-inefficient, while Bayesian Optimization (BO) is efficient but can be brittle if the underlying surrogate model is misspecified.

PyBADS addresses this gap by providing a robust, "off-the-shelf" optimizer that balances the speed of model-based search with the reliability of grid-based polling.

Methodology: The Hybrid Framework

The core of PyBADS is its ability to alternate between two distinct phases to ensure both speed and reliability.

The Poll Stage (Model-Free)

Based on the MADS framework, the Poll Stage performs a systematic search on a mesh grid around the current best point. This stage does not rely on statistical assumptions, serving as a "fail-safe" mechanism. If complex models fail to provide a better estimate, the Poll Stage ensures the optimizer continues to make progress.

The Search Stage (Model-Based)

The Search Stage utilizes Bayesian Optimization by fitting a Gaussian Process (GP) surrogate model to previously evaluated points. It employs an acquisition function (typically the Lower Confidence Bound) to predict the location of the global minimum. This allows the algorithm to take "big jumps" across the parameter space, significantly reducing the number of evaluations needed compared to pure direct search.

The hybrid optimization process in PyBADS, showing the local refinement of the POLL stage versus the global exploration of the SEARCH stage.

The algorithm includes a fail-safe mechanism: if the Search Stage fails to find an improvement due to an inaccurate GP model, the system automatically reverts to the reliable Poll Stage. Furthermore, PyBADS natively handles heteroskedastic noise—situations where the objective function's variance changes depending on the input coordinates.

Performance and Applications

PyBADS is designed to work "out of the box" with sensible defaults for most scientific problems. It has been extensively tested on artificial benchmarks like the Rosenbrock function and real-world model-fitting problems in cognitive and computational neuroscience.

Key performance characteristics include:

  • Efficiency: Reaches solutions within a few hundred function evaluations, making it significantly faster than traditional direct-search methods.
  • Scalability: Effectively handles problems with up to 20 continuous input parameters.
  • Robustness: Outperforms standard gradient-based or pure BO methods on non-smooth or "rough" objective functions where stochasticity might otherwise lead to failure.

Conclusion

PyBADS provides a robust, efficient solution for researchers dealing with mildly expensive black-box functions. By bridging the gap between sample-efficient Bayesian models and reliable direct-search grids, it offers a versatile tool for model-fitting and optimization in the experimental sciences. Future work suggests its utility as an initialization tool for more complex uncertainty quantification methods, such as those found in the PyVBMC library.

Summary updated

BibTeX
@article{singh2024pybads,
  author = {Gurjeet Sangra Singh and Luigi Acerbi},
  title = {{PyBADS: Fast and robust black-box optimization in Python}},
  journal = {J. Open Source Softw.},
  year = {2024},
  doi = {10.21105/joss.05694},
}
Figure