Examples
Load and plot previously generated data:
>>> import cma.purecma as pcma
>>> logger = pcma.CMAESDataLogger().load()
>>> logger.filename == "_CMAESDataLogger_datadict.py"
True
>> logger.plot()
The data may come from fmin or CMAES and the simulation may
still be running in a different Python shell.
Use the default logger from CMAES:
>>> import cma.purecma as pcma
>>> es = pcma.CMAES(3 * [0.1], 1)
>>> isinstance(es.logger, pcma.CMAESDataLogger) # type(es.logger)
True
>>> while not es.stop():
... X = es.ask()
... es.tell(X, [pcma.ff.elli(x) for x in X])
... es.logger.add(es) # doctest: +ELLIPSIS
<cma...
>> es.logger.plot()
TODO: the recorded data are kept in memory and keep growing, which
may well lead to performance issues for (very?) long runs. Ideally,
it should be possible to dump data to a file and clear the memory and
also to downsample data to prevent plotting of long runs to take
forever. "], 'key': " or "]}" is the place where to
prepend/append new data in the file.
|
__init__(self,
verb_modulo=1)
verb_modulo controls whether and when logging takes place
for each call to the method add |
source code
|
|
|
add(self,
es=None,
force=False,
more_data=None)
append some logging data from CMAES class instance es ,
if number_of_times_called modulo verb_modulo equals zero |
source code
|
|
|
plot(self,
fig_number=322)
plot the stored data in figure fig_number . |
source code
|
|
|
save(self,
name=None)
save data to file name or self.filename |
source code
|
|
|
load(self,
name=None)
load data from file name or self.filename |
source code
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|