Learn R Programming

bbotk (version 1.7.1)

mlr_optimizers_async_random_search: Asynchronous Optimization via Random Search

Description

OptimizerAsyncRandomSearch class that implements a simple Random Search.

Arguments

Dictionary

This Optimizer can be instantiated via the dictionary mlr_optimizers or with the associated sugar function opt():

mlr_optimizers$get("async_random_search")
opt("async_random_search")

Super classes

bbotk::Optimizer -> bbotk::OptimizerAsync -> OptimizerAsyncRandomSearch

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage

OptimizerAsyncRandomSearch$new()


Method clone()

The objects of this class are cloneable with this method.

Usage

OptimizerAsyncRandomSearch$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

Run this code
# 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 = "remote")
mirai::daemons(1)

# initialize instance
instance = oi_async(
  objective = objective,
  terminator = trm("evals", n_evals = 20)
)

# load optimizer
optimizer = opt("async_random_search")

# 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)
}

Run the code above in your browser using DataLab