Optimization via Covariance Matrix Adaptation Evolution Strategy
Source:R/OptimizerBatchCmaes.R
mlr_optimizers_cmaes.RdOptimizerBatchCmaes 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():
Parameters
sigmanumeric(1)start_valuescharacter(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. If set to"custom", the start values can be passed via thestartparameter.startnumeric()
Custom start values. Only applicable ifstart_valuesparameter is set to"custom".
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 classes
bbotk::Optimizer -> bbotk::OptimizerBatch -> OptimizerBatchCmaes
Examples
# example only runs if GenSA is available
if (mlr3misc::require_namespaces("adagio", quietly = TRUE)) {
# define the objective function
fun = function(xs) {
list(y = - (xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 - (xs[[3]] + 4)^2 + 10)
}
# set domain
domain = ps(
x1 = p_dbl(-10, 10),
x2 = p_dbl(-5, 5),
x3 = 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("cmaes")
# trigger optimization
optimizer$optimize(instance)
# all evaluated configurations
instance$archive
# best performing configuration
instance$result
}
#> x1 x2 x3 x_domain y
#> <num> <num> <num> <list> <num>
#> 1: 3.649141 -5 0.3082349 <list[3]> -15.28056