BayesianOptimization icon indicating copy to clipboard operation
BayesianOptimization copied to clipboard

add alternative termination criteria

Open cballam opened this issue 3 months ago • 2 comments

This is a WIP attempt to satisfy some of the goals in this issue thread about adding alternative (not just iteration based) termination criteria for the optimizer: https://github.com/bayesian-optimization/BayesianOptimization/issues/381

New termination criteria are:

  • value of the user-defined function
  • time taken to run the full optimization process
  • absolute tolerance of the improvement in function value

I've added tests to make sure these are functional. The "time taken" one is challenging as this depends on the user's machine (the old "it works on my machine" excuse), but is empirically accurate to within about 200ms for low complexity target/acquisition functions

Open to any criticism/suggestions here, I am sure the code could be improved but am not sure on the best way to go about it.

Summary by CodeRabbit

  • New Features
    • Added configurable termination criteria to optimization, including max iterations, target value threshold, time limit, and convergence tolerance.
    • Optimization now stops automatically when any configured criterion is met.
    • Termination settings and progress are preserved when saving/loading state, enabling resumable runs.
  • Tests
    • Added comprehensive tests covering iteration-, value-, time-, and convergence-based termination scenarios.
  • Documentation
    • Clarified usage of iteration parameters when termination criteria are not provided.

cballam avatar Sep 27 '25 08:09 cballam