Covariance Matrix Adaption - Evolutionary Strategy in R.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
R
images
man
tests
.Rbuildignore
.gitignore
.travis.yml
DESCRIPTION
LICENSE
NAMESPACE
NEWS
README.md
appveyor.yml
test_all.R
test_specific.R

README.md

cmaesr: Covariance Matrix Adaptation - Evolution Strategy in R

CRAN Status Badge CRAN Downloads Build Status Build status Coverage Status

Description

The cmaesr package implements the popular Covariance Matrix Adaptation - Evolution Strategy [2, 3] optimizer for numerical optimization problems in pure R. The main features of the package are:

  • Extensible S3 based system for stopping conditions.
  • Possibility to enable restarting [1] with flexible declaration of restart-triggering stopping conditions.
  • Nice visualization of 2D optimization runs for, e.g., teaching purposes.

Visualization of the distribution in an examplary optimization run on the sphere function

[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.

Installation Instructions

The package will be available in a first version at CRAN soon. If you are interested in trying out and playing around with the current github developer version use the devtools package and type the following command in R:

devtools::install_github("jakobbossek/cmaesr")

Example

Assume we want to minimize the 2D Ackeley Function. To accomplish this task with cmaesr we need to define the objective function as a smoof function. This function is then passed with some control arguments to the main function of the packge.

library(cmaesr)

# first generate the objective smoof function
fn = makeAckleyFunction(dimensions = 2L)
res = cmaes(
    fn, 
    monitor = makeSimpleMonitor(),
    control = list(
        sigma = 1.5, # initial step size
        lambda = 50, # number of offspring
        stop.ons = c(
            list(stopOnMaxIters(100)), # stop after 100 iteration ...
            getDefaultStoppingConditions() # ... or after some default stopping conditions
        )
    )
)
print(res)

For 2D functions a monitor for visualization is included.

library(cmaesr)

# generate the objective function
fn = makeSphereFunction(dimensions = 2L)
res = cmaes(
    fn,
    monitor = makeVisualizingMonitor(
        show.distribution = TRUE, show.last = TRUE
    ),
    control = list(
        sigma = 1, lambda = 100,
        stop.ons = list(stopOnMaxIters(15L))
    )
)

Contact

Please address questions and missing features about the cmaesr package to the author Jakob Bossek j.bossek@gmail.com. Found some nasty bugs? Please use the issue tracker for this. Pay attention to explain the problem as good as possible. At its best you provide an example, so I can reproduce your problem.