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 Alsodisp (), plot ()
Method __init__ initialize logging of data from a CMAEvolutionStrategy instance, default modulo=1 means logging with each call
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.
Method initialize reset logger, overwrite original files, modulo: log only every modulo 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 load Undocumented
Method plot Undocumented
Method plot_front Undocumented
Method plot_ratios Undocumented
Method plot_divers Undocumented
Method plot_stds 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 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.
def initialize(self, modulo=None):
reset logger, overwrite original files, modulo: log only every modulo 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 load(self, filenames):
Undocumented
def plot(self, filename, x_iteration=0):
Undocumented
def plot_front(self, aspect=None):
Undocumented
def plot_ratios(self, iabscissa=1):
Undocumented
def plot_divers(self, iabscissa=1):
Undocumented
def plot_stds(self, iabscissa=1):
Undocumented
def _enter_plotting(self, fontsize=7):
assumes that a figure is open
def _finalize_plotting(self):
Undocumented
def _xlabel(self, iabscissa=1):
Undocumented
API Documentation for comocma, generated by pydoctor at 2020-04-18 16:47:06.