Skip to contents

Package website: release | dev

bbotk is a black-box optimization framework for R. It features highly configurable search spaces via the paradox package and optimizes every user-defined objective function. The package includes several optimization algorithms e.g. Random Search, Grid Search, Iterated Racing, Bayesian Optimization (in mlr3mbo) and Hyperband (in mlr3hyperband). bbotk is the base package of mlr3tuning, mlr3fselect and miesmuschel.

Resources

There are several sections about black-box optimization in the mlr3book. Often the sections about tuning are also relevant for general black-box optimization.

Installation

Install the latest release from CRAN.

Install the development version from GitHub.

pak::pkg_install("mlr-org/bbotk")

Example

# define the objective function
fun = function(xs) {
  list(y = - (xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10)
}

# set domain
domain = ps(
  x1 = p_dbl(-10, 10),
  x2 = p_dbl(-5, 5)
)

# set codomain
codomain = ps(
  y = p_dbl(tags = "maximize")
)

# create objective
objective = ObjectiveRFun$new(
  fun = fun,
  domain = domain,
  codomain = codomain,
  properties = "deterministic"
)

# initialize instance
instance = oi(
  objective = objective,
  terminator = trm("evals", n_evals = 20)
)

# load optimizer
optimizer = opt("gensa")

# trigger optimization
optimizer$optimize(instance)
##    x1 x2  x_domain  y
## 1:  2 -3 <list[2]> 10
# best performing configuration
instance$result
##    x1 x2  x_domain  y
## 1:  2 -3 <list[2]> 10
# all evaluated configuration
as.data.table(instance$archive)
##            x1        x2          y           timestamp batch_nr x_domain_x1 x_domain_x2
##  1: -4.689827 -1.278761 -37.716445 2026-07-14 17:06:25        1   -4.689827   -1.278761
##  2: -5.930364 -4.400474 -54.851999 2026-07-14 17:06:25        2   -5.930364   -4.400474
##  3:  7.170817 -1.519948 -18.927907 2026-07-14 17:06:25        3    7.170817   -1.519948
##  4:  2.045200 -1.519948   7.807403 2026-07-14 17:06:25        4    2.045200   -1.519948
##  5:  2.045200 -2.064742   9.123250 2026-07-14 17:06:25        5    2.045200   -2.064742
## ---                                                                                    
## 16:  2.000000 -3.000000  10.000000 2026-07-14 17:06:26       16    2.000000   -3.000000
## 17:  2.000001 -3.000000  10.000000 2026-07-14 17:06:26       17    2.000001   -3.000000
## 18:  1.999999 -3.000000  10.000000 2026-07-14 17:06:26       18    1.999999   -3.000000
## 19:  2.000000 -2.999999  10.000000 2026-07-14 17:06:26       19    2.000000   -2.999999
## 20:  2.000000 -3.000001  10.000000 2026-07-14 17:06:26       20    2.000000   -3.000001

Citation

If you use bbotk in your work, please cite it.

Becker M, Richter J, Lang M, Bischl B, Binder M (2026). bbotk: Black-Box Optimization Toolkit. doi:10.5281/zenodo.20669808, https://doi.org/10.5281/zenodo.20669808.

@Manual{becker2026bbotk,
  title = {bbotk: Black-Box Optimization Toolkit},
  url = {https://doi.org/10.5281/zenodo.20669808},
  author = {Marc Becker and Jakob Richter and Michel Lang and Bernd Bischl and Martin Binder},
  year = {2026},
  doi = {10.5281/zenodo.20669808},
}