Implements a simple Local Search, see local_search() for details.
Currently, setting initial points is not supported.
Dictionary
This Optimizer can be instantiated via the dictionary
mlr_optimizers or with the associated sugar function opt():
Parameters
The same as for local_search_control(), with the same defaults (except for minimize).
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
# define the objective function
fun = function(xs) {
list(y = - (xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10)
}
# set domain
domain = ps(
x1 = p_dbl(-10, 10),
x2 = p_dbl(-5, 5)
)
# set codomain
codomain = ps(
y = p_dbl(tags = "maximize")
)
# create objective
objective = ObjectiveRFun$new(
fun = fun,
domain = domain,
codomain = codomain,
properties = "deterministic"
)
# initialize instance
instance = oi(
objective = objective,
terminator = trm("evals", n_evals = 20)
)
# load optimizer
optimizer = opt("local_search")
# trigger optimization
optimizer$optimize(instance)
#> x1 x2 x_domain y
#> <num> <num> <list> <num>
#> 1: 1.30762 -3.111123 <list[2]> 9.508261
# all evaluated configurations
instance$archive
#>
#> ── <ArchiveBatch> - Data Table Storage ─────────────────────────────────────────
#> x1 x2 y timestamp batch_nr x_domain_x1 x_domain_x2
#> <num> <num> <num> <POSc> <int> <num> <num>
#> 1: -2.7 0.1 -21.81 2026-03-09 09:07:30 1 -2.7 0.1
#> 2: 1.3 -3.7 8.99 2026-03-09 09:07:30 1 1.3 -3.7
#> 3: 3.3 1.2 -9.03 2026-03-09 09:07:30 1 3.3 1.2
#> 4: -5.9 3.1 -89.21 2026-03-09 09:07:30 1 -5.9 3.1
#> 5: -3.9 4.7 -83.85 2026-03-09 09:07:30 1 -3.9 4.7
#> ---
#> 106: -1.2 -3.3 -0.04 2026-03-09 09:07:31 2 -1.2 -3.3
#> 107: 2.4 -3.8 9.13 2026-03-09 09:07:31 2 2.4 -3.8
#> 108: 2.6 -3.8 8.92 2026-03-09 09:07:31 2 2.6 -3.8
#> 109: -2.0 -3.8 -6.96 2026-03-09 09:07:31 2 -2.0 -3.8
#> 110: 0.4 -3.8 6.74 2026-03-09 09:07:31 2 0.4 -3.8
# best performing configuration
instance$result
#> x1 x2 x_domain y
#> <num> <num> <list> <num>
#> 1: 1.30762 -3.111123 <list[2]> 9.508261