Title: | Covariance Matrix Adaptation Evolution Strategy |
---|---|
Description: | Pure R implementation of the Covariance Matrix Adaptation - Evolution Strategy (CMA-ES) with optional restarts (IPOP-CMA-ES). |
Authors: | Jakob Bossek [aut, cre] |
Maintainer: | Jakob Bossek <[email protected]> |
License: | BSD_2_clause + file LICENSE |
Version: | 1.0.3 |
Built: | 2025-01-20 03:25:14 UTC |
Source: | https://github.com/jakobbossek/cmaesr |
This funtions serves to call a specific monitor step.
callMonitor(monitor, step, envir = parent.frame())
callMonitor(monitor, step, envir = parent.frame())
monitor |
[ |
step |
[ |
envir |
[ |
Performs non-linear, non-convex optimization by means of the Covariance Matrix Adaptation - Evolution Strategy (CMA-ES).
cmaes(objective.fun, start.point = NULL, monitor = makeSimpleMonitor(), control = list(stop.ons = c(getDefaultStoppingConditions())))
cmaes(objective.fun, start.point = NULL, monitor = makeSimpleMonitor(), control = list(stop.ons = c(getDefaultStoppingConditions())))
objective.fun |
[ |
start.point |
[ |
monitor |
[ |
control |
[ |
This is a pure R implementation of the popular CMA-ES optimizer for continuous black box optimization [2, 3]. It features a flexible system of stopping conditions and enables restarts [1], which can be triggered by arbitrary stopping conditions and can lead to superior performance on multimodal problems.
You may pass additional parameters to the CMA-ES via the control
argument.
This argument must be a named list. The following control elements will be considered
by the CMA-ES implementation:
integer(1)
]Number of offspring generated in each generation.
integer(1)
]Number of individuals in each population. Defaults to .
numeric
]Numeric vector of positive weights.
numeric(1)
]Initial step-size. Default is 0.5.
character
]List of stopping condition codes / short names (see
makeStoppingCondition
). All stopping conditions which are placed in this vector do trigger a restart
instead of leaving the main loop. Default is the empty character vector, i.e., restart is not triggered.
integer(1)
]Maximal number of restarts. Default is 0. If set
to >= 1, the CMA-ES is restarted with a higher population size if at least one of the
stoppping conditions is defined as a restart trigger restart.triggers
.
numeric(1)
]Factor which is used to increase the population size after restart. Default is 2.
list
]List of stopping conditions. The default is to stop after 10 iterations or after a
kind of a stagnation (see getDefaultStoppingConditions
).
logical(1L)
]Should each population be stored? Default is FALSE
.
[cma_result
] Result object. Internally a list with the following
components:
ParamSet
]Parameter set of the objective function.
numeric
]Final best parameter setting.
numeric(1L)
]Fitness value of the best.param
.
integer(1L)
]Number of function evaluations performed.
integer(1L)
]Running time of the optimization in seconds.
integer(1L)
]Number of restarts.
list
]Trace of population.
character(1L)
]Message generated by stopping condition.
Internally a check for an indefinite covariance matrix is always performed, i.e., this stopping condition is always prepended internally to the list of stopping conditions.
[1] Auger and Hansen (2005). A Restart CMA Evolution Strategy With Increasing Population Size. In IEEE Congress on Evolutionary Computation, CEC 2005, Proceedings, pp. 1769-1776. [2] N. Hansen (2006). The CMA Evolution Strategy: A Comparing Review. In J.A. Lozano, P. Larranaga, I. Inza and E. Bengoetxea (Eds.). Towards a new evolutionary computation. Advances in estimation of distribution algorithms. Springer, pp. 75-102. [3] Hansen and Ostermeier (1996). Adapting arbitrary normal mutation distributions in evolution strategies: The covariance matrix adaptation. In Proceedings of the 1996 IEEE International Conference on Evolutionary Computation, pp. 312-317.
# generate objective function from smoof package fn = makeRosenbrockFunction(dimensions = 2L) res = cmaes( fn, monitor = NULL, control = list( sigma = 1.5, lambda = 40, stop.ons = c(list(stopOnMaxIters(100L)), getDefaultStoppingConditions()) ) ) print(res)
# generate objective function from smoof package fn = makeRosenbrockFunction(dimensions = 2L) res = cmaes( fn, monitor = NULL, control = list( sigma = 1.5, lambda = 40, stop.ons = c(list(stopOnMaxIters(100L)), getDefaultStoppingConditions()) ) ) print(res)
Default stopping conditions which are active in the reference implementation by Nico Hansen in Python.
getDefaultStoppingConditions()
getDefaultStoppingConditions()
[list
]
Monitors can be pluged in the main cmaes
function.
They have full access to the environment of the optimization routine and can
be used to write/log/visualize relevant data in each iteration.
makeMonitor(before = NULL, step = NULL, after = NULL, ...)
makeMonitor(before = NULL, step = NULL, after = NULL, ...)
before |
[ |
step |
[ |
after |
[ |
... |
[ |
[cma_monitor
]
Monitor object.
makeSimpleMonitor
, makeVisualizingMonitor
The simple monitor prints the iteration, current best parameter values and best fitness to the standard output.
makeSimpleMonitor(max.params = 4L)
makeSimpleMonitor(max.params = 4L)
max.params |
[ |
[cma_monitor
]
A list of stopping conditions can be passed to the cmaes
function. Instead of hardconding the stopping criteria into the main function
they exist as stand-alone functions for maximal flexibility and extendability.
makeStoppingCondition(name, message, stop.fun, code = name, control = list())
makeStoppingCondition(name, message, stop.fun, code = name, control = list())
name |
[ |
message |
[ |
stop.fun |
[ |
code |
[ |
control |
[ |
[cma_stopping_condition
] Stopping condition object.
This generator visualizes the optimization process for two-dimensional functions by means of ggplot2.
makeVisualizingMonitor(show.last = FALSE, show.distribution = TRUE, xlim = NULL, ylim = NULL)
makeVisualizingMonitor(show.last = FALSE, show.distribution = TRUE, xlim = NULL, ylim = NULL)
show.last |
[ |
show.distribution |
[ |
xlim |
[ |
ylim |
[ |
The plot contains points representing the current population, the center of mass or mean value of the population respectively. Optionally an ellipsis represneting the normal distribution of the points can be depicted.
[cma_monitor
]
Stop if condition number of covariance matrix exceeds tolerance value.
stopOnCondCov(tol = 1e+14)
stopOnCondCov(tol = 1e+14)
tol |
[ |
[cma_stopping_condition
]
Other stopping.conditions: stopOnMaxIters
,
stopOnNoEffectAxis
,
stopOnNoEffectCoord
,
stopOnOptParam
,
stopOnOptValue
,
stopOnTimeBudget
Stop if maximal number of function evaluations is reached.
stopOnMaxEvals(max.evals)
stopOnMaxEvals(max.evals)
max.evals |
[ |
[cma_stopping_condition
]
Stop on maximal number of iterations.
stopOnMaxIters(max.iter = 100L)
stopOnMaxIters(max.iter = 100L)
max.iter |
[integer(1)] |
[cma_stopping_condition
]
Other stopping.conditions: stopOnCondCov
,
stopOnNoEffectAxis
,
stopOnNoEffectCoord
,
stopOnOptParam
,
stopOnOptValue
,
stopOnTimeBudget
Stop if addition of 0.1 * sigma in a principal axis direction does not change mean value.
stopOnNoEffectAxis()
stopOnNoEffectAxis()
[cma_stopping_condition
]
Other stopping.conditions: stopOnCondCov
,
stopOnMaxIters
,
stopOnNoEffectCoord
,
stopOnOptParam
,
stopOnOptValue
,
stopOnTimeBudget
Stop if addition of 0.2 * standard deviations in any coordinate does not change mean value.
stopOnNoEffectCoord()
stopOnNoEffectCoord()
[cma_stopping_condition
]
Other stopping.conditions: stopOnCondCov
,
stopOnMaxIters
,
stopOnNoEffectAxis
,
stopOnOptParam
,
stopOnOptValue
,
stopOnTimeBudget
Stop if euclidean distance of parameter is below some tolerance value.
stopOnOptParam(opt.param, tol = 1e-08)
stopOnOptParam(opt.param, tol = 1e-08)
opt.param |
[ |
tol |
[ |
[cma_stopping_condition
]
Other stopping.conditions: stopOnCondCov
,
stopOnMaxIters
,
stopOnNoEffectAxis
,
stopOnNoEffectCoord
,
stopOnOptValue
,
stopOnTimeBudget
Stop if best solution is close to optimal objective value.
stopOnOptValue(opt.value, tol = 1e-08)
stopOnOptValue(opt.value, tol = 1e-08)
opt.value |
[ |
tol |
[ |
[cma_stopping_condition
]
Other stopping.conditions: stopOnCondCov
,
stopOnMaxIters
,
stopOnNoEffectAxis
,
stopOnNoEffectCoord
,
stopOnOptParam
,
stopOnTimeBudget
Stop if maximal running time budget is reached.
stopOnTimeBudget(budget)
stopOnTimeBudget(budget)
budget |
[ |
[cma_stopping_condition
]
Other stopping.conditions: stopOnCondCov
,
stopOnMaxIters
,
stopOnNoEffectAxis
,
stopOnNoEffectCoord
,
stopOnOptParam
,
stopOnOptValue
Stop if the standard deviation falls below a tolerance value in all coordinates?
stopOnTolX(tol = 1e-12)
stopOnTolX(tol = 1e-12)
tol |
[ |
[cma_stopping_condition
]