module documentation

Parameters and Options for CMA-ES.

Class CMAOptions a dictionary with the available options and their default values for class CMAEvolutionStrategy.
Class CMAParameters strategy parameters like population size and learning rates.
Class MetaParameters collection of many meta parameters.
Function amend_restarts_parameter return a dict with 'maxrestarts' and 'maxfevals' as keys.
Function cma_default_options_ use this function to get keyword completion for CMAOptions.
Function integer_lower_bound_target_probability target probability for an integer mutation assuming a centered mean
Function integer_std_lower_bound can be reassigned/overwritten like a global "parameter setting"
Function is_feasible default to check feasibility of f-values.
Function safe_str return a string safe to eval or raise an exception.
Variable cma_allowed_options_keys Undocumented
Variable cma_default_options Undocumented
Variable cma_versatile_options Undocumented
Variable default_restart_number_if_not_zero Undocumented
Variable integer_active_limit_recombination_weight_condition None or True or a function float->bool, None -> limit only negative updates
Variable integer_std_lower_bound_factor1 factor used in integer_std_lower_bound as multiplier to mueff/N
Variable integer_std_lower_bound_factor2 factor used in integer_std_lower_bound as multiplier to integer_std_lower_bound_limit_when_mu_is_large
Variable integer_std_lower_bound_limit limit coordinate stds of solutions in C update, by default off, may go away
Variable options_environment Undocumented
def amend_restarts_parameter(restarts):

return a dict with 'maxrestarts' and 'maxfevals' as keys.

restarts is a parameter to cma.fmin*, see cma.fmin.

def cma_default_options_(AdaptSigma='True # or False or any CMAAdaptSigmaBase class e.g. CMAAdaptSigmaTPA, CMAAdaptSigmaCSA', CMA_active='True # negative update, conducted after the original update', CMA_active_injected='0 #v weight multiplier for negative weights of injected solutions', CMA_cmean='1 # learning rate for the mean value', CMA_const_trace='False # normalize trace, 1, True, "arithm", "geom", "aeig", "geig" are valid', CMA_diagonal='0*100*N/popsize**0.5 # nb of iterations with diagonal covariance matrix, True for always', CMA_diagonal_decoding='0 # learning rate multiplier for additional diagonal update', CMA_eigenmethod='np.linalg.eigh # or cma.utilities.math.eig or pygsl.eigen.eigenvectors', CMA_elitist='False #v or "initial" or True, elitism likely impairs global search performance', CMA_injections_threshold_keep_len='1 #v keep length if Mahalanobis length is below the given relative threshold', CMA_mirrors='popsize < 6 # values <0.5 are interpreted as fraction, values >1 as numbers (rounded), for `True` about 0.16 is used', CMA_mirrormethod='2 # 0=unconditional, 1=selective, 2=selective with delay', CMA_mu='None # parents selection parameter, default is popsize // 2', CMA_on='1 # multiplier for all covariance matrix updates', CMA_sampler='None # a class or instance that implements the interface of `cma.interfaces.StatisticalModelSamplerWithZeroMeanBaseClass`', CMA_sampler_options='{} # options passed to `CMA_sampler` class init as keyword arguments', CMA_rankmu='1.0 # multiplier for rank-mu update learning rate of covariance matrix', CMA_rankone='1.0 # multiplier for rank-one update learning rate of covariance matrix', CMA_recombination_weights='None # a list, see class RecombinationWeights, overwrites CMA_mu and popsize options', CMA_dampsvec_fac='np.inf # tentative and subject to changes, 0.5 would be a "default" damping for sigma vector update', CMA_dampsvec_fade='0.1 # tentative fading out parameter for sigma vector update', CMA_teststds='None # factors for non-isotropic initial distr. of C, mainly for test purpose, see CMA_stds for production', CMA_stds='None # multipliers for sigma0 in each coordinate (not represented in C), or use `cma.ScaleCoordinates` instead', CSA_dampfac='1 #v positive multiplier for step-size damping, 0.3 is close to optimal on the sphere', CSA_damp_mueff_exponent='None # exponent for mueff/N, by default 0.5 and 1 if CSA_squared, zero means no dependency of damping on mueff, useful with CSA_disregard_length option', CSA_disregard_length='False #v True is untested, also changes respective parameters', CSA_clip_length_value='None #v poorly tested, [0, 0] means const length N**0.5, [-1, 1] allows a variation of +- N/(N+2), etc.', CSA_squared='False #v use squared length for sigma-adaptation ', CSA_invariant_path='False #v pc is invariant and ps (default) is unbiased', stall_sigma_change_on_divergence_iterations='False #v number of iterations of median worsenings threshold at which the sigma change is stalled; the default may become 2', BoundaryHandler='BoundTransform # or BoundPenalty, unused when ``bounds in (None, [None, None])``', bounds='[None, None] # lower (=bounds[0]) and upper domain boundaries, each a scalar or a list/vector', conditioncov_alleviate='[1e8, 1e12] # when to alleviate the condition in the coordinates and in main axes', eval_final_mean='True # evaluate the final mean, which is a favorite return candidate', fixed_variables='None # dictionary with index-value pairs like {0:1.1, 2:0.1} that are not optimized', ftarget='-inf #v target function value, minimization', integer_variables='[] # index list, invokes basic integer handling by setting minstd of integer variables if it was not given and by integer centering', is_feasible='is_feasible #v a function that computes feasibility, by default lambda x, f: f not in (None, np.nan)', maxfevals='inf #v maximum number of function evaluations', maxiter='100 + 150 * (N+3)**2 // popsize**0.5 #v maximum number of iterations', mean_shift_line_samples='False #v sample two new solutions colinear to previous mean shift', mindx='0 #v minimal std in any arbitrary direction, cave interference with tol*', minstd='0 #v minimal std (scalar or vector) in any coordinate direction, cave interference with tol*', maxstd='None #v maximal std (scalar or vector) in any coordinate direction', maxstd_boundrange='1/3 # maximal std relative to bound_range per coordinate, overruled by maxstd', pc_line_samples='False #v one line sample along the evolution path pc', popsize='4 + 3 * np.log(N) # population size, AKA lambda, int(popsize) is the number of new solution per iteration', popsize_factor='1 # multiplier for popsize, convenience option to increase default popsize', randn='np.random.randn #v randn(lam, N) must return an np.array of shape (lam, N), see also cma.utilities.math.randhss', scaling_of_variables='None # deprecated, rather use fitness_transformations.ScaleCoordinates instead (or CMA_stds). WAS: Scale for each variable in that effective_sigma0 = sigma0*scaling. Internally the variables are divided by scaling_of_variables and sigma is unchanged, default is `np.ones(N)`', seed='time # random number seed for `numpy.random`; `None` and `0` equate to `time`, `np.nan` means "do nothing", see also option "randn"', signals_filename='cma_signals.in # read versatile options from this file (use `None` or `""` for no file) which contains a single options dict, e.g. ``{"timeout": 0}`` to stop, string-values are evaluated, e.g. "np.inf" is valid', termination_callback='[] #v a function or list of functions returning True for termination, called in `stop` with `self` as argument, could be abused for side effects', timeout='inf #v stop if timeout seconds are exceeded, the string "2.5 * 60**2" evaluates to 2 hours and 30 minutes', tolconditioncov='1e14 #v stop if the condition of the covariance matrix is above `tolconditioncov`', tolfacupx='1e3 #v termination when step-size increases by tolfacupx (diverges). That is, the initial step-size was chosen far too small and better solutions were found far away from the initial solution x0', tolupsigma='1e20 #v sigma/sigma0 > tolupsigma * max(eivenvals(C)**0.5) indicates "creeping behavior" with usually minor improvements', tolflatfitness='1 #v iterations tolerated with flat fitness before termination', tolfun='1e-11 #v termination criterion: tolerance in function value, quite useful', tolfunhist='1e-12 #v termination criterion: tolerance in function value history', tolfunrel='0 #v termination criterion: relative tolerance in function value: Delta f current < tolfunrel * (median0 - median_min)', tolstagnation='int(100 + 100 * N**1.5 / popsize) #v termination if no improvement over tolstagnation iterations', tolxstagnation='[1e-9, 20, 0.1] #v termination thresholds for Delta of [mean, iterations, iterations fraction], the latter two are summed; trigger termination if Dmean stays below the threshold over Diter iterations, pass `False` or a negative value to turn off tolxstagnation', tolx='1e-11 #v termination criterion: tolerance in x-changes', transformation='None # deprecated, use a wrapper like those in cma.fitness_transformations instead.', typical_x='None # deprecated, use `cma.fitness_transformations.Shifted` instead', updatecovwait='None #v number of iterations without distribution update, name is subject to future changes', verbose='3 #v verbosity e.g. of initial/final message, -1 is very quiet, -9 maximally quiet, may not be fully implemented', verb_append='0 # initial evaluation counter, if append, do not overwrite output files', verb_disp='100 #v verbosity: display console output every verb_disp iteration', verb_disp_overwrite='inf #v start overwriting after given iteration', verb_filenameprefix=CMADataLogger.default_prefix+' # output path (folder) and filenames prefix', verb_log='1 #v verbosity: write data to files every verb_log iteration, writing can be time critical on fast to evaluate functions', verb_log_expensive='N * (N <= 50) # allow to execute eigendecomposition for logging every verb_log_expensive iteration, 0 or False for never', verb_plot='0 #v in fmin2(): plot() is called every verb_plot iteration', verb_time='True #v output timings on console', vv='{} #? versatile set or dictionary for hacking purposes, value found in self.opts["vv"]'):

use this function to get keyword completion for CMAOptions.

cma.CMAOptions('substr') provides even substring search.

returns default options as a dict (not a cma.CMAOptions dict).

def integer_lower_bound_target_probability(N, N_int):

target probability for an integer mutation assuming a centered mean

and no boundaries (two-tailed).

2 / (N + N_int) should keep at least 37% of the solutions unaffected.

Details: from ptarget we can compute sigma = 1 / PPF(ptarget/2) / 2 where PPF is the quantile function of the standard normal distribution and the first 2 accounts for two-sided sampling of the tails and the second 2 is needed because the distance to the value domain bound is 1/2.

def integer_std_lower_bound(N, mueff, N_int=None, binary=False):

can be reassigned/overwritten like a global "parameter setting"

This function returns the minimum of three bounds, an absolute bound (default 0.2), mueff / N, and a bound computed from the normal quantile (when the mean is assumed to be in the domain middle) which takes ptarget=integer_lower_bound_target_probability(N, N_int) (which should be roughly 1/N) as input. This bound becomes < 0.2 only when ptarget < 1/152 (==> < -2.5-sigma).

def is_feasible(x, f):

default to check feasibility of f-values.

Used for rejection sampling in method ask_and_eval.

See Also
CMAOptions, CMAOptions('feas').
def safe_str(s):

return a string safe to eval or raise an exception.

Selected words and chars are considered safe such that all default string-type option values from CMAOptions() pass. This function is implemented for convenience, to keep the default option format backwards compatible, and to be able to pass, for example, 3 * N. Function or class names other than those from the default values cannot be passed as strings (any more) but only as the function or class themselves.

cma_allowed_options_keys =

Undocumented

cma_default_options =

Undocumented

cma_versatile_options =

Undocumented

default_restart_number_if_not_zero: int =

Undocumented

integer_active_limit_recombination_weight_condition =

None or True or a function float->bool, None -> limit only negative updates

integer_std_lower_bound_factor1: int =

factor used in integer_std_lower_bound as multiplier to mueff/N

integer_std_lower_bound_factor2: int =

factor used in integer_std_lower_bound as multiplier to integer_std_lower_bound_limit_when_mu_is_large

integer_std_lower_bound_limit: float =

limit coordinate stds of solutions in C update, by default off, may go away

options_environment =

Undocumented