module documentation

A collection of commands for using COCO from Jupyter or IPython.

The main data structures used in COCO are DataSet, which corresponds to data of one algorithm on one problem, and DataSetList, which is for collections of DataSet instances. Both classes are implemented in cocopp.pproc.

Examples:

  • Start by importing cocopp:

    >>> import cocopp
    >>> cocopp.genericsettings.verbose = False # ensure to make below doctests work
    >>> def print_(*args, **kwargs): pass
    >>> cocopp.archives.bbob._print = print_  # avoid download notification
    
  • Load a data set, assign to variable ds:

    >>> path = cocopp.archives.bbob.get(4)
    >>> print('ESC'); dsl = cocopp.load(path)  # a dataset list  # doctest:+ELLIPSIS
    ESC...
    >>> ds = dsl[0]
    
  • Get some information on a DataSetList instance:

    >>> print(dsl)  # doctest:+ELLIPSIS
    [DataSet(BIPOP-CMA-ES_hansen on f1 2-D), DataSet(BIPOP-CMA-ES...
    >>> dsl.info()
    144 data set(s)
    Algorithm(s): BIPOP-CMA-ES_hansen
    24 Functions with IDs 1-24
    Dimension(s): 2, 3, 5, 10, 20, 40
    Max evals: [1625595, 2349823, 3114271, 5884514, 12102699, 36849608]
    
  • Get some information on a DataSet instance:

    >>> print(ds)
    DataSet(BIPOP-CMA-ES_hansen on f1 2-D)
    >>> ds.info()
    Algorithm: BIPOP-CMA-ES_hansen
    Function ID: 1
    Dimension DIM = 2
    Number of trials: 15
    Final target Df: 1e-08
    min / max number of evals per trial: 224 / 333
       evals/DIM:  best     15%     50%     85%     max |  ERT/DIM  nsucc
      ---Df---|-----------------------------------------|----------------
      1.0e+03 |       0       0       0       0       0 |      0.5  15
      1.0e+01 |       0       0       2       8      10 |      2.9  15
      1.0e-01 |       8      13      22      38      52 |     24.2  15
      1.0e-03 |      34      48      56      74      77 |     58.2  15
      1.0e-05 |      64      70      89     100     102 |     86.1  15
      1.0e-08 |     112     116     128     150     166 |    130.9  15
    
Class DataWithFewSuccesses The all property is an OrderedDict with all (dimension, funcId)-
Function info Display more info on an instance of DatasetList.
Function load [currently broken when further used within cocopp, see load2] Create a DataSetList instance from a file or folder.
Function load2 [WIP] return a dict of dict of DataSetLists with dimension and pathname as keys.
Function systeminfo Display information on the system.
Function true_number_of_trials return number of actually conducted trials for DataSet ds
Function _pickle Pickle a DataSetList.
def info(dsList):

Display more info on an instance of DatasetList.

def load(filename):

[currently broken when further used within cocopp, see load2] Create a DataSetList instance from a file or folder.

Input argument filename can be a single :file:`info` file name, a single pickle filename or a folder name. In the latter case, the folder is browsed recursively for :file:`info` or :file:`pickle` files.

Details: due to newly implemented side effects when data are read in, the returned data set list may not work anymore when used with plotting functions of the cocopp module, see also load2.

def load2(args):

[WIP] return a dict of dict of DataSetLists with dimension and pathname as keys.

args is a string or a list of strings passed to cocopp.official_archives.all.get_extended to determine the desired data sets which can also come from a local folder or a zip-file.

Examples:

>>> import cocopp
>>> def load2(s):
...     print(s)  # predictable output
...     return cocopp.load2(s)
>>> def pprld(dsl):
...     print('_')  # predictable output
...     with cocopp.toolsdivers.InfolderGoneWithTheWind():
...         cocopp.compall.pprldmany.main(dsl)  # writes pprldmany_default.*
>>> ddsl = load2('bbob/2009/B*')  # doctest:+ELLIPSIS
bbob/200...
>>> assert sorted(ddsl) == [2, 3, 5, 10, 20, 40], ddsl
>>> assert all([len(ddsl[i]) == 3 for i in ddsl]), ddsl  # 3 algorithms
>>> pprld(ddsl[2])  # doctest:+ELLIPSIS
_...
>> ddsl31 = load('bbob/2009/*')  # 31 data sets, takes ~3 minutes at first ever loading
>> assert sorted(ddsl31) == [2, 3, 5, 10, 20, 40], ddsl
>> assert len(ddsl31[3]) == 31, ddsl
def systeminfo():

Display information on the system.

def true_number_of_trials(ds):

return number of actually conducted trials for DataSet ds

def _pickle(dsList):

Pickle a DataSetList.