BO with Binary Black-box Constraint
- Contributors: Fanjin Wang
- Last updated: Jan 26, 2025
- BoTorch version: 0.12.1.dev91+g0df552162.d20250124
In this notebook, we show how to implement BO under unknown constraints learned from a classification model trained together with a GP.
To add some context, the recommendations presented by BO to assist laboratory experiments may lead to undesired experiment results, such as failures or infeasible protocols [1]. And in these cases, the underlying feasible region can only be obtained through experimentation. In such cases, these unknown constraints can be treated as an unknown variable modeled by a surrogate classification model. Note that this setting, in which we only obtain binary information about whether or not a proposed candidate is feasible or not, is different from the setting in which we observe numerical values of an outcome that is subject to some constraint.
The present code is also inspired by the implementation in [2].
Set dtype and device
import torch
tkwargs = {
"dtype": torch.double,
"device": torch.device("cuda:0" if torch.cuda.is_available() else "cpu"),
}
Problem setup
We begin with setting up a classical synthetic problem Townsend
presented in [3]. The
objective to be maximized is:
Subjected to the constraint :
where