Module cma :: Class CMAOptions
[hide private]
[frames] | no frames]

Class CMAOptions

source code

object --+    
         |    
      dict --+
             |
            CMAOptions

CMAOptions() returns a dictionary with the available options and their default values for class CMAEvolutionStrategy.

CMAOptions('pop') returns a subset of recognized options that contain 'pop' 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 fmin 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 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

See Also: fmin`(), `CMAEvolutionStrategy, _CMAParameters

Instance Methods [hide private]
 
check(self, options=None)
check for ambiguous keys and move attributes into dict
source code
 
check_values(self, options=None) source code
 
check_attributes(self, opts=None)
check for attributes and moves them into the dictionary
source code
new empty dictionary

__init__(self, s=None, unchecked=False)
return an CMAOptions instance, either with the default options, if s is None, or with all options whose name or description contains s, if s is a string (case is disregarded), or with entries from dictionary s as options, not complemented with default options or settings
source code
 
init(self, dict_or_str, val=None, warn=True)
initialize one or several options.
source code
 
set(self, dic, val=None, force=False)
set can assign versatile options from CMAOptions.versatile_options() with a new value, use init() for the others.
source code
 
complement(self)
add all missing options with their default values
source code
 
settable(self)
return the subset of those options that are settable at any time.
source code
 
__call__(self, key, default=None, loc=None)
evaluate and return the value of option key on the fly, or returns those options whose name or description contains key, case disregarded.
source code
 
corrected_key(self, key)
return the matching valid key, if key.lower() is a unique starting sequence to identify the valid key, else None
source code
 
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.
source code
 
evalall(self, loc=None, defaults=None)
Evaluates all option values in environment loc.
source code
 
match(self, s=u'')
return all options that match, in the name or the description, with string s, case is disregarded.
source code
 
pp(self) source code
 
pprint(self, linebreak=80) source code
 
print_(self, linebreak=80) source code
 
printme(self, linebreak=80) source code

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __repr__, __setitem__, __sizeof__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values, viewitems, viewkeys, viewvalues

Inherited from object: __delattr__, __format__, __reduce__, __reduce_ex__, __setattr__, __str__, __subclasshook__

Static Methods [hide private]
 
defaults()
return a dictionary with default option values and description
source code
 
versatile_options()
return list of options that can be changed at any time (not only be initialized), however the list might not be entirely up to date.
source code
 
merge(self, dict_=None)
not is use so far, see check()
source code
Class Variables [hide private]

Inherited from dict: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

versatile_options()
Static Method

source code 

return list of options that can be changed at any time (not only be initialized), however the 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.

__init__(self, s=None, unchecked=False)
(Constructor)

source code 

return an CMAOptions instance, either with the default options, if s is None, or with all options whose name or description contains s, if s is a string (case is disregarded), or with entries from dictionary s as options, not complemented with default options or settings

Returns: see above.

Returns:
new empty dictionary

Overrides: object.__init__

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

source code 

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()

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

source code 

set can assign versatile options from CMAOptions.versatile_options() with a new value, use init() for 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.

settable(self)

source code 

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

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

__call__(self, key, default=None, loc=None)
(Call operator)

source code 

evaluate and return the value of option key on the fly, or returns 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()

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

source code 

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__

evalall(self, loc=None, defaults=None)

source code 
Evaluates all option values in environment loc.

See Also: eval()

match(self, s=u'')

source code 

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.