module documentation

Best algorithm dataset module

This module implements BestAlgSet class which is used as data structure for the data set of the virtual best algorithm. Therefore this module will be imported by other modules which need to access best algorithm data set.

The best algorithm data set can be accessed by the bestAlgorithmEntries variable. This variable needs to be initialized by executing functions load_reference_algorithm(...)

This module can also be used generate the best algorithm data set with its generate method.

Class BestAlgSet Unit element of best algorithm data set.
Function create_data_files Undocumented
Function custom_generate Generates best algorithm data set from a given set of algorithms.
Function deprecated_customgenerate Generates best algorithm data set.
Function extractBestAlgorithms Returns (and prints) per dimension a list of algorithms within algorithm list args that contains an algorithm if for any
Function generate Generates dictionary of best algorithm data set.
Function get_used_instance_list Undocumented
Function getAllContributingAlgorithmsToBest Computes first the artificial best algorithm from given algorithm list algnamelist, constructed by extracting for each target/function pair thalgorithm with best ERT among the given ones. Returns then the list of algorithms that are contributing to the definition of the best algorithm, separated by dimension, and sorted by importance (i...
Function load_reference_algorithm Assigns bestAlgorithmEntries.
Function reset_reference_algorithm Undocumented
Function usage Undocumented
Function write_to_file Undocumented
Variable algs2009 Undocumented
Variable algs2010 Undocumented
Variable algs2012 Undocumented
Variable bestAlgorithmEntries Undocumented
def create_data_files(output_dir, result, suite):

Undocumented

def custom_generate(args=algs2009, algId='bestCustomAlg', suite=None):

Generates best algorithm data set from a given set of algorithms.

It will create a folder named as algId in the current working directory corresponding to the bestalg dataSet of the algorithms listed in variable args. This folder is furthermore added to a .tar.gz file of the same name.

This method is called from the python command line from a directory containing all necessary data folders:

>>> import cocopp
>>> def print_(*args, **kwargs): pass
>>> cocopp.archives.bbob._print = print_  # prevent download message
>>> filename = cocopp.archives.bbob.get('2009/ALPS_hornby_noiseless')
>>> with cocopp.toolsdivers.InfolderGoneWithTheWind(cocopp.archives.bbob.local_data_path):

... print('ESC'); cocopp.bestalg.custom_generate((filename, ), ... '_doctest_refAlgFromALPS') # doctest: +ELLIPSIS ESC...

def deprecated_customgenerate(args=algs2009):

Generates best algorithm data set.

This functionality is deprecated because it writes unsupported pickle files.

It will create a folder bestAlg in the current working directory with a pickle file corresponding to the bestalg dataSet of the algorithms listed in variable args.

This method is called from the python command line from a directory containing all necessary data folders.

def extractBestAlgorithms(args=algs2009, f_factor=2, target_lb=1e-08, target_ub=1e+22):

Returns (and prints) per dimension a list of algorithms within algorithm list args that contains an algorithm if for any

dimension/target/function pair this algorithm: - is the best algorithm wrt ERT - its own ERT lies within a factor f_factor of the best ERT - there is no algorithm within a factor of f_factor of the best ERT

and the current algorithm is the second best.
def generate(dict_alg, algId):

Generates dictionary of best algorithm data set.

def get_used_instance_list(instance_number_list):

Undocumented

def getAllContributingAlgorithmsToBest(algnamelist, target_lb=1e-08, target_ub=100.0):

Computes first the artificial best algorithm from given algorithm list algnamelist, constructed by extracting for each target/function pair thalgorithm with best ERT among the given ones. Returns then the list of algorithms that are contributing to the definition of the best algorithm, separated by dimension, and sorted by importance (i.e. with respect to the number of target/function pairs where each algorithm is best). Only target/function pairs are taken into account where the target is in between target_lb and target_ub. This method should be called from the python command line from a directory containing all necessary data folders:

>>> import os, cocopp
>>> import cocopp.toolsdivers
>>> def print_(*args, **kwargs): pass
>>> cocopp.archives.bbob._print = print_  # prevent downloading... message
>>> filenames = (cocopp.archives.bbob.get('2009/BIPOP-CMA-ES'),  # first match will stay the same forever
...              cocopp.archives.bbob.get('2009/MCS_huyer_noiseless'))
>>> with cocopp.toolsdivers.InfolderGoneWithTheWind(cocopp.archives.bbob.local_data_path):
...     cocopp.bestalg.getAllContributingAlgorithmsToBest(filenames)
...     assert os.path.exists('bestCustomAlg.tar.gz')  # doctest:+ELLIPSIS
Generating best algorithm data...
def load_reference_algorithm(best_algo_filename, force=False, relative_load=True):

Assigns bestAlgorithmEntries.

This function is needed to set the global variable bestAlgorithmEntries. It reads in the data, specified by the string best_algo_filename which can either be a pickled file (deprecated), generated by deprecated_customgenerate or any standard data set (i.e. a zipped or unzipped folder with .info, .dat, and .tdat files such as the ones generated by custom_generate). This function will also set the testbedsettings.current_testbed.reference_algorithm_displayname according to the read data if not already present.

bestAlgorithmEntries is a dictionary accessed by providing a tuple (dimension, function). This returns an instance of BestAlgSet. The data is that of specific algorithms (depending on the Testbed used).

def reset_reference_algorithm():

Undocumented

def usage():

Undocumented

def write_to_file(filename, lines):

Undocumented

algs2009: tuple[str, ...] =

Undocumented

algs2010: tuple[str, ...] =

Undocumented

algs2012: tuple[str, ...] =

Undocumented

bestAlgorithmEntries: dict =

Undocumented