Asynchronous Optimization via Grid Search
Source:R/OptimizerAsyncGridSearch.R
mlr_optimizers_async_grid_search.RdOptimizerAsyncGridSearch class that implements a 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.
Source
Bergstra J, Bengio Y (2012). “Random Search for Hyper-Parameter Optimization.” Journal of Machine Learning Research, 13(10), 281–305. https://jmlr.csail.mit.edu/papers/v13/bergstra12a.html.
Dictionary
This Optimizer can be instantiated via the dictionary
mlr_optimizers or with the associated sugar function opt():
Super classes
Optimizer -> OptimizerAsync -> OptimizerAsyncGridSearch
Methods
Inherited methods
OptimizerAsyncGridSearch$new()
Creates a new instance of this R6 class.
Usage
OptimizerAsyncGridSearch$new()Examples
# example only runs if a Redis server is available
if (mlr3misc::require_namespaces(c("rush", "redux", "mirai"), quietly = TRUE) &&
redux::redis_available()) {
# 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"
)
# start workers
rush::rush_plan(worker_type = "mirai")
mirai::daemons(1)
# initialize instance
instance = oi_async(
objective = objective,
terminator = trm("evals", n_evals = 20)
)
# load optimizer
optimizer = opt("async_grid_search", resolution = 10)
# trigger optimization
optimizer$optimize(instance)
# all evaluated configurations
instance$archive
# best performing configuration
instance$archive$best()
# covert to data.table
as.data.table(instance$archive)
}
#> ERROR [09:28:38.178] [rush] Lost worker 'sinking_raccoon_f7b79af3': Error in !self$is_terminated && self$archive$n_queued_available: invalid 'y' type in 'x && y'
#> Error: Optimization terminated without any finished evaluations.