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.007621593 <list[1]> 5.808868e-05

# returns best scoring evaluation
instance$result
#>               x  x_domain            y
#>           <num>    <list>        <num>
#> 1: -0.007621593 <list[1]> 5.808868e-05

# 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.145375402 2.113401e-02 <list[1]> 2025-07-23 11:59:39        1        NA
#>   2: -0.022373165 5.005585e-04 <list[1]> 2025-07-23 11:59:39        1        NA
#>   3:  0.886380139 7.856698e-01 <list[1]> 2025-07-23 11:59:39        1        NA
#>   4: -0.387283073 1.499882e-01 <list[1]> 2025-07-23 11:59:39        1        NA
#>   5:  0.726841456 5.282985e-01 <list[1]> 2025-07-23 11:59:39        1        NA
#>   6: -0.397751912 1.582066e-01 <list[1]> 2025-07-23 11:59:39        1        NA
#>   7: -0.396008062 1.568224e-01 <list[1]> 2025-07-23 11:59:39        1        NA
#>   8:  0.020697454 4.283846e-04 <list[1]> 2025-07-23 11:59:39        1        NA
#>   9:  0.236614957 5.598664e-02 <list[1]> 2025-07-23 11:59:39        1        NA
#>  10: -0.756173969 5.717991e-01 <list[1]> 2025-07-23 11:59:39        1        NA
#>  11: -0.040811589 1.665586e-03 <list[1]> 2025-07-23 11:59:39        2         1
#>  12: -0.032342885 1.046062e-03 <list[1]> 2025-07-23 11:59:39        2         1
#>  13:  0.192257207 3.696283e-02 <list[1]> 2025-07-23 11:59:39        2         1
#>  14:  0.193094029 3.728530e-02 <list[1]> 2025-07-23 11:59:39        2         1
#>  15:  0.032055264 1.027540e-03 <list[1]> 2025-07-23 11:59:39        2         1
#>  16: -0.127387265 1.622752e-02 <list[1]> 2025-07-23 11:59:39        2         1
#>  17:  0.310929543 9.667718e-02 <list[1]> 2025-07-23 11:59:39        2         1
#>  18: -0.050403288 2.540491e-03 <list[1]> 2025-07-23 11:59:39        2         1
#>  19:  0.054913936 3.015540e-03 <list[1]> 2025-07-23 11:59:39        2         1
#>  20:  0.073396227 5.387006e-03 <list[1]> 2025-07-23 11:59:39        2         1
#>  21:  0.072137154 5.203769e-03 <list[1]> 2025-07-23 11:59:39        2         2
#>  22:  0.037176865 1.382119e-03 <list[1]> 2025-07-23 11:59:39        2         2
#>  23:  0.011872014 1.409447e-04 <list[1]> 2025-07-23 11:59:39        2         2
#>  24: -0.203309263 4.133466e-02 <list[1]> 2025-07-23 11:59:39        2         2
#>  25: -0.024475181 5.990345e-04 <list[1]> 2025-07-23 11:59:39        2         2
#>  26:  0.357148437 1.275550e-01 <list[1]> 2025-07-23 11:59:39        2         2
#>  27: -0.303656111 9.220703e-02 <list[1]> 2025-07-23 11:59:39        2         2
#>  28:  0.079341295 6.295041e-03 <list[1]> 2025-07-23 11:59:39        2         2
#>  29:  0.157653392 2.485459e-02 <list[1]> 2025-07-23 11:59:39        2         2
#>  30: -0.165904280 2.752423e-02 <list[1]> 2025-07-23 11:59:39        2         2
#>  31:  0.348327847 1.213323e-01 <list[1]> 2025-07-23 11:59:39        2         3
#>  32:  0.249399647 6.220018e-02 <list[1]> 2025-07-23 11:59:39        2         3
#>  33: -0.246051392 6.054129e-02 <list[1]> 2025-07-23 11:59:39        2         3
#>  34: -0.041612358 1.731588e-03 <list[1]> 2025-07-23 11:59:39        2         3
#>  35: -0.186261726 3.469343e-02 <list[1]> 2025-07-23 11:59:39        2         3
#>  36: -0.033535138 1.124605e-03 <list[1]> 2025-07-23 11:59:39        2         3
#>  37:  0.026350050 6.943251e-04 <list[1]> 2025-07-23 11:59:39        2         3
#>  38:  0.398806118 1.590463e-01 <list[1]> 2025-07-23 11:59:39        2         3
#>  39: -0.019389055 3.759355e-04 <list[1]> 2025-07-23 11:59:39        2         3
#>  40:  0.348490366 1.214455e-01 <list[1]> 2025-07-23 11:59:39        2         3
#>  41:  0.370315333 1.371334e-01 <list[1]> 2025-07-23 11:59:39        3         1
#>  42: -0.251101871 6.305215e-02 <list[1]> 2025-07-23 11:59:39        3         1
#>  43: -0.025107856 6.304044e-04 <list[1]> 2025-07-23 11:59:39        3         1
#>  44: -0.281896956 7.946589e-02 <list[1]> 2025-07-23 11:59:39        3         1
#>  45:  0.110422058 1.219303e-02 <list[1]> 2025-07-23 11:59:39        3         1
#>  46: -0.230911867 5.332029e-02 <list[1]> 2025-07-23 11:59:39        3         1
#>  47:  0.122423168 1.498743e-02 <list[1]> 2025-07-23 11:59:39        3         1
#>  48:  0.450421974 2.028800e-01 <list[1]> 2025-07-23 11:59:39        3         1
#>  49:  0.306428463 9.389840e-02 <list[1]> 2025-07-23 11:59:39        3         1
#>  50:  0.135723604 1.842090e-02 <list[1]> 2025-07-23 11:59:39        3         1
#>  51: -0.255932680 6.550154e-02 <list[1]> 2025-07-23 11:59:39        3         2
#>  52:  0.062394808 3.893112e-03 <list[1]> 2025-07-23 11:59:39        3         2
#>  53: -0.038447959 1.478246e-03 <list[1]> 2025-07-23 11:59:39        3         2
#>  54:  0.090617150 8.211468e-03 <list[1]> 2025-07-23 11:59:39        3         2
#>  55:  0.150704845 2.271195e-02 <list[1]> 2025-07-23 11:59:39        3         2
#>  56:  0.044479861 1.978458e-03 <list[1]> 2025-07-23 11:59:39        3         2
#>  57:  0.302923016 9.176235e-02 <list[1]> 2025-07-23 11:59:39        3         2
#>  58:  0.053406276 2.852230e-03 <list[1]> 2025-07-23 11:59:39        3         2
#>  59:  0.100264664 1.005300e-02 <list[1]> 2025-07-23 11:59:39        3         2
#>  60:  0.151842467 2.305613e-02 <list[1]> 2025-07-23 11:59:39        3         2
#>  61: -0.353390589 1.248849e-01 <list[1]> 2025-07-23 11:59:39        3         3
#>  62:  0.130569965 1.704852e-02 <list[1]> 2025-07-23 11:59:39        3         3
#>  63:  0.029122602 8.481260e-04 <list[1]> 2025-07-23 11:59:39        3         3
#>  64:  0.295189107 8.713661e-02 <list[1]> 2025-07-23 11:59:39        3         3
#>  65:  0.011831761 1.399906e-04 <list[1]> 2025-07-23 11:59:39        3         3
#>  66:  0.231389768 5.354122e-02 <list[1]> 2025-07-23 11:59:39        3         3
#>  67:  0.119523076 1.428577e-02 <list[1]> 2025-07-23 11:59:39        3         3
#>  68: -0.173199116 2.999793e-02 <list[1]> 2025-07-23 11:59:39        3         3
#>  69:  0.123929444 1.535851e-02 <list[1]> 2025-07-23 11:59:39        3         3
#>  70: -0.007621593 5.808868e-05 <list[1]> 2025-07-23 11:59:39        3         3
#>  71:  0.137674265 1.895420e-02 <list[1]> 2025-07-23 11:59:40        4         1
#>  72:  0.109072627 1.189684e-02 <list[1]> 2025-07-23 11:59:40        4         1
#>  73: -0.105179770 1.106278e-02 <list[1]> 2025-07-23 11:59:40        4         1
#>  74:  0.424133766 1.798895e-01 <list[1]> 2025-07-23 11:59:40        4         1
#>  75: -0.013726042 1.884042e-04 <list[1]> 2025-07-23 11:59:40        4         1
#>  76: -0.044687202 1.996946e-03 <list[1]> 2025-07-23 11:59:40        4         1
#>  77:  0.087216261 7.606676e-03 <list[1]> 2025-07-23 11:59:40        4         1
#>  78:  0.319551341 1.021131e-01 <list[1]> 2025-07-23 11:59:40        4         1
#>  79:  0.108258510 1.171990e-02 <list[1]> 2025-07-23 11:59:40        4         1
#>  80:  0.168807500 2.849597e-02 <list[1]> 2025-07-23 11:59:40        4         1
#>  81:  0.206847927 4.278607e-02 <list[1]> 2025-07-23 11:59:40        4         2
#>  82: -0.194061242 3.765977e-02 <list[1]> 2025-07-23 11:59:40        4         2
#>  83:  0.048015688 2.305506e-03 <list[1]> 2025-07-23 11:59:40        4         2
#>  84:  0.242174331 5.864841e-02 <list[1]> 2025-07-23 11:59:40        4         2
#>  85:  0.201419735 4.056991e-02 <list[1]> 2025-07-23 11:59:40        4         2
#>  86:  0.554816621 3.078215e-01 <list[1]> 2025-07-23 11:59:40        4         2
#>  87:  0.087818934 7.712165e-03 <list[1]> 2025-07-23 11:59:40        4         2
#>  88: -0.049210135 2.421637e-03 <list[1]> 2025-07-23 11:59:40        4         2
#>  89: -0.017057777 2.909678e-04 <list[1]> 2025-07-23 11:59:40        4         2
#>  90:  0.393764818 1.550507e-01 <list[1]> 2025-07-23 11:59:40        4         2
#>  91:  0.066253899 4.389579e-03 <list[1]> 2025-07-23 11:59:40        4         3
#>  92: -0.053756452 2.889756e-03 <list[1]> 2025-07-23 11:59:40        4         3
#>  93:  0.341850091 1.168615e-01 <list[1]> 2025-07-23 11:59:40        4         3
#>  94: -0.267431341 7.151952e-02 <list[1]> 2025-07-23 11:59:40        4         3
#>  95: -0.129325400 1.672506e-02 <list[1]> 2025-07-23 11:59:40        4         3
#>  96: -0.353462850 1.249360e-01 <list[1]> 2025-07-23 11:59:40        4         3
#>  97:  0.122103503 1.490927e-02 <list[1]> 2025-07-23 11:59:40        4         3
#>  98:  0.175569169 3.082453e-02 <list[1]> 2025-07-23 11:59:40        4         3
#>  99: -0.020334732 4.135013e-04 <list[1]> 2025-07-23 11:59:40        4         3
#> 100:  0.187439659 3.513363e-02 <list[1]> 2025-07-23 11:59:40        4         3
#>                 x            y  x_domain           timestamp batch_nr .point_id