| mlr_optimizers_focus_search | R Documentation |
OptimizerBatchFocusSearch class that implements a Focus Search.
Focus Search starts with evaluating n_points drawn uniformly at random.
For 1 to maxit batches, n_points are then drawn uniformly at random and if the best value of a batch outperforms the previous best value over all batches evaluated so far, the search space is shrinked around this new best point prior to the next batch being sampled and evaluated.
For details on the shrinking, see shrink_ps.
Depending on the Terminator this procedure simply restarts after maxit is reached.
This Optimizer can be instantiated via the dictionary
mlr_optimizers or with the associated sugar function opt():
mlr_optimizers$get("focus_search")
opt("focus_search")
n_pointsinteger(1)
Number of points to evaluate in each random search batch.
maxitinteger(1)
Number of random search batches to run.
$optimize() supports progress bars via the package progressr
combined with a Terminator. Simply wrap the function in
progressr::with_progress() to enable them. We recommend to use package
progress as backend; enable with progressr::handlers("progress").
bbotk::Optimizer -> bbotk::OptimizerBatch -> OptimizerBatchFocusSearch
new()Creates a new instance of this R6 class.
OptimizerBatchFocusSearch$new()
clone()The objects of this class are cloneable with this method.
OptimizerBatchFocusSearch$clone(deep = FALSE)
deepWhether to make a deep clone.
# 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("focus_search", n_points = 10, maxit = 10)
# trigger optimization
optimizer$optimize(instance)
# all evaluated configurations
instance$archive
# best performing configuration
instance$result
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.