mlr_optimizers_focus_search: Optimization via Focus Search

mlr_optimizers_focus_searchR Documentation

Optimization via Focus Search

Description

OptimizerFocusSearch 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_points

integer(1)
Number of points to evaluate in each random search batch.

maxit

integer(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 class

bbotk::Optimizer -> OptimizerFocusSearch

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of this R6 class.

Usage
OptimizerFocusSearch$new()

Method clone()

The objects of this class are cloneable with this method.

Usage
OptimizerFocusSearch$clone(deep = FALSE)
Arguments
deep

Whether 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 = OptimInstanceSingleCrit$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)

bbotk documentation built on Nov. 13, 2023, 5:06 p.m.