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 |
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 |
amend options when integer variables are indicated |
Method | amend |
removed fixed variables from the integer variable index values |
Method | check |
check for ambiguous keys and move attributes into dict |
Method | check |
check for attributes and moves them into the dictionary |
Method | check |
Undocumented |
Method | complement |
add all missing options with their default values |
Method | corrected |
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 |
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 |
set lower std bounds for integer variables. |
Property | settable |
return the subset of those options that are settable at any time. |
Property | to |
return options as const attributes of the returned object, only useful for inspection. |
Class Variable | _hsig |
Undocumented |
Class Variable | _ps |
Undocumented |
Class Variable | _stationary |
Undocumented |
Instance Variable | _attributes |
Undocumented |
Instance Variable | _lock |
Undocumented |
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.
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.
return the matching valid key, if key.lower() is a unique starting sequence to identify the valid key, else None
initialize one or several options.
Arguments
dict_or_str
- a dictionary if val is None, otherwise a key. If
val
is provideddict_or_str
must be a valid key.val
- value for key
Details
Only known keys are accepted. Known keys are in CMAOptions.defaults()
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.
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 providedval
- value for
key
, approximate match is sufficientforce
- force setting of non-versatile options, use with caution
This method will be most probably used with the opts attribute of
a CMAEvolutionStrategy
instance.
set lower std bounds for integer variables.
Uses the above defined integer_std_lower_bound
function which can
be reassigned.
return the subset of those options that are settable at any time.
Settable options are in versatile_options
(), but the
list might be incomplete.