| mlr_optimizers_focus_search {bbotk} | R Documentation |
Optimization via Focus Search
Description
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.
Dictionary
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")
Parameters
n_pointsinteger(1)
Number of points to evaluate in each random search batch.maxitinteger(1)
Number of random search batches to run.
Progress Bars
$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").
Super classes
bbotk::Optimizer -> bbotk::OptimizerBatch -> OptimizerBatchFocusSearch
Methods
Public methods
Inherited methods
Method new()
Creates a new instance of this R6 class.
Usage
OptimizerBatchFocusSearch$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
OptimizerBatchFocusSearch$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
search_space = domain = ps(x = p_dbl(lower = -1, upper = 1))
codomain = ps(y = p_dbl(tags = "minimize"))
objective_function = function(xs) {
list(y = as.numeric(xs)^2)
}
objective = ObjectiveRFun$new(
fun = objective_function,
domain = domain,
codomain = codomain)
instance = OptimInstanceBatchSingleCrit$new(
objective = objective,
search_space = search_space,
terminator = trm("evals", n_evals = 10))
optimizer = opt("focus_search")
# modifies the instance by reference
optimizer$optimize(instance)
# returns best scoring evaluation
instance$result
# allows access of data.table of full path of all evaluations
as.data.table(instance$archive$data)