Skip to contents

OptimizerCmaes class that implements CMA-ES. Calls adagio::pureCMAES() from package adagio. The algorithm is typically applied to search space dimensions between three and fifty. Lower search space dimensions might crash.

Dictionary

This Optimizer can be instantiated via the dictionary mlr_optimizers or with the associated sugar function opt():

mlr_optimizers$get("cmaes")
opt("cmaes")

Parameters

sigma

numeric(1)

start_values

character(1)
Create random start values or based on center of search space? In the latter case, it is the center of the parameters before a trafo is applied.

For the meaning of the control parameters, see adagio::pureCMAES(). Note that we have removed all control parameters which refer to the termination of the algorithm and where our terminators allow to obtain the same behavior.

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 class

bbotk::Optimizer -> OptimizerCmaes

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

OptimizerCmaes$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (requireNamespace("adagio")) {
  search_space = domain = ps(
    x1 = p_dbl(-10, 10),
    x2 = p_dbl(-5, 5)
  )

  codomain = ps(y = p_dbl(tags = "maximize"))

  objective_function = function(xs) {
    c(y = -(xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10)
  }

  objective = ObjectiveRFun$new(
    fun = objective_function,
    domain = domain,
    codomain = codomain)

  instance = OptimInstanceSingleCrit$new(
    objective = objective,
    search_space = search_space,
    terminator = trm("evals", n_evals = 10))

  optimizer = opt("cmaes")

  # modifies the instance by reference
  optimizer$optimize(instance)

  # returns best scoring evaluation
  instance$result

  # allows access of data.table of full path of all evaluations
  as.data.table(instance$archive$data)
}
#>             x1         x2            y  x_domain           timestamp batch_nr
#>          <num>      <num>        <num>    <list>              <POSc>    <int>
#>  1:  10.000000 -0.2451810  -61.5890278 <list[2]> 2024-02-29 15:32:24        1
#>  2: -10.000000 -0.9713821 -138.1152905 <list[2]> 2024-02-29 15:32:24        2
#>  3:   5.820819  5.0000000  -68.5986576 <list[2]> 2024-02-29 15:32:24        3
#>  4:   9.655627 -2.7708125  -48.6611556 <list[2]> 2024-02-29 15:32:24        4
#>  5:   8.455630 -0.8326131  -36.3727215 <list[2]> 2024-02-29 15:32:24        5
#>  6:  10.000000  5.0000000 -118.0000000 <list[2]> 2024-02-29 15:32:24        6
#>  7:   4.744545 -1.1647937   -0.9005111 <list[2]> 2024-02-29 15:32:24        7
#>  8:  10.000000 -0.9023483  -58.4001426 <list[2]> 2024-02-29 15:32:24        8
#>  9:  10.000000  1.8585285  -77.6052990 <list[2]> 2024-02-29 15:32:24        9
#> 10:   8.779057 -2.1023506  -36.7613948 <list[2]> 2024-02-29 15:32:24       10