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()
:
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 is10
.initial_random_sample_size
integer(1)
Number of points that are sampled uniformly at random before the bestn_initial_points
initial points are determined, if fewer points thann_initial_points
are present in the Archive of the OptimInstance. Default is100
.neighbors_per_point
integer(1)
Number of neighboring points to generate for each of then_initial_points
best starting points in each iteration. Default is100
.mutation_sd
numeric(1)
Standard deviation used to create neighbors during mutation of numeric parameters on the standardized[0, 1]
scale. Default is0.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 then_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
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.0004821201 <list[1]> 2.324398e-07
# returns best scoring evaluation
instance$result
#> x x_domain y
#> <num> <list> <num>
#> 1: 0.0004821201 <list[1]> 2.324398e-07
# allows access of data.table of full path of all evaluations
as.data.table(instance$archive$data)
#> x y x_domain timestamp batch_nr
#> <num> <num> <list> <POSc> <int>
#> 1: -0.2862196355 8.192168e-02 <list[1]> 2025-05-30 08:00:32 1
#> 2: -0.3226344651 1.040930e-01 <list[1]> 2025-05-30 08:00:32 1
#> 3: -0.8750307984 7.656789e-01 <list[1]> 2025-05-30 08:00:32 1
#> 4: 0.3489210065 1.217459e-01 <list[1]> 2025-05-30 08:00:32 1
#> 5: 0.3738443493 1.397596e-01 <list[1]> 2025-05-30 08:00:32 1
#> 6: -0.3918538294 1.535494e-01 <list[1]> 2025-05-30 08:00:32 1
#> 7: 0.2648870423 7.016515e-02 <list[1]> 2025-05-30 08:00:32 1
#> 8: 0.2479003915 6.145460e-02 <list[1]> 2025-05-30 08:00:32 1
#> 9: -0.2509884080 6.299518e-02 <list[1]> 2025-05-30 08:00:32 1
#> 10: 0.3780645211 1.429328e-01 <list[1]> 2025-05-30 08:00:32 1
#> 11: 0.3072822449 9.442238e-02 <list[1]> 2025-05-30 08:00:33 2
#> 12: 0.1141403980 1.302803e-02 <list[1]> 2025-05-30 08:00:33 2
#> 13: 0.1334439998 1.780730e-02 <list[1]> 2025-05-30 08:00:33 2
#> 14: 0.1739072585 3.024373e-02 <list[1]> 2025-05-30 08:00:33 2
#> 15: 0.2511082088 6.305533e-02 <list[1]> 2025-05-30 08:00:33 2
#> 16: 0.3361524122 1.129984e-01 <list[1]> 2025-05-30 08:00:33 2
#> 17: 0.5959234137 3.551247e-01 <list[1]> 2025-05-30 08:00:33 2
#> 18: 0.5372080472 2.885925e-01 <list[1]> 2025-05-30 08:00:33 2
#> 19: 0.3925868772 1.541245e-01 <list[1]> 2025-05-30 08:00:33 2
#> 20: 0.3481740847 1.212252e-01 <list[1]> 2025-05-30 08:00:33 2
#> 21: -0.3872758412 1.499826e-01 <list[1]> 2025-05-30 08:00:33 2
#> 22: -0.0536161852 2.874695e-03 <list[1]> 2025-05-30 08:00:33 2
#> 23: -0.3953065711 1.562673e-01 <list[1]> 2025-05-30 08:00:33 2
#> 24: -0.4179312247 1.746665e-01 <list[1]> 2025-05-30 08:00:33 2
#> 25: -0.3219496145 1.036516e-01 <list[1]> 2025-05-30 08:00:33 2
#> 26: -0.4718802959 2.226710e-01 <list[1]> 2025-05-30 08:00:33 2
#> 27: -0.4145701989 1.718684e-01 <list[1]> 2025-05-30 08:00:33 2
#> 28: -0.1652955353 2.732261e-02 <list[1]> 2025-05-30 08:00:33 2
#> 29: -0.2256128982 5.090118e-02 <list[1]> 2025-05-30 08:00:33 2
#> 30: -0.5136306058 2.638164e-01 <list[1]> 2025-05-30 08:00:33 2
#> 31: 0.1630922373 2.659908e-02 <list[1]> 2025-05-30 08:00:33 2
#> 32: 0.1563171708 2.443506e-02 <list[1]> 2025-05-30 08:00:33 2
#> 33: 0.3592767182 1.290798e-01 <list[1]> 2025-05-30 08:00:33 2
#> 34: -0.0234891051 5.517381e-04 <list[1]> 2025-05-30 08:00:33 2
#> 35: 0.1228512936 1.509244e-02 <list[1]> 2025-05-30 08:00:33 2
#> 36: 0.3526240933 1.243438e-01 <list[1]> 2025-05-30 08:00:33 2
#> 37: 0.4864711487 2.366542e-01 <list[1]> 2025-05-30 08:00:33 2
#> 38: 0.3667525786 1.345075e-01 <list[1]> 2025-05-30 08:00:33 2
#> 39: 0.5788993683 3.351245e-01 <list[1]> 2025-05-30 08:00:33 2
#> 40: 0.2681552970 7.190726e-02 <list[1]> 2025-05-30 08:00:33 2
#> 41: 0.3071735548 9.435559e-02 <list[1]> 2025-05-30 08:00:33 3
#> 42: 0.0219546074 4.820048e-04 <list[1]> 2025-05-30 08:00:33 3
#> 43: 0.1261531417 1.591462e-02 <list[1]> 2025-05-30 08:00:33 3
#> 44: 0.1438712223 2.069893e-02 <list[1]> 2025-05-30 08:00:33 3
#> 45: -0.0381724032 1.457132e-03 <list[1]> 2025-05-30 08:00:33 3
#> 46: 0.1080890091 1.168323e-02 <list[1]> 2025-05-30 08:00:33 3
#> 47: 0.4263554169 1.817789e-01 <list[1]> 2025-05-30 08:00:33 3
#> 48: 0.2469102932 6.096469e-02 <list[1]> 2025-05-30 08:00:33 3
#> 49: 0.0486310550 2.364980e-03 <list[1]> 2025-05-30 08:00:33 3
#> 50: 0.0669627984 4.484016e-03 <list[1]> 2025-05-30 08:00:33 3
#> 51: -0.2422548326 5.868740e-02 <list[1]> 2025-05-30 08:00:33 3
#> 52: -0.1607017926 2.582507e-02 <list[1]> 2025-05-30 08:00:33 3
#> 53: -0.0625999786 3.918757e-03 <list[1]> 2025-05-30 08:00:33 3
#> 54: -0.2160076878 4.665932e-02 <list[1]> 2025-05-30 08:00:33 3
#> 55: -0.1310252016 1.716760e-02 <list[1]> 2025-05-30 08:00:33 3
#> 56: -0.2740800894 7.511990e-02 <list[1]> 2025-05-30 08:00:33 3
#> 57: 0.1169455658 1.367627e-02 <list[1]> 2025-05-30 08:00:33 3
#> 58: -0.2757560981 7.604143e-02 <list[1]> 2025-05-30 08:00:33 3
#> 59: -0.3298046924 1.087711e-01 <list[1]> 2025-05-30 08:00:33 3
#> 60: -0.2214927204 4.905903e-02 <list[1]> 2025-05-30 08:00:33 3
#> 61: 0.0732903803 5.371480e-03 <list[1]> 2025-05-30 08:00:33 3
#> 62: -0.0564548654 3.187152e-03 <list[1]> 2025-05-30 08:00:33 3
#> 63: 0.0004821201 2.324398e-07 <list[1]> 2025-05-30 08:00:33 3
#> 64: 0.0362206655 1.311937e-03 <list[1]> 2025-05-30 08:00:33 3
#> 65: 0.1368125157 1.871766e-02 <list[1]> 2025-05-30 08:00:33 3
#> 66: 0.1799713753 3.238970e-02 <list[1]> 2025-05-30 08:00:33 3
#> 67: -0.0920765680 8.478094e-03 <list[1]> 2025-05-30 08:00:33 3
#> 68: -0.1798117442 3.233226e-02 <list[1]> 2025-05-30 08:00:33 3
#> 69: 0.1774386618 3.148448e-02 <list[1]> 2025-05-30 08:00:33 3
#> 70: 0.0812111811 6.595256e-03 <list[1]> 2025-05-30 08:00:33 3
#> 71: -0.1109745619 1.231535e-02 <list[1]> 2025-05-30 08:00:33 4
#> 72: -0.3459158753 1.196578e-01 <list[1]> 2025-05-30 08:00:33 4
#> 73: 0.3044846879 9.271093e-02 <list[1]> 2025-05-30 08:00:33 4
#> 74: 0.0507094478 2.571448e-03 <list[1]> 2025-05-30 08:00:33 4
#> 75: -0.2681684435 7.191431e-02 <list[1]> 2025-05-30 08:00:33 4
#> 76: 0.2839277029 8.061494e-02 <list[1]> 2025-05-30 08:00:33 4
#> 77: 0.1224252806 1.498795e-02 <list[1]> 2025-05-30 08:00:33 4
#> 78: 0.3467935124 1.202657e-01 <list[1]> 2025-05-30 08:00:33 4
#> 79: -0.0532497042 2.835531e-03 <list[1]> 2025-05-30 08:00:33 4
#> 80: 0.2447980760 5.992610e-02 <list[1]> 2025-05-30 08:00:33 4
#> 81: 0.1039801204 1.081187e-02 <list[1]> 2025-05-30 08:00:33 4
#> 82: -0.1399248057 1.957895e-02 <list[1]> 2025-05-30 08:00:33 4
#> 83: 0.0613406337 3.762673e-03 <list[1]> 2025-05-30 08:00:33 4
#> 84: 0.0381579495 1.456029e-03 <list[1]> 2025-05-30 08:00:33 4
#> 85: -0.0432787770 1.873053e-03 <list[1]> 2025-05-30 08:00:33 4
#> 86: -0.2302800388 5.302890e-02 <list[1]> 2025-05-30 08:00:33 4
#> 87: 0.0473066501 2.237919e-03 <list[1]> 2025-05-30 08:00:33 4
#> 88: -0.2115517296 4.475413e-02 <list[1]> 2025-05-30 08:00:33 4
#> 89: 0.1149008029 1.320219e-02 <list[1]> 2025-05-30 08:00:33 4
#> 90: 0.0248885281 6.194388e-04 <list[1]> 2025-05-30 08:00:33 4
#> 91: -0.0016913609 2.860702e-06 <list[1]> 2025-05-30 08:00:33 4
#> 92: -0.0054919988 3.016205e-05 <list[1]> 2025-05-30 08:00:33 4
#> 93: 0.0358900935 1.288099e-03 <list[1]> 2025-05-30 08:00:33 4
#> 94: 0.4406226191 1.941483e-01 <list[1]> 2025-05-30 08:00:33 4
#> 95: -0.1011783299 1.023705e-02 <list[1]> 2025-05-30 08:00:33 4
#> 96: -0.0185930256 3.457006e-04 <list[1]> 2025-05-30 08:00:33 4
#> 97: 0.0282251899 7.966613e-04 <list[1]> 2025-05-30 08:00:33 4
#> 98: -0.0390807001 1.527301e-03 <list[1]> 2025-05-30 08:00:33 4
#> 99: -0.0083025163 6.893178e-05 <list[1]> 2025-05-30 08:00:33 4
#> 100: 0.1810357219 3.277393e-02 <list[1]> 2025-05-30 08:00:33 4
#> x y x_domain timestamp batch_nr
#> .point_id
#> <int>
#> 1: NA
#> 2: NA
#> 3: NA
#> 4: NA
#> 5: NA
#> 6: NA
#> 7: NA
#> 8: NA
#> 9: NA
#> 10: NA
#> 11: 1
#> 12: 1
#> 13: 1
#> 14: 1
#> 15: 1
#> 16: 1
#> 17: 1
#> 18: 1
#> 19: 1
#> 20: 1
#> 21: 2
#> 22: 2
#> 23: 2
#> 24: 2
#> 25: 2
#> 26: 2
#> 27: 2
#> 28: 2
#> 29: 2
#> 30: 2
#> 31: 3
#> 32: 3
#> 33: 3
#> 34: 3
#> 35: 3
#> 36: 3
#> 37: 3
#> 38: 3
#> 39: 3
#> 40: 3
#> 41: 1
#> 42: 1
#> 43: 1
#> 44: 1
#> 45: 1
#> 46: 1
#> 47: 1
#> 48: 1
#> 49: 1
#> 50: 1
#> 51: 2
#> 52: 2
#> 53: 2
#> 54: 2
#> 55: 2
#> 56: 2
#> 57: 2
#> 58: 2
#> 59: 2
#> 60: 2
#> 61: 3
#> 62: 3
#> 63: 3
#> 64: 3
#> 65: 3
#> 66: 3
#> 67: 3
#> 68: 3
#> 69: 3
#> 70: 3
#> 71: 1
#> 72: 1
#> 73: 1
#> 74: 1
#> 75: 1
#> 76: 1
#> 77: 1
#> 78: 1
#> 79: 1
#> 80: 1
#> 81: 2
#> 82: 2
#> 83: 2
#> 84: 2
#> 85: 2
#> 86: 2
#> 87: 2
#> 88: 2
#> 89: 2
#> 90: 2
#> 91: 3
#> 92: 3
#> 93: 3
#> 94: 3
#> 95: 3
#> 96: 3
#> 97: 3
#> 98: 3
#> 99: 3
#> 100: 3
#> .point_id