R interface to Python's GPopt.BOstopping. A Gaussian-Process-based Bayesian optimizer with built-in early stopping diagnostics (based on e.g. Wasserstein-distance convergence of the posterior on a fixed test set), useful when function evaluations are expensive and you want the search to stop automatically once it has converged.

BOstopping(
  f,
  bounds,
  n_init = 5L,
  kappa = 1.96,
  early_stopping = TRUE,
  stop_patience = 20L,
  stop_threshold = 0.01,
  n_test_points = 100L,
  alpha = 1e-06,
  n_restarts_optimizer = 25L,
  seed = 123L,
  venv_path = "./venv"
)

Arguments

f

an R function taking a single numeric vector `x` (1-indexed, as usual in R) and returning a single numeric value to be minimized

bounds

a numeric matrix (or list of length-2 numeric vectors) with one row `c(lower, upper)` per dimension, e.g. `rbind(c(-5, 10), c(0, 15))`

n_init

number of points in the initial design

kappa

exploration/exploitation trade-off parameter for the acquisition function

early_stopping

logical, whether to enable early stopping

stop_patience

number of iterations without sufficient improvement before stopping

stop_threshold

convergence threshold used by the early-stopping rule

n_test_points

number of points used to monitor convergence

alpha

numeric, GP regularization / noise parameter

n_restarts_optimizer

number of restarts of the GP's internal hyperparameter optimizer

seed

integer random seed

venv_path

path to the Python virtual environment created with `uv` (see the package README for setup instructions)

Value

A Python `GPopt.BOstopping` object, with `$optimize(n_iter = 100L)` as its main method (accessed with `$`).

Examples

if (FALSE) { # \dontrun{
branin <- function(x) {
  x1 <- x[1]; x2 <- x[2]
  term1 <- (x2 - (5.1 * x1^2) / (4 * pi^2) + (5 * x1) / pi - 6)^2
  term2 <- 10 * (1 - 1 / (8 * pi)) * cos(x1)
  term1 + term2 + 10
}

opt <- BOstopping(
  f = branin,
  bounds = rbind(c(-5, 10), c(0, 15)),
  venv_path = "./venv"
)
result <- opt$optimize(n_iter = 100L)
} # }