StageOpt is an algorithm for optimizing black-box functions based on SafeOpt. It divides the optimization process into two stages: safe region expansion and utility function maximization, thereby satisfying safety constraints while approximating the optimal point.
This repository provides an implementation of the StageOpt algorithm proposed in the following paper:
Stagewise Safe Bayesian Optimization with Gaussian Processes
Yanan Sui, Vincent Zhuang, Joel Burdick, Yisong Yue
International Conference on Machine Learning (ICML), 2018
PDF

The safe set (green bar), expanders (blue bar).
Python = 3.13
pip install -r requirements.txt && pip install -e .To get started, it is recommended to run the interactive notebooks in the examples folder. We provide 1-d and 2-d examples for the algorithm.
An example for 1-d:
import torch
from stageopt import StageOpt
# Initialization
candidates = torch.linspace(0, 10, 100).unsqueeze(-1)
bounds = torch.tensor([[0.], [10.]])
train_X = candidates[[40, 70]]
train_Y = torch.tensor([[1.0, 0.3], [1.5, 0.8]]) # [objective, constraint]
fmin = torch.tensor([0.2])
lipschitz = torch.tensor([0.5])
algo = StageOpt(
candidates=candidates,
bounds=bounds,
train_X=train_X,
train_Y=train_Y,
num_objectives=1,
num_constraints=1,
fmin=fmin,
switch_time=10,
lipschitz=lipschitz,
covar_module=None, # Use default RBF kernel
ci_beta=2.0,
enable_fit=False,
)
# Optimization
for _ in range(20):
x_next = algo.next()
if x_next is None: break
y_next = your_function(x_next) # Return [objective, constraint]
algo.update(x_next, y_next)@InProceedings{pmlr-v80-sui18a,
title={Stagewise Safe {B}ayesian Optimization with {G}aussian Processes},
author={Sui, Yanan and Zhuang, Vincent and Burdick, Joel and Yue, Yisong},
booktitle={Proceedings of the 35th International Conference on Machine Learning},
year={2018}
}