Learn R Programming

bbotk (version 1.5.0)

mlr_optimizers_local_search: Optimization via Local Search

Description

OptimizerBatchLocalSearch class that implements a simple Local Search. Local Search starts by determining the n_initial_points initial best points present in the Archive of the OptimInstance. If fewer points than n_initial_points are present, additional initial_random_sample_size points sampled uniformly at random are evaluated and the best n_initial_points initial points are determined.

In each iteration, for each of the n_initial_points initial best points, neighbors_per_point neighbors are generated by local mutation. Local mutation generates a neighbor by sampling a single parameter that is to be mutated and then proceeds as follows: Double parameters (paradox::p_dbl()) are mutated via Gaussian mutation (with a prior standardization to [0, 1] and retransformation after mutation). Integer parameters (paradox::p_int()) undergo the same mutation but are rounded to the closest integer after mutation. Categorical parameters (paradox::p_fct() and paradox::p_lgl()) are mutated via uniform mutation. Note that parameters that are conditioned on (i.e., they are parents of a paradox::Condition, see the dependencies of the search space) are not mutated.

Arguments

Dictionary

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

mlr_optimizers$get("local_search")
opt("local_search")

Parameters

n_initial_points

integer(1)
Size of the set of initial best points which are used as starting points for the Local Search. Default is 10.

initial_random_sample_size

integer(1)
Number of points that are sampled uniformly at random before the best n_initial_points initial points are determined, if fewer points than n_initial_points are present in the Archive of the OptimInstance. Default is 100.

neighbors_per_point

integer(1)
Number of neighboring points to generate for each of the n_initial_points best starting points in each iteration. Default is 100.

mutation_sd

numeric(1)
Standard deviation used to create neighbors during mutation of numeric parameters on the standardized [0, 1] scale. Default is 0.1.

Archive

The Archive holds the following additional column that is specific to the algorithm:

  • .point_id (integer(1))
    The id (1, ..., n_initial_points) indicating from which of the n_initial_points best points the evaluated point was generated from.

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 -> OptimizerBatchLocalSearch

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage

OptimizerBatchLocalSearch$new()


Method clone()

The objects of this class are cloneable with this method.

Usage

OptimizerBatchLocalSearch$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

Run this code
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 = 100))

# evaluate an initial sample of 10 points uniformly at random
# choose the best 3 points as the initial points
# for each of these points generate 10 neighbors
# repeat this process
optimizer = opt("local_search",
  n_initial_points = 3,
  initial_random_sample_size = 10,
  neighbors_per_point = 10)

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

Run the code above in your browser using DataLab