Skip to contents

PyCMAOpt() minimizes with the default CMA-ES of the Python package cma (pycma), ported to R: active covariance matrix adaptation with negative recombination weights, cumulative step size adaptation, lazy eigendecomposition, the bound transformation BoundTransform (a periodic linear-quadratic map into lb and ub, with the coordinate standard deviations limited to a third of the bound range) and the termination criteria of pycma. No derivatives are used. As in OptimizationPyCMA, the initial step size is 1.

Usage

PyCMAOpt()

Value

An algorithm object.

Details

The solve arguments map as in OptimizationPyCMA: maxiters to the option maxiter, maxtime to timeout (seconds), abstol to tolfun and reltol to tolfunrel. Further pycma options can be given by name: popsize, maxfevals, ftarget, tolx, tolfunhist, tolstagnation, tolupsigma, tolconditioncov, tolfacupx, tolflatfitness, tolxstagnation, maxstd, CMA_active and seed (the random numbers are R's). The return code is Success for the criteria ftarget, tolfun and tolx, MaxIters for maxiter and maxfevals, MaxTime for timeout, Failure for the stagnation and numerical criteria and Terminated when the callback halts. The solution's original holds xbest, fbest, countiter, countevals, stop (the criteria met), mean, sigma and C.

Examples

rosenbrock <- function(x, p) (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
prob <- OptimizationProblem(rosenbrock, c(0, 0), c(1, 100), lb = c(-1, -1), ub = c(0.8, 0.8))
sol <- solve(prob, PyCMAOpt(), seed = 42)
round(sol$u, 3); sol$retcode
#> [1] 0.80 0.64
#> [1] "Success"