class documentation

class CMAOptions(dict):

Constructor: CMAOptions(s, **kwargs)

View In Hierarchy

a dictionary with the available options and their default values for class CMAEvolutionStrategy.

CMAOptions() returns a dict with all available options and their default values with a comment string.

CMAOptions('verb') returns a subset of recognized options that contain 'verb' in there keyword name or (default) value or description.

CMAOptions(opts) returns the subset of recognized options in dict(opts).

Option values can be "written" in a string and, when passed to fmin2 or CMAEvolutionStrategy, are evaluated using "N" and "popsize" as known values for dimension and population size (sample size, number of new solutions per iteration). All default option values are given as such a string.

Details

CMAOptions entries starting with tol are termination "tolerances".

For tolstagnation, the median over the first and the second half of at least tolstagnation iterations are compared for both, the per-iteration best and per-iteration median function value.

Example

import cma
cma.CMAOptions('tol')

is a shortcut for cma.CMAOptions().match('tol') that returns all options that contain 'tol' in their name or description.

To set an option:

import cma
opts = cma.CMAOptions()
opts.set('tolfun', 1e-12)
opts['tolx'] = 1e-11

todo: this class is overly complex and should be re-written, possibly with reduced functionality.

See Also
fmin2 (), CMAEvolutionStrategy, CMAParameters
Static Method defaults return a dictionary with default option values and description
Static Method versatile_options return list of options that can be changed at any time (not only be initialized).
Method __call__ evaluate and return the value of option key on the fly, or return those options whose name or description contains key, case disregarded.
Method __init__ return an CMAOptions instance.
Method amend_integer_options amend options when integer variables are indicated
Method amend_integer_variables removed fixed variables from the integer variable index values
Method check check for ambiguous keys and move attributes into dict
Method check_attributes check for attributes and moves them into the dictionary
Method check_values Undocumented
Method complement add all missing options with their default values
Method corrected_key return the matching valid key, if key.lower() is a unique starting sequence to identify the valid key, else None
Method eval Evaluates and sets the specified option value in environment loc. Many options need N to be defined in loc, some need popsize.
Method evalall Evaluates all option values in environment loc.
Method from_namedtuple update options from a collections.namedtuple. :See also: to_namedtuple
Method init initialize one or several options.
Method match return all options that match, in the name or the description, with string s, case is disregarded.
Method pprint Undocumented
Method set assign versatile options.
Method set_integer_min_std set lower std bounds for integer variables.
Property settable return the subset of those options that are settable at any time.
Property to_namedtuple return options as const attributes of the returned object, only useful for inspection.
Class Variable _hsig Undocumented
Class Variable _ps_for_pc Undocumented
Class Variable _stationary_sphere Undocumented
Instance Variable _attributes Undocumented
Instance Variable _lock_setting Undocumented
@staticmethod
def defaults():

return a dictionary with default option values and description

@staticmethod
def versatile_options():

return list of options that can be changed at any time (not only be initialized).

Consider that this list might not be entirely up to date.

The string ' #v ' in the default value indicates a versatile option that can be changed any time, however a string will not necessarily be evaluated again.

def __call__(self, key, default=None, loc=None):

evaluate and return the value of option key on the fly, or return those options whose name or description contains key, case disregarded.

Details

Keys that contain filename are not evaluated. For loc==None, self is used as environment but this does not define N.

See Also
eval(), evalall()
def __init__(self, s=None, **kwargs):

return an CMAOptions instance.

Return default options if s is None and not kwargs, or all options whose name or description contains s, if s is a (search) string (case is disregarded in the match), or with entries from dictionary s as options, or with kwargs as options if s is None, in any of the latter cases not complemented with default options or settings.

Returns: see above.

Details: as several options start with 's', s=value is not valid as an option setting.

def amend_integer_options(self, dimension, inopts):

amend options when integer variables are indicated

def amend_integer_variables(self, dimension):

removed fixed variables from the integer variable index values

def check(self, options=None):

check for ambiguous keys and move attributes into dict

def check_attributes(self, opts=None):

check for attributes and moves them into the dictionary

def check_values(self, options=None):

Undocumented

def complement(self):

add all missing options with their default values

def corrected_key(self, key):

return the matching valid key, if key.lower() is a unique starting sequence to identify the valid key, else None

def eval(self, key, default=None, loc=None, correct_key=True):

Evaluates and sets the specified option value in environment loc. Many options need N to be defined in loc, some need popsize.

Details

Keys that contain 'filename' are not evaluated. For loc is None, the self-dict is used as environment

See Also
evalall(), __call__
def evalall(self, loc=None, defaults=None):

Evaluates all option values in environment loc.

See Also
eval()
def from_namedtuple(self, t):

update options from a collections.namedtuple. :See also: to_namedtuple

def init(self, dict_or_str, val=None, warn=True):

initialize one or several options.

Arguments

dict_or_str
a dictionary if val is None, otherwise a key. If val is provided dict_or_str must be a valid key.
val
value for key

Details

Only known keys are accepted. Known keys are in CMAOptions.defaults()

def match(self, s=''):

return all options that match, in the name or the description, with string s, case is disregarded.

Example: cma.CMAOptions().match('verb') returns the verbosity options.

def pprint(self, linebreak=80):

Undocumented

def set(self, dic, val=None, force=False):

assign versatile options.

Method CMAOptions.versatile_options () gives the versatile options, use init() to set the others.

Arguments

dic
either a dictionary or a key. In the latter case, val must be provided
val
value for key, approximate match is sufficient
force
force setting of non-versatile options, use with caution

This method will be most probably used with the opts attribute of a CMAEvolutionStrategy instance.

def set_integer_min_std(self, N, mueff):

set lower std bounds for integer variables.

Uses the above defined integer_std_lower_bound function which can be reassigned.

@property
settable =

return the subset of those options that are settable at any time.

Settable options are in versatile_options (), but the list might be incomplete.

@property
to_namedtuple =

return options as const attributes of the returned object, only useful for inspection.

_hsig: bool =

Undocumented

_ps_for_pc: bool =

Undocumented

_stationary_sphere: bool =

Undocumented

_attributes =

Undocumented

_lock_setting: bool =

Undocumented