CMA-ES with Restarts and Increasing Population Size (IPOP-CMA-ES)¶
CMA-ES that restarts with a larger population whenever it stalls. Use it for continuous problems with many local optima and a large budget.
IPOPCMAES ¶
IPOPCMAES(*, pop_size=None, sigma0=0.5, x0=None, pop_size_factor=2, max_restarts=None, tol_fun=1e-12, tol_hist_fun=1e-12, tol_x=None, max_condition=100000000000000.0, **kwargs)
IPOP-CMA-ES: CMA-ES that restarts with a larger population when it stops making progress.
Each run is the CMAES of this package. When a restart criterion holds, a new run
starts from a random mean with step size sigma0, and the population size is
multiplied by pop_size_factor. The number of parents is always lambda // 2. The best
solution over all runs is the result. Each restart evaluates its initial mean once.
Bounds are handled by reflection, as in CMAES (the paper used a penalty).
Parameters
pop_size: population size (lambda) of the first run. None (default) gives the CMA-ES default 4 + floor(3 ln n), where n is the number of codes.sigma0: initial step size of every run, in code units (the search space is [0, 1] per code). Default 0.5, half the width of the search space.x0: one starting solution (any formx0accepts), used as the initial mean of the first run. None (default) draws it at random. Later runs always start from a random mean.pop_size_factor: factor that multiplies lambda at each restart. Default 2. pycma calls itincpopsize.max_restarts: maximum number of restarts. None (default) means no limit. When the limit is reached and a restart criterion holds, the run stops with the reason "max_restarts".tol_fun: restart when the range of the best values of the last 10 + ceil(30 n / lambda) iterations and all values of the current iteration is below this. Default 1e-12. Use 0 to turn it off (it stops a run that has already converged to an exact optimum).tol_hist_fun: restart when 10 + ceil(30 n / lambda) iterations have passed and the range of their best values is below this. Equal values, also infinite ones, have range 0. Default 1e-12. Use 0 to turn it off.tol_x: restart when sigma times max(sqrt(C_ii), |pc_i|) is below this for every coordinate i. None (default) gives 1e-12 * sigma0.max_condition: restart when the condition number of C exceeds this. Default 1e14.
The paper's NoEffectAxis and NoEffectCoord criteria are always on. The criteria on objective values use only iterations whose samples are all feasible.
After a run, restarts is the number of restarts, lam_current the population size
of the last run, and restart_log a list of (nfe, new lambda, reason) for each restart.
References: A. Auger and N. Hansen, "A restart CMA evolution strategy with increasing population size", IEEE Congress on Evolutionary Computation (CEC 2005), pp. 1769 to 1776. N. Hansen, "The CMA Evolution Strategy: A Tutorial", arXiv:1604.00772 (2016).
Example¶
import ypea
problem = ypea.Problem(
ypea.Real("x", shape=20, lb=-10, ub=10),
lambda sol: ypea.benchmarks.sphere(sol.x),
vectorized=True,
name="sphere",
)
alg = ypea.IPOPCMAES(max_nfe=20_000)
result = alg.solve(problem, seed=1)
print(result.summary())
IPOP-CMA-ES on sphere
best objective value: 3.48847e-15
feasible: True (violation 0)
evaluations: 20000, iterations: 868, time: 0.174 s, stopped by: max_nfe
Differs from Python: MATLAB draws its own random numbers, so the best value differs from Python's.
problem = ypea.Problem( ...
vars=ypea.Real("x", shape=20, lb=-10, ub=10), ...
objective=@(sol) ypea.benchmarks.sphere(sol.x), ...
vectorized=true, ...
name="sphere");
alg = ypea.IPOPCMAES(max_nfe=20000);
result = alg.solve(problem, seed=1);
disp(result.summary())
IPOP-CMA-ES on sphere
best objective value: 1.33598e-15
feasible: true (violation 0)
evaluations: 20000, iterations: 871, time: 0.342 s, stopped by: max_nfe
Search on Rastrigin¶