class documentation

class SofomoreDataLogger(interfaces.BaseDataLogger):

Constructor: SofomoreDataLogger(name_prefix, modulo, append)

View In Hierarchy

data logger for class CMAEvolutionStrategy.

The logger is identified by its name prefix and (over-)writes or reads according data files. Therefore, the logger must be considered as global variable with unpredictable side effects, if two loggers with the same name and on the same working folder are used at the same time.

Examples

import cma
es = cma.CMAEvolutionStrategy(...)
logger = cma.CMADataLogger().register(es)
while not es.stop():
    ...
    logger.add()  # add can also take an argument

logger.plot() # or a short cut can be used:
cma.plot()  # plot data from logger with default name

logger2 = cma.CMADataLogger('just_another_filename_prefix').load()
logger2.plot()
logger2.disp()

import cma
from matplotlib.pylab import *
res = cma.fmin(cma.ff.sphere, rand(10), 1e-0)
logger = res[-1]  # the CMADataLogger
logger.load()  # by "default" data are on disk
semilogy(logger.f[:,0], logger.f[:,5])  # plot f versus iteration, see file header
cma.s.figshow()

Details

After loading data, the logger has the attributes xmean, xrecent, std, f, D and corrspec corresponding to xmean, xrecentbest, stddev, fit, axlen and axlencorr filename trails.

See Also
disp (), plot ()
Method __init__ initialize logging of data from a CMAEvolutionStrategy instance, default modulo=1 means logging with each call
Method add append some logging data from Sofomore class instance es, if number_of_times_called % modulo equals to zero, never if modulo==0.
Method initialize reset logger, overwrite original files, modulo: log only every modulo call
Method load No summary
Method plot load filename if given and plot the result.
Method plot_divers No summary
Method plot_front No summary
Method plot_ratios No summary
Method plot_stds No summary
Method register register a Sofomore instance for logging, append=True appends to previous data logged under the same name, by default previous data are overwritten.
Class Variable default_prefix Undocumented
Instance Variable append append to previous data
Instance Variable counter number of calls to add
Instance Variable es Undocumented
Instance Variable file_names Undocumented
Instance Variable last_iteration Undocumented
Instance Variable modulo how often to record data, allows calling add without args
Instance Variable name_prefix Undocumented
Instance Variable original_fontsize Undocumented
Instance Variable persistent_communication_dict Undocumented
Instance Variable registered Undocumented
Method _enter_plotting assumes that a figure is open
Method _finalize_plotting Undocumented
Method _xlabel Undocumented
def __init__(self, name_prefix=default_prefix, modulo=1, append=False):

initialize logging of data from a CMAEvolutionStrategy instance, default modulo=1 means logging with each call

def add(self, es=None, more_data=(), modulo=None):

append some logging data from Sofomore class instance es, if number_of_times_called % modulo equals to zero, never if modulo==0.

more_data is a list of additional data to be recorded where each data entry must have the same length.

When used for a different optimizer class, this function can be (easily?) adapted by changing the assignments under INTERFACE in the implemention.

def initialize(self, modulo=None):

reset logger, overwrite original files, modulo: log only every modulo call

def load(self, filenames):
def plot(self, filename=None, x_iteration=False):

load filename if given and plot the result.

Otherwise, plot all.

def plot_divers(self, iabscissa=1):
def plot_front(self, aspect=None):
def plot_ratios(self, iabscissa=1):
def plot_stds(self, iabscissa=1):
def register(self, es, append=None, modulo=None):

register a Sofomore instance for logging, append=True appends to previous data logged under the same name, by default previous data are overwritten.

default_prefix =

Undocumented

append =

append to previous data

counter: int =

number of calls to add

es =

Undocumented

file_names: tuple[str, ...] =

Undocumented

last_iteration =

Undocumented

modulo =

how often to record data, allows calling add without args

name_prefix =

Undocumented

original_fontsize =

Undocumented

persistent_communication_dict =

Undocumented

registered: bool =

Undocumented

def _enter_plotting(self, fontsize=7):

assumes that a figure is open

def _finalize_plotting(self):

Undocumented

def _xlabel(self, iabscissa=1):

Undocumented