library("paradox")
library("bbotk")
# silly example function: minimize x^2 for -1 < x < 1
domain <- ps(x = p_dbl(lower = -1, upper = 1))
codomain <- ps(y = p_dbl(tags = "minimize"))
objective <- ObjectiveRFun$new(function(xs) list(y = xs$x^2), domain, codomain)
# initialize instance
instance <- OptimInstanceSingleCrit$new(objective, domain, trm("evals", n_evals = 6))
# use intermbo optimizer
#
# Also warn on surrogate model errors
# (this is the default and can be omitted)
optser <- opt("intermbo", on.surrogate.error = "warn")
# optimizer has hyperparameters from mlrMBO
optser$param_set$values$final.method <- "best.predicted"
# optimization happens here.
optser$optimize(instance)
instance$result
Run the code above in your browser using DataLab