| mlr_optimizers_grid_search | R Documentation |
OptimizerBatchGridSearch class that implements grid search. The grid is
constructed as a Cartesian product over discretized values per parameter, see
paradox::generate_design_grid(). The points of the grid are evaluated in a
random order.
In order to support general termination criteria and parallelization, we
evaluate points in a batch-fashion of size batch_size. Larger batches mean
we can parallelize more, smaller batches imply a more fine-grained checking
of termination criteria.
This Optimizer can be instantiated via the dictionary
mlr_optimizers or with the associated sugar function opt():
mlr_optimizers$get("grid_search")
opt("grid_search")
resolutioninteger(1)
Resolution of the grid, see paradox::generate_design_grid().
param_resolutionsnamed integer()
Resolution per parameter, named by parameter ID, see
paradox::generate_design_grid().
batch_sizeinteger(1)
Maximum number of points to try in a batch.
$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 -> OptimizerBatchGridSearch
new()Creates a new instance of this R6 class.
OptimizerBatchGridSearch$new()
clone()The objects of this class are cloneable with this method.
OptimizerBatchGridSearch$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("grid_search", resolution = 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.