Skip to contents

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():

mlr_optimizers$get("local_search")
opt("local_search")

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

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

# 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: 2.197966 -2.625208 <list[2]> 9.82034

# 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:   4.9  -2.0    0.5 2025-10-24 13:34:37        1         4.9        -2.0
#>   2:  -8.7  -1.0 -108.1 2025-10-24 13:34:37        1        -8.7        -1.0
#>   3:  -2.6  -1.4  -13.5 2025-10-24 13:34:37        1        -2.6        -1.4
#>   4:   3.2  -0.9    4.2 2025-10-24 13:34:37        1         3.2        -0.9
#>   5:   0.7  -4.8    5.1 2025-10-24 13:34:37        1         0.7        -4.8
#>  ---                                                                        
#> 106:   1.1  -0.5    2.8 2025-10-24 13:34:38        2         1.1        -0.5
#> 107:   1.7   1.8  -13.5 2025-10-24 13:34:38        2         1.7         1.8
#> 108:   1.7   0.4   -1.7 2025-10-24 13:34:38        2         1.7         0.4
#> 109:   0.2  -0.5    0.5 2025-10-24 13:34:38        2         0.2        -0.5
#> 110:  -0.8  -0.5   -4.5 2025-10-24 13:34:38        2        -0.8        -0.5

# best performing configuration
instance$result
#>          x1        x2  x_domain       y
#>       <num>     <num>    <list>   <num>
#> 1: 2.197966 -2.625208 <list[2]> 9.82034