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
Optimizer -> OptimizerBatch -> OptimizerBatchLocalSearch
Methods
Inherited methods
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.095615 -3.078378 <list[2]> 9.175946
# 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: -8 -2.5 -99 2026-09-03 12:11:12 1 -8 -2.5
#> 2: -4 -0.3 -28 2026-09-03 12:11:12 1 -4 -0.3
#> 3: -3 0.5 -27 2026-09-03 12:11:12 1 -3 0.5
#> 4: -2 -2.5 -3 2026-09-03 12:11:12 1 -2 -2.5
#> 5: 2 -2.1 9 2026-09-03 12:11:12 1 2 -2.1
#> ---
#> 106: -7 0.5 -84 2026-09-03 12:11:13 2 -7 0.5
#> 107: -8 1.2 -98 2026-09-03 12:11:13 2 -8 1.2
#> 108: -7 0.9 -86 2026-09-03 12:11:13 2 -7 0.9
#> 109: -7 2.8 -105 2026-09-03 12:11:13 2 -7 2.8
#> 110: -9 1.2 -125 2026-09-03 12:11:13 2 -9 1.2
# best performing configuration
instance$result
#> x1 x2 x_domain y
#> <num> <num> <list> <num>
#> 1: 1.095615 -3.078378 <list[2]> 9.175946