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.002401566 <list[1]> 5.76752e-06

# returns best scoring evaluation
instance$result
#>              x  x_domain           y
#>          <num>    <list>       <num>
#> 1: 0.002401566 <list[1]> 5.76752e-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.434562679 1.888447e-01 <list[1]> 2024-12-18 10:02:46        1        NA
#>   2: -0.125425003 1.573143e-02 <list[1]> 2024-12-18 10:02:46        1        NA
#>   3:  0.033470919 1.120302e-03 <list[1]> 2024-12-18 10:02:46        1        NA
#>   4:  0.353672964 1.250846e-01 <list[1]> 2024-12-18 10:02:46        1        NA
#>   5:  0.177525542 3.151532e-02 <list[1]> 2024-12-18 10:02:46        1        NA
#>   6:  0.099881455 9.976305e-03 <list[1]> 2024-12-18 10:02:46        1        NA
#>   7:  0.041221941 1.699248e-03 <list[1]> 2024-12-18 10:02:46        1        NA
#>   8: -0.320341957 1.026190e-01 <list[1]> 2024-12-18 10:02:46        1        NA
#>   9: -0.931926232 8.684865e-01 <list[1]> 2024-12-18 10:02:46        1        NA
#>  10: -0.622936200 3.880495e-01 <list[1]> 2024-12-18 10:02:46        1        NA
#>  11:  0.240396995 5.779072e-02 <list[1]> 2024-12-18 10:02:46        2         1
#>  12:  0.078773803 6.205312e-03 <list[1]> 2024-12-18 10:02:46        2         1
#>  13: -0.264627964 7.002796e-02 <list[1]> 2024-12-18 10:02:46        2         1
#>  14:  0.289058224 8.355466e-02 <list[1]> 2024-12-18 10:02:46        2         1
#>  15: -0.264506043 6.996345e-02 <list[1]> 2024-12-18 10:02:46        2         1
#>  16: -0.529376677 2.802397e-01 <list[1]> 2024-12-18 10:02:46        2         1
#>  17:  0.478036678 2.285191e-01 <list[1]> 2024-12-18 10:02:46        2         1
#>  18: -0.430212293 1.850826e-01 <list[1]> 2024-12-18 10:02:46        2         1
#>  19: -0.122211896 1.493575e-02 <list[1]> 2024-12-18 10:02:46        2         1
#>  20:  0.247608977 6.131021e-02 <list[1]> 2024-12-18 10:02:46        2         1
#>  21:  0.223349981 4.988521e-02 <list[1]> 2024-12-18 10:02:46        2         2
#>  22:  0.188007406 3.534678e-02 <list[1]> 2024-12-18 10:02:46        2         2
#>  23:  0.098430576 9.688578e-03 <list[1]> 2024-12-18 10:02:46        2         2
#>  24: -0.103020881 1.061330e-02 <list[1]> 2024-12-18 10:02:46        2         2
#>  25:  0.223285963 4.985662e-02 <list[1]> 2024-12-18 10:02:46        2         2
#>  26:  0.101562463 1.031493e-02 <list[1]> 2024-12-18 10:02:46        2         2
#>  27:  0.567367025 3.219053e-01 <list[1]> 2024-12-18 10:02:46        2         2
#>  28: -0.267905320 7.177326e-02 <list[1]> 2024-12-18 10:02:46        2         2
#>  29:  0.102661949 1.053948e-02 <list[1]> 2024-12-18 10:02:46        2         2
#>  30:  0.172578100 2.978320e-02 <list[1]> 2024-12-18 10:02:46        2         2
#>  31:  0.078924628 6.229097e-03 <list[1]> 2024-12-18 10:02:46        2         3
#>  32:  0.457976118 2.097421e-01 <list[1]> 2024-12-18 10:02:46        2         3
#>  33: -0.084205498 7.090566e-03 <list[1]> 2024-12-18 10:02:46        2         3
#>  34: -0.302660706 9.160350e-02 <list[1]> 2024-12-18 10:02:46        2         3
#>  35:  0.143066197 2.046794e-02 <list[1]> 2024-12-18 10:02:46        2         3
#>  36: -0.280027320 7.841530e-02 <list[1]> 2024-12-18 10:02:46        2         3
#>  37:  0.102836571 1.057536e-02 <list[1]> 2024-12-18 10:02:46        2         3
#>  38: -0.239177842 5.720604e-02 <list[1]> 2024-12-18 10:02:46        2         3
#>  39:  0.102444799 1.049494e-02 <list[1]> 2024-12-18 10:02:46        2         3
#>  40:  0.228273249 5.210868e-02 <list[1]> 2024-12-18 10:02:46        2         3
#>  41: -0.019443213 3.780385e-04 <list[1]> 2024-12-18 10:02:46        3         1
#>  42:  0.351599501 1.236222e-01 <list[1]> 2024-12-18 10:02:46        3         1
#>  43:  0.093679678 8.775882e-03 <list[1]> 2024-12-18 10:02:46        3         1
#>  44: -0.183109416 3.352906e-02 <list[1]> 2024-12-18 10:02:46        3         1
#>  45:  0.117927886 1.390699e-02 <list[1]> 2024-12-18 10:02:46        3         1
#>  46: -0.031940662 1.020206e-03 <list[1]> 2024-12-18 10:02:46        3         1
#>  47: -0.344077844 1.183896e-01 <list[1]> 2024-12-18 10:02:46        3         1
#>  48:  0.240515781 5.784784e-02 <list[1]> 2024-12-18 10:02:46        3         1
#>  49: -0.003064378 9.390416e-06 <list[1]> 2024-12-18 10:02:46        3         1
#>  50: -0.090463875 8.183713e-03 <list[1]> 2024-12-18 10:02:46        3         1
#>  51:  0.267099959 7.134239e-02 <list[1]> 2024-12-18 10:02:46        3         2
#>  52:  0.067776339 4.593632e-03 <list[1]> 2024-12-18 10:02:46        3         2
#>  53:  0.002401566 5.767520e-06 <list[1]> 2024-12-18 10:02:46        3         2
#>  54: -0.099498981 9.900047e-03 <list[1]> 2024-12-18 10:02:46        3         2
#>  55:  0.053078882 2.817368e-03 <list[1]> 2024-12-18 10:02:46        3         2
#>  56:  0.362144847 1.311489e-01 <list[1]> 2024-12-18 10:02:46        3         2
#>  57:  0.378641165 1.433691e-01 <list[1]> 2024-12-18 10:02:46        3         2
#>  58:  0.014201558 2.016843e-04 <list[1]> 2024-12-18 10:02:46        3         2
#>  59: -0.192897827 3.720957e-02 <list[1]> 2024-12-18 10:02:46        3         2
#>  60: -0.071325349 5.087305e-03 <list[1]> 2024-12-18 10:02:46        3         2
#>  61:  0.073715337 5.433951e-03 <list[1]> 2024-12-18 10:02:46        3         3
#>  62:  0.182270847 3.322266e-02 <list[1]> 2024-12-18 10:02:46        3         3
#>  63:  0.135811673 1.844481e-02 <list[1]> 2024-12-18 10:02:46        3         3
#>  64:  0.113078756 1.278681e-02 <list[1]> 2024-12-18 10:02:46        3         3
#>  65:  0.330411781 1.091719e-01 <list[1]> 2024-12-18 10:02:46        3         3
#>  66: -0.096564927 9.324785e-03 <list[1]> 2024-12-18 10:02:46        3         3
#>  67: -0.094851444 8.996796e-03 <list[1]> 2024-12-18 10:02:46        3         3
#>  68:  0.416035569 1.730856e-01 <list[1]> 2024-12-18 10:02:46        3         3
#>  69: -0.172022315 2.959168e-02 <list[1]> 2024-12-18 10:02:46        3         3
#>  70:  0.101083439 1.021786e-02 <list[1]> 2024-12-18 10:02:46        3         3
#>  71:  0.255765908 6.541620e-02 <list[1]> 2024-12-18 10:02:46        4         1
#>  72: -0.179159708 3.209820e-02 <list[1]> 2024-12-18 10:02:46        4         1
#>  73: -0.044734783 2.001201e-03 <list[1]> 2024-12-18 10:02:46        4         1
#>  74: -0.170547961 2.908661e-02 <list[1]> 2024-12-18 10:02:46        4         1
#>  75: -0.459601149 2.112332e-01 <list[1]> 2024-12-18 10:02:46        4         1
#>  76:  0.108248374 1.171771e-02 <list[1]> 2024-12-18 10:02:46        4         1
#>  77: -0.097656151 9.536724e-03 <list[1]> 2024-12-18 10:02:46        4         1
#>  78:  0.083178488 6.918661e-03 <list[1]> 2024-12-18 10:02:46        4         1
#>  79: -0.007977024 6.363291e-05 <list[1]> 2024-12-18 10:02:46        4         1
#>  80:  0.249340862 6.217087e-02 <list[1]> 2024-12-18 10:02:46        4         1
#>  81: -0.308352315 9.508115e-02 <list[1]> 2024-12-18 10:02:46        4         2
#>  82: -0.136337555 1.858793e-02 <list[1]> 2024-12-18 10:02:46        4         2
#>  83:  0.068922042 4.750248e-03 <list[1]> 2024-12-18 10:02:46        4         2
#>  84: -0.119960333 1.439048e-02 <list[1]> 2024-12-18 10:02:46        4         2
#>  85: -0.375316340 1.408624e-01 <list[1]> 2024-12-18 10:02:46        4         2
#>  86:  0.051073021 2.608454e-03 <list[1]> 2024-12-18 10:02:46        4         2
#>  87:  0.052424317 2.748309e-03 <list[1]> 2024-12-18 10:02:46        4         2
#>  88:  0.234961920 5.520710e-02 <list[1]> 2024-12-18 10:02:46        4         2
#>  89: -0.003919949 1.536600e-05 <list[1]> 2024-12-18 10:02:46        4         2
#>  90:  0.231008659 5.336500e-02 <list[1]> 2024-12-18 10:02:46        4         2
#>  91: -0.085801556 7.361907e-03 <list[1]> 2024-12-18 10:02:46        4         3
#>  92:  0.106501326 1.134253e-02 <list[1]> 2024-12-18 10:02:46        4         3
#>  93:  0.208232389 4.336073e-02 <list[1]> 2024-12-18 10:02:46        4         3
#>  94:  0.201602434 4.064354e-02 <list[1]> 2024-12-18 10:02:46        4         3
#>  95:  0.015728904 2.473984e-04 <list[1]> 2024-12-18 10:02:46        4         3
#>  96:  0.116287249 1.352272e-02 <list[1]> 2024-12-18 10:02:46        4         3
#>  97:  0.114082568 1.301483e-02 <list[1]> 2024-12-18 10:02:46        4         3
#>  98:  0.192165550 3.692760e-02 <list[1]> 2024-12-18 10:02:46        4         3
#>  99:  0.072009012 5.185298e-03 <list[1]> 2024-12-18 10:02:46        4         3
#> 100: -0.264301091 6.985507e-02 <list[1]> 2024-12-18 10:02:46        4         3
#>                 x            y  x_domain           timestamp batch_nr .point_id