Skip to contents

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.

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.


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

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)
#>               x  x_domain            y
#>           <num>    <list>        <num>
#> 1: -0.001513127 <list[1]> 2.289553e-06

# returns best scoring evaluation
instance$result
#>               x  x_domain            y
#>           <num>    <list>        <num>
#> 1: -0.001513127 <list[1]> 2.289553e-06

# allows access of data.table of full path of all evaluations
as.data.table(instance$archive$data)
#>                 x            y  x_domain           timestamp batch_nr .point_id
#>             <num>        <num>    <list>              <POSc>    <int>     <int>
#>   1: -0.159742753 2.551775e-02 <list[1]> 2024-11-08 08:28:06        1        NA
#>   2: -0.282035319 7.954392e-02 <list[1]> 2024-11-08 08:28:06        1        NA
#>   3:  0.360471830 1.299399e-01 <list[1]> 2024-11-08 08:28:06        1        NA
#>   4: -0.573702628 3.291347e-01 <list[1]> 2024-11-08 08:28:06        1        NA
#>   5: -0.018821961 3.542662e-04 <list[1]> 2024-11-08 08:28:06        1        NA
#>   6:  0.926881443 8.591092e-01 <list[1]> 2024-11-08 08:28:06        1        NA
#>   7:  0.893151477 7.977196e-01 <list[1]> 2024-11-08 08:28:06        1        NA
#>   8: -0.896230842 8.032297e-01 <list[1]> 2024-11-08 08:28:06        1        NA
#>   9: -0.409851406 1.679782e-01 <list[1]> 2024-11-08 08:28:06        1        NA
#>  10:  0.248380058 6.169265e-02 <list[1]> 2024-11-08 08:28:06        1        NA
#>  11:  0.044367130 1.968442e-03 <list[1]> 2024-11-08 08:28:06        2         1
#>  12: -0.001513127 2.289553e-06 <list[1]> 2024-11-08 08:28:06        2         1
#>  13: -0.127162798 1.617038e-02 <list[1]> 2024-11-08 08:28:06        2         1
#>  14: -0.022984094 5.282686e-04 <list[1]> 2024-11-08 08:28:06        2         1
#>  15: -0.398864827 1.590932e-01 <list[1]> 2024-11-08 08:28:06        2         1
#>  16: -0.046068272 2.122286e-03 <list[1]> 2024-11-08 08:28:06        2         1
#>  17:  0.342370982 1.172179e-01 <list[1]> 2024-11-08 08:28:06        2         1
#>  18:  0.272922608 7.448675e-02 <list[1]> 2024-11-08 08:28:06        2         1
#>  19: -0.429658091 1.846061e-01 <list[1]> 2024-11-08 08:28:06        2         1
#>  20: -0.035604171 1.267657e-03 <list[1]> 2024-11-08 08:28:06        2         1
#>  21: -0.069783331 4.869713e-03 <list[1]> 2024-11-08 08:28:06        2         2
#>  22: -0.363784264 1.323390e-01 <list[1]> 2024-11-08 08:28:06        2         2
#>  23: -0.011159547 1.245355e-04 <list[1]> 2024-11-08 08:28:06        2         2
#>  24:  0.029740669 8.845074e-04 <list[1]> 2024-11-08 08:28:06        2         2
#>  25: -0.187991993 3.534099e-02 <list[1]> 2024-11-08 08:28:06        2         2
#>  26: -0.074284940 5.518252e-03 <list[1]> 2024-11-08 08:28:06        2         2
#>  27: -0.692471195 4.795164e-01 <list[1]> 2024-11-08 08:28:06        2         2
#>  28: -0.239601261 5.740876e-02 <list[1]> 2024-11-08 08:28:06        2         2
#>  29:  0.077985842 6.081791e-03 <list[1]> 2024-11-08 08:28:06        2         2
#>  30: -0.140295110 1.968272e-02 <list[1]> 2024-11-08 08:28:06        2         2
#>  31:  0.030410879 9.248216e-04 <list[1]> 2024-11-08 08:28:06        2         3
#>  32:  0.308999637 9.548078e-02 <list[1]> 2024-11-08 08:28:06        2         3
#>  33:  0.435351301 1.895308e-01 <list[1]> 2024-11-08 08:28:06        2         3
#>  34:  0.457006694 2.088551e-01 <list[1]> 2024-11-08 08:28:06        2         3
#>  35:  0.045621198 2.081294e-03 <list[1]> 2024-11-08 08:28:06        2         3
#>  36:  0.343133166 1.177404e-01 <list[1]> 2024-11-08 08:28:06        2         3
#>  37:  0.099376008 9.875591e-03 <list[1]> 2024-11-08 08:28:06        2         3
#>  38:  0.296414382 8.786149e-02 <list[1]> 2024-11-08 08:28:06        2         3
#>  39:  0.130223904 1.695827e-02 <list[1]> 2024-11-08 08:28:06        2         3
#>  40:  0.204822816 4.195239e-02 <list[1]> 2024-11-08 08:28:06        2         3
#>  41: -0.142292139 2.024705e-02 <list[1]> 2024-11-08 08:28:06        3         1
#>  42:  0.080505567 6.481146e-03 <list[1]> 2024-11-08 08:28:06        3         1
#>  43:  0.379181819 1.437789e-01 <list[1]> 2024-11-08 08:28:06        3         1
#>  44:  0.372006467 1.383888e-01 <list[1]> 2024-11-08 08:28:06        3         1
#>  45:  0.165140076 2.727124e-02 <list[1]> 2024-11-08 08:28:06        3         1
#>  46:  0.033959116 1.153222e-03 <list[1]> 2024-11-08 08:28:06        3         1
#>  47:  0.084342708 7.113692e-03 <list[1]> 2024-11-08 08:28:06        3         1
#>  48: -0.245305539 6.017481e-02 <list[1]> 2024-11-08 08:28:06        3         1
#>  49: -0.172299939 2.968727e-02 <list[1]> 2024-11-08 08:28:06        3         1
#>  50: -0.163614478 2.676970e-02 <list[1]> 2024-11-08 08:28:06        3         1
#>  51:  0.033185269 1.101262e-03 <list[1]> 2024-11-08 08:28:06        3         2
#>  52: -0.267968019 7.180686e-02 <list[1]> 2024-11-08 08:28:06        3         2
#>  53:  0.111418436 1.241407e-02 <list[1]> 2024-11-08 08:28:06        3         2
#>  54: -0.079518051 6.323120e-03 <list[1]> 2024-11-08 08:28:06        3         2
#>  55:  0.099788630 9.957771e-03 <list[1]> 2024-11-08 08:28:06        3         2
#>  56: -0.260609203 6.791716e-02 <list[1]> 2024-11-08 08:28:06        3         2
#>  57:  0.349606121 1.222244e-01 <list[1]> 2024-11-08 08:28:06        3         2
#>  58: -0.162403385 2.637486e-02 <list[1]> 2024-11-08 08:28:06        3         2
#>  59:  0.130694906 1.708116e-02 <list[1]> 2024-11-08 08:28:06        3         2
#>  60:  0.010103175 1.020742e-04 <list[1]> 2024-11-08 08:28:06        3         2
#>  61:  0.153005961 2.341082e-02 <list[1]> 2024-11-08 08:28:06        3         3
#>  62:  0.373244179 1.393112e-01 <list[1]> 2024-11-08 08:28:06        3         3
#>  63: -0.235554463 5.548591e-02 <list[1]> 2024-11-08 08:28:06        3         3
#>  64:  0.044022126 1.937948e-03 <list[1]> 2024-11-08 08:28:06        3         3
#>  65: -0.214623212 4.606312e-02 <list[1]> 2024-11-08 08:28:06        3         3
#>  66: -0.069237414 4.793819e-03 <list[1]> 2024-11-08 08:28:06        3         3
#>  67:  0.400363140 1.602906e-01 <list[1]> 2024-11-08 08:28:06        3         3
#>  68: -0.046393243 2.152333e-03 <list[1]> 2024-11-08 08:28:06        3         3
#>  69: -0.229867543 5.283909e-02 <list[1]> 2024-11-08 08:28:06        3         3
#>  70:  0.056793802 3.225536e-03 <list[1]> 2024-11-08 08:28:06        3         3
#>  71: -0.430078169 1.849672e-01 <list[1]> 2024-11-08 08:28:06        4         1
#>  72:  0.158457044 2.510863e-02 <list[1]> 2024-11-08 08:28:06        4         1
#>  73:  0.036005937 1.296427e-03 <list[1]> 2024-11-08 08:28:06        4         1
#>  74: -0.024618599 6.060754e-04 <list[1]> 2024-11-08 08:28:06        4         1
#>  75:  0.083562841 6.982748e-03 <list[1]> 2024-11-08 08:28:06        4         1
#>  76: -0.235123790 5.528320e-02 <list[1]> 2024-11-08 08:28:06        4         1
#>  77:  0.137688515 1.895813e-02 <list[1]> 2024-11-08 08:28:06        4         1
#>  78: -0.302569192 9.154812e-02 <list[1]> 2024-11-08 08:28:06        4         1
#>  79:  0.120793137 1.459098e-02 <list[1]> 2024-11-08 08:28:06        4         1
#>  80: -0.159037421 2.529290e-02 <list[1]> 2024-11-08 08:28:06        4         1
#>  81:  0.016831489 2.832990e-04 <list[1]> 2024-11-08 08:28:06        4         2
#>  82: -0.183462202 3.365838e-02 <list[1]> 2024-11-08 08:28:06        4         2
#>  83:  0.014621865 2.137989e-04 <list[1]> 2024-11-08 08:28:06        4         2
#>  84:  0.111163605 1.235735e-02 <list[1]> 2024-11-08 08:28:06        4         2
#>  85:  0.050326959 2.532803e-03 <list[1]> 2024-11-08 08:28:06        4         2
#>  86: -0.017896682 3.202912e-04 <list[1]> 2024-11-08 08:28:06        4         2
#>  87: -0.500897760 2.508986e-01 <list[1]> 2024-11-08 08:28:06        4         2
#>  88:  0.384285475 1.476753e-01 <list[1]> 2024-11-08 08:28:06        4         2
#>  89:  0.063974974 4.092797e-03 <list[1]> 2024-11-08 08:28:06        4         2
#>  90:  0.396718366 1.573855e-01 <list[1]> 2024-11-08 08:28:06        4         2
#>  91:  0.004141410 1.715128e-05 <list[1]> 2024-11-08 08:28:06        4         3
#>  92:  0.162168377 2.629858e-02 <list[1]> 2024-11-08 08:28:06        4         3
#>  93: -0.097397100 9.486195e-03 <list[1]> 2024-11-08 08:28:06        4         3
#>  94: -0.282796497 7.997386e-02 <list[1]> 2024-11-08 08:28:06        4         3
#>  95:  0.032444437 1.052642e-03 <list[1]> 2024-11-08 08:28:06        4         3
#>  96:  0.238059682 5.667241e-02 <list[1]> 2024-11-08 08:28:06        4         3
#>  97: -0.412334177 1.700195e-01 <list[1]> 2024-11-08 08:28:06        4         3
#>  98:  0.385714496 1.487757e-01 <list[1]> 2024-11-08 08:28:06        4         3
#>  99:  0.245431637 6.023669e-02 <list[1]> 2024-11-08 08:28:06        4         3
#> 100: -0.099390131 9.878398e-03 <list[1]> 2024-11-08 08:28:06        4         3
#>                 x            y  x_domain           timestamp batch_nr .point_id