Parameters

class modcma.parameters.Parameters(*args, **kwargs)

Bases: modcma.utils.AnnotatedStruct

AnnotatedStruct object for holding the parameters for the ModularCMAES.

d

The dimensionality of the problem

Type

int

x0

Initial guess of the population center of mass.

Type

np.ndarray

target

The absolute target of the optimization problem

Type

float = -float(“inf”)

budget

The maximum number of iterations

Type

int = None

n_generations

The number of generations to run the optimizer. If this value is specified this will override the default break-conditions, and the optimizer will only stop after n_generations. Target-reached and budget will be ignored.

Type

int = None

lambda_

The number of offspring in the population

Type

int = None

mu

The number of parents in the population

Type

int = None

sigma0

The initial value of sigma (step size)

Type

float = .5

a_tpa

Parameter used in TPA

Type

float = .5

b_tpa

Parameter used in TPA

Type

float = 0.

cs

Learning rate for the cumulation of the step size control

Type

float = None

cc

Learning rate for the rank-one update

Type

float = None

cmu

Learning rate for the rank-mu update

Type

float = None

c1

Learning rate for the rank-one update

Type

float = None

seq_cutoff_factor

Used in sequential selection, the number of times mu individuals must be seen before a sequential break can be performed

Type

int = 1

ub

The upper bound, used for bound correction and threshold convergence

Type

np.array = None

lb

The lower bound, used for bound correction and threshold convergence

Type

np.array = None

init_threshold

The initial length theshold used in treshold convergence

Type

float = 0.2

decay_factor

The decay for the threshold used in threshold covergence

Type

float = 0.995

max_resamples

The maximum amount of resamples which can be done when ‘dismiss’-boundary correction is used

Type

int

active
Specifying whether to use active update.

[1] G. Jastrebski, D. V. Arnold, et al. Improving evolution strategies through active covariance matrix adaptation. In Evolutionary Computation (CEC), 2006 IEEE Congress on, pages 2814–2821. IEEE, 2006

Type

bool = False

elitist

Specifying whether to use an elitist approach

Type

bool = False

sequential
Specifying whether to use sequential selection

[3] D. Brockhoff, A. Auger, N. Hansen, D. V. Arnold, and T. Hohm. Mirrored Sampling and Sequential Selection for Evolution Strategies. In R. Schaefer, C. Cotta, J. Kołodziej, and G. Rudolph, editors, Parallel Problem Solving from Nature, PPSN XI: 11th International Conference, Kraków, Poland, September 11-15, 2010, Proceedings, Part I, pages 11–21, Berlin, Heidelberg, 2010. Springer Berlin Heidelberg.

Type

bool = False

threshold_convergence
Specifying whether to use threshold convergence

[4] A. Piad-Morffis, S. Estevez-Velarde, A. Bolufe-Rohler, J. Montgomery, and S. Chen. Evolution strategies with thresheld convergence. In Evolutionary Computation (CEC), 2015 IEEE Congress on, pages 2097– 2104, May 2015.

Type

bool = False

bound_correction

Specifying whether to use bound correction to enforce ub and lb

Type

str = (None, ‘saturate’, ‘unif_resample’, ‘COTN’, ‘toroidal’, ‘mirror’,)

orthogonal
Specifying whether to use orthogonal sampling

[5] H. Wang, M. Emmerich, and T. Bäck. Mirrored Orthogonal Sampling with Pairwise Selection in Evolution Strategies. In Proceedings of the 29th Annual ACM Symposium on Applied Computing, pages 154–156.

Type

bool = False

local_restart
Specifying which local restart strategy should be used
IPOP:

[11] Anne Auger and Nikolaus Hansen. A restart cma evolution strategy with increasing population size. volume 2, pages 1769–1776, 01 2005

Type

str = (None, ‘IPOP’, )

base_sampler

Denoting which base sampler to use, ‘sobol’, ‘halton’ can be selected to sample from a quasi random sequence.

[6] A. Auger, M. Jebalia, and O. Teytaud. Algorithms (x, sigma, eta): random mutations for evolution strategies. In Artificial Evolution: 7th International Conference, Revised Selected Papers, pages 296–307. Springer, 2006.

Type

str = (‘gaussian’, ‘sobol’, ‘halton’,)

mirrored
Specifying whether to use mirrored sampling

[2] D. Brockhoff, A. Auger, N. Hansen, D. V. CMAEST. Hohm. Mirrored Sampling and Sequential SelectioCMAESion Strategies. In R. Schaefer, C. Cotta, J. Kołodziej, aCMAESh, editors, Parallel Problem Solving from Nature, PPSN XI: 11tCMAESnal Conference, Kraków, Poland, September 11-15, 2010, PrCMAESart I, pages 11–21, Berlin, Heidelberg, 2010. SpringerCMAESelberg. ACM, 2014.

Type

str = (None, ‘mirrored’, mirrored pairwise’, )

weights_option
Denoting the recombination weigths to be used.

[7] Sander van Rijn, Hao Wang, Matthijs van Leeuwen, and Thomas Bäck. 2016. Evolving the Structure of Evolution Strategies. Computer 49, 5 (May 2016), 54–63.

Type

str = (‘default’, ‘1/mu’, ‘1/2^mu’, )

step_size_adaptation

Specifying which step size adaptation mechanism should be used. csa:

[8] Nikolaus Hansen. The CMA evolution strategy: A tutorial.CoRR, abs/1604.00772, 2016

tpa:

[9] Nikolaus Hansen. CMA-ES with two-point step-size adaptation.CoRR, abs/0805.0231,2008.

msr:

[10] Ouassim Ait Elhara, Anne Auger, and Nikolaus Hansen. A Median Success Rule for Non-Elitist Evolution Strategies: Study of Feasibility. In Blum et al. Christian, editor,Genetic and Evolutionary Computation Conference, pages 415–422, Amsterdam, Nether-lands, July 2013. ACM, ACM Press.

Type

str = (‘csa’, ‘tpa’, ‘msr’, )

population

The current population of individuals

Type

TypeVar(‘Population’) = None

old_population

The old population of individuals

Type

TypeVar(‘Population’) = None

termination_criteria

A dictionary of termination criteria

Type

dict = {}

ipop_factor

The factor to increase the population after each resart (IPOP)

Type

int = 2

tolx

Use to compute restart condition

Type

float = 10e-12

tolup_sigma

Use to compute restart condition

Type

float = 10e20

condition_cov

Use to compute restart condition

Type

float = 10e14

ps_factor

Determines the frequence of exploration/expliotation 1 is neutral, lower is more expliotative, higher is more explorative

Type

float = 1.

sample_sigma

Whether to sample sigma for each individual from a lognormal distribution.

Type

bool = Flase

sampler

A generator object producing new samples

Type

generator

used_budget

The number of function evaluations used

Type

int

fopt

The fitness of the current best individual

Type

float

t

The number of generations

Type

int

sigma_over_time

The value sigma has in each generation

Type

list

best_fopts

The value of fopt in each generation

Type

list

median_fitnesses

The median fitness value in each generation

Type

list

best_fitnesses

The best fitness value observed in each generation

Type

list

flat_fitnesses = deque

A deque containing boolean values denoting if a flat fitness value is observed in recent generations

restarts

A list containing the t values (generations) where a restart has taken place

Type

list

seq_cutoff

The number of individuals that must be seen before a sequential break can be performed

Type

int

diameter

The diameter of the search space

Type

float

max_iter

The maximum number of iterations that can occur between two restarts.

Type

float

nbin

Used to determine a window for equal function values

Type

int

n_stagnation

Used to determine a window for stagnation

Type

int

flat_fitness_index

Used to determine which ranked individual should be the same as the first indivual in order to determine flat fitness values.

Type

int

sigma

The step size

Type

float

m

The mean value of the individuals

Type

np.ndarray

dm

The difference in the new mean value of the individuals versus the old mean value.

Type

np.ndarray

pc

The evolution path

Type

np.ndarray

ps

The conjugate evolution path

Type

np.ndarray

C

The covariance matrix

Type

np.ndarray

B

The eigenvectors of the covariance matrix C

Type

np.ndarray

D

The eigenvalues of the covariance matrix C

Type

np.ndarray

inv_root_C

The result of C**-(1/2)

Type

np.ndarray

s

Used for TPA

Type

float

rank_tpa

Used for TPA

Type

float

weights

The recombination weights.

Type

np.ndarray

pweights

The positive recombination weights.

Type

np.ndarray

nweights

The negative recombination weights, used in active update

Type

np.ndarray

mueff

The variance effective selection mass

Type

float

damps

Used for adapting sigma with csa

Type

float

chiN

Value approaching E||N(0,I)||

Type

np.ndarray

ds

Used for msr

Type

float

threshold

The length threshold used in threshold convergence

Type

float

last_restart

The generation in where the last restart has occored

Type

int

max_resamples

The maximum amount of resamples which can be done when ‘dismiss’-boundary correction is used

Type

int

n_out_of_bounds

The number of individals that are sampled out of bounds

Type

int

Attributes Summary

a_tpa

Data descriptor checks for correct types.

active

Data descriptor checks for correct types.

b_tpa

Data descriptor checks for correct types.

base_sampler

Descriptor, checks of value is Any of a specified sequence of options.

bound_correction

Descriptor, checks of value is Any of a specified sequence of options.

budget

Data descriptor checks for correct types.

c1

Data descriptor checks for correct types.

cc

Data descriptor checks for correct types.

cmu

Data descriptor checks for correct types.

compute_termination_criteria

Data descriptor checks for correct types.

condition_cov

Data descriptor checks for correct types.

cs

Data descriptor checks for correct types.

d

Data descriptor checks for correct types.

decay_factor

Data descriptor checks for correct types.

elitist

Data descriptor checks for correct types.

init_threshold

Data descriptor checks for correct types.

ipop_factor

Data descriptor checks for correct types.

lambda_

Data descriptor checks for correct types.

last_restart

Return the last index of self.restarts.

lb

Data descriptor checks for correct types.

local_restart

Descriptor, checks of value is Any of a specified sequence of options.

max_resamples

Data descriptor checks for correct types.

mirrored

Descriptor, checks of value is Any of a specified sequence of options.

mu

Data descriptor checks for correct types.

old_population

Data descriptor checks for correct types.

orthogonal

Data descriptor checks for correct types.

population

Data descriptor checks for correct types.

ps_factor

Data descriptor checks for correct types.

seq_cutoff_factor

Data descriptor checks for correct types.

sequential

Data descriptor checks for correct types.

step_size_adaptation

Descriptor, checks of value is Any of a specified sequence of options.

target

Data descriptor checks for correct types.

termination_criteria

Data descriptor checks for correct types.

threshold

Calculate threshold for mutation, used in threshold convergence.

threshold_convergence

Data descriptor checks for correct types.

tolup_sigma

Data descriptor checks for correct types.

tolx

Data descriptor checks for correct types.

ub

Data descriptor checks for correct types.

weights_option

Descriptor, checks of value is Any of a specified sequence of options.

Methods Summary

adapt()

Method for adapting the internal state parameters.

adapt_covariance_matrix()

Method for adapting the covariance matrix.

adapt_sigma()

Method to adapt the step size sigma.

calculate_termination_criteria()

Method for computing restart criteria.

from_config_array(d, config_array)

Instantiate a Parameters object from a configuration array.

get_sampler()

Function to return a sampler generator based on the values of other parameters.

init_adaptation_parameters()

Initialization function for parameters for self-adaptive processes.

init_dynamic_parameters()

Initialization function of parameters that represent the dynamic state of the CMA-ES.

init_fixed_parameters()

Initialization function for parameters that are not restarted during a run.

init_local_restart_parameters()

Initialization function for parameters for local restart strategies, i.e. IPOP.

init_selection_parameters()

Initialization function for parameters that influence in selection.

load(filename)

Load stored parameter objects from pickle.

perform_eigendecomposition()

Method to perform eigendecomposition.

perform_local_restart()

Method performing local restart, if a restart strategy is specified.

record_statistics()

Method for recording metadata.

save([filename])

Save a parameters object to pickle.

Attributes Documentation

a_tpa: float

Data descriptor checks for correct types.

active: bool

Data descriptor checks for correct types.

b_tpa: float

Data descriptor checks for correct types.

base_sampler: gaussian, sobol, halton

Descriptor, checks of value is Any of a specified sequence of options.

bound_correction: None, saturate, unif_resample, COTN, toroidal, mirror

Descriptor, checks of value is Any of a specified sequence of options.

budget: int

Data descriptor checks for correct types.

c1: float

Data descriptor checks for correct types.

cc: float

Data descriptor checks for correct types.

cmu: float

Data descriptor checks for correct types.

compute_termination_criteria: bool

Data descriptor checks for correct types.

condition_cov: float

Data descriptor checks for correct types.

cs: float

Data descriptor checks for correct types.

d: int

Data descriptor checks for correct types.

decay_factor: float

Data descriptor checks for correct types.

elitist: bool

Data descriptor checks for correct types.

init_threshold: float

Data descriptor checks for correct types.

ipop_factor: int

Data descriptor checks for correct types.

lambda_: int

Data descriptor checks for correct types.

last_restart

Return the last index of self.restarts.

lb: numpy.ndarray

Data descriptor checks for correct types.

local_restart: None, IPOP, BIPOP

Descriptor, checks of value is Any of a specified sequence of options.

max_resamples: int

Data descriptor checks for correct types.

mirrored: None, mirrored, mirrored pairwise

Descriptor, checks of value is Any of a specified sequence of options.

mu: int

Data descriptor checks for correct types.

old_population: Population

Data descriptor checks for correct types.

orthogonal: bool

Data descriptor checks for correct types.

population: Population

Data descriptor checks for correct types.

ps_factor: float

Data descriptor checks for correct types.

seq_cutoff_factor: int

Data descriptor checks for correct types.

sequential: bool

Data descriptor checks for correct types.

step_size_adaptation: csa, tpa, msr, xnes, m-xnes, lp-xnes, psr

Descriptor, checks of value is Any of a specified sequence of options.

target: float

Data descriptor checks for correct types.

termination_criteria: dict

Data descriptor checks for correct types.

threshold

Calculate threshold for mutation, used in threshold convergence.

threshold_convergence: bool

Data descriptor checks for correct types.

tolup_sigma: float

Data descriptor checks for correct types.

tolx: float

Data descriptor checks for correct types.

ub: numpy.ndarray

Data descriptor checks for correct types.

weights_option: default, equal, 1/2^lambda

Descriptor, checks of value is Any of a specified sequence of options.

Methods Documentation

adapt() → None

Method for adapting the internal state parameters.

The conjugate evolution path ps is calculated, in addition to the difference in mean x values dm. Thereafter, sigma is adapated, followed by the adapatation of the covariance matrix. TODO: eigendecomp is not neccesary to be beformed every iteration, says CMAES tut.

adapt_covariance_matrix() → None

Method for adapting the covariance matrix.

If the option active is specified, active update of the covariance matrix is performed, using negative weights.

adapt_sigma() → None

Method to adapt the step size sigma.

There are three variants in implemented here, namely:

~ Cummulative Stepsize Adaptation (csa) ~ Two-Point Stepsize Adaptation (tpa) ~ Median Success Rule (msr) ~ xNES step size adaptation (xnes) ~ median-xNES step size adaptation (m-xnes) ~ xNES with Log-normal Prior step size adaptation (lp-xnes) ~ Population Step Size rule from lm-cmaes (psr)

One of these methods can be selected by setting the step_size_adaptation parameter.

calculate_termination_criteria() → None

Method for computing restart criteria.

Only computes when a local restart strategy is specified, or when explicitly told to do so, i.e.: self.compute_termination_criteria = True

static from_config_array(d: int, config_array: list)modcma.parameters.Parameters

Instantiate a Parameters object from a configuration array.

Parameters
  • d (int) – The dimensionality of the problem

  • config_array (list) –

    A list of length len(Parameters.__modules__),

    containing ints from 0 to 2

Returns

Return type

A new Parameters instance

get_sampler() → Generator

Function to return a sampler generator based on the values of other parameters.

Returns

a sampler

Return type

generator

init_adaptation_parameters() → None

Initialization function for parameters for self-adaptive processes.

Examples are recombination weights and learning rates for the covariance matrix adapation.

init_dynamic_parameters() → None

Initialization function of parameters that represent the dynamic state of the CMA-ES.

Examples of such parameters are the Covariance matrix C and its eigenvectors and the learning rate sigma.

init_fixed_parameters() → None

Initialization function for parameters that are not restarted during a run.

init_local_restart_parameters() → None

Initialization function for parameters for local restart strategies, i.e. IPOP.

TODO: check if we can move this to separate object.

init_selection_parameters() → None

Initialization function for parameters that influence in selection.

static load(filename: str)modcma.parameters.Parameters

Load stored parameter objects from pickle.

Parameters

filename (str) – A file path

Returns

Return type

A Parameters object

perform_eigendecomposition() → None

Method to perform eigendecomposition.

If sigma or the coveriance matrix has degenerated, the dynamic parameters are reset.

perform_local_restart() → None

Method performing local restart, if a restart strategy is specified.

record_statistics() → None

Method for recording metadata.

save(filename: str = 'parameters.pkl') → None

Save a parameters object to pickle.

Parameters

filename (str) – The name of the file to save to.