class documentation

class CMAESDataLogger(_BaseDataLogger):

Constructor: CMAESDataLogger(verb_modulo)

View In Hierarchy

data logger for class CMAES, that can record and plot data.

Examples

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:

>>> try: import cma.purecma as pcma
... except ImportError: import 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: +SKIP
>>> es.logger.save()
>>> # es.logger.plot()  #

Load and plot previously generated data:

>>> logger = pcma.CMAESDataLogger().load()
>>> logger.filename == "_CMAESDataLogger_datadict.py"
True
>>> # 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.

Method __init__ verb_modulo controls whether and when logging takes place for each call to the method add
Method add append some logging data from CMAES class instance es, if number_of_times_called modulo verb_modulo equals zero
Method load load data from file name or self.filename
Method plot plot the stored data in figure fig_number.
Method save save data to file name or self.filename
Class Variable plotted plot count for all instances
Instance Variable counter Undocumented
Instance Variable filename file to save to or load from unless specified otherwise
Instance Variable modulo Undocumented
Instance Variable optim object instance to be logging data from
Instance Variable _data dict of logged data

Inherited from BaseDataLogger:

Method disp abstract method, display some data trace
Method register register an optimizer optim, only needed if method add is called without passing the optim argument
Property data logged data in a dictionary
def __init__(self, verb_modulo=1):

verb_modulo controls whether and when logging takes place for each call to the method add

def 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

def load(self, name=None):

load data from file name or self.filename

def plot(self, fig_number=322):

plot the stored data in figure fig_number.

Dependencies: matlabplotlib.pylab

def save(self, name=None):

save data to file name or self.filename

plotted: int =

plot count for all instances

counter: int =

Undocumented

filename: str =

file to save to or load from unless specified otherwise

modulo =

Undocumented

optim =

object instance to be logging data from

_data =

dict of logged data