module documentation

logger class mainly to be used with CMAEvolutionStrategy

Class CMADataLogger data logger for class CMAEvolutionStrategy.
Class Logger log an arbitrary number of data (a data row) per "timestep".
Class LoggerDummy use to fake a Logger in non-verbose setting
Function custom_default_matplotlib reduce wasted margin area from 19.0% to 4.0% and make both grids default and
Function disp displays selected data from (files written by) the class CMADataLogger.
Function plot plot data from files written by a CMADataLogger, the call cma.plot(name, **argsdict) is a shortcut for cma.CMADataLogger(name).plot(**argsdict)
Function plot_zip create tar file filename [+ ...] + '.tar.gz' of folder name.
Function smartlogygrid turn on grid and also minor grid depending on y-limits
Variable __author__ Undocumented
Variable last_figure_number Undocumented
Function _fix_lower_xlim_and_clipping minimize space wasted below x=0
Function _monotone_abscissa make x monotone if not iabscissa.
def custom_default_matplotlib():

reduce wasted margin area from 19.0% to 4.0% and make both grids default and

show legend when labels are available.

def disp(name=None, idx=None):

displays selected data from (files written by) the class CMADataLogger.

The call cma.disp(name, idx) is a shortcut for cma.CMADataLogger(name).disp(idx).

Arguments

name
name of the logger, filename prefix, None evaluates to the default 'outcma/cma'
idx
indices corresponding to rows in the data file; by default the first five, then every 100-th, and the last 10 rows. Too large index values are removed.

The best ever observed iteration is also printed by default.

Examples

import cma
from numpy import r_
# assume some data are available from previous runs
cma.disp(None, r_[0, -1])  # first and last
cma.disp(None, r_[0:int(1e9):100, -1]) # every 100-th and last
cma.disp(idx=r_[0, -10:0]) # first and ten last
cma.disp(idx=r_[0:int(1e9):1000, -10:0])
See Also
CMADataLogger.disp
def plot(name=None, fig=None, abscissa=0, iteridx=None, plot_mean=False, foffset=1e-19, x_opt=None, fontsize=7, downsample_to=3000.0, xsemilog=None, xnormalize=None, fshift=0, addcols=None, **kwargs):

plot data from files written by a CMADataLogger, the call cma.plot(name, **argsdict) is a shortcut for cma.CMADataLogger(name).plot(**argsdict)

Arguments

name
name of the logger, filename prefix, None evaluates to the default 'outcmaes/'
fig
filename or figure number, or both as a tuple (any order)
abscissa
0==plot versus iteration count, 1==plot versus function evaluation number
iteridx
iteration indices to plot
x_opt
If isscalar(x_opt) it is interpreted as iteration number and the difference of x to the respective iteration is plotted. If it is a negative scalar the respective index rather than the iteration is used. Namely in particular, x_opt=0 subtracts the initial solution X0 and x_opt=-1 subtracts the final solution of the data. If len(x_opt) == dimension, the difference to x_opt is plotted, otherwise the first row of x_opt are the indices of the variables to be plotted and the second row, if present, is used to take the difference.
xsemilog
customized semilog plot for x-values
fshift
is added to plotted and shown f-values

Return None

Examples

cma.plot()  # the optimization might be still
            # running in a different shell
cma.s.figsave('fig325.png')
cma.s.figclose()

cdl = cma.CMADataLogger().downsampling().plot()
# in case the file sizes are large

Details

Data from codes in other languages (C, Java, Matlab, Scilab) have the same format and can be plotted just the same.

See Also
CMADataLogger, CMADataLogger.plot
def plot_zip(name=None, filename=None, unique=True):

create tar file filename [+ ...] + '.tar.gz' of folder name.

The resulting tar file serves to recreate the current cma.plot elsewhere.

name defaults to the folder plotted with cma.plot by default. filename defaults to name while adding a unique time stamp if unique is true.

Return the path of the created file (may be absolute or relative).

Details

This is a convenience replacement for executing tar -czf filename.tar.gz name in a system shell where name defaults to the default plot data folder and filename is created to be unique.

This function calls CMADataLogger.zip to do the real work.

def smartlogygrid(**kwargs):

turn on grid and also minor grid depending on y-limits

__author__: str =

Undocumented

last_figure_number: int =

Undocumented

def _fix_lower_xlim_and_clipping():

minimize space wasted below x=0

def _monotone_abscissa(x, iabscissa=0):

make x monotone if not iabscissa.

Useful to plot restarted runs where the iteration is reset after each restart.

TODO: handle same iteration number better, but how? Currently we assume it was written "on purpose" twice.