cocopp.bestalg
module documentationcocopp
Best algorithm dataset module This module implements :py:class:`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 :py:data:`bestAlgorithmEntries` variable. This variable needs to be initialized by executing functions :py:func:`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 | reset_reference_algorithm | Undocumented |
Function | load_reference_algorithm | Assigns :py:data:`bestAlgorithmEntries`. |
Function | usage | Undocumented |
Function | generate | Generates dictionary of best algorithm data set. |
Function | deprecated_customgenerate | Generates best algorithm data set. |
Function | custom_generate | Generates best algorithm data set from a given set of algorithms. |
Function | create_data_files | Undocumented |
Function | write_to_file | Undocumented |
Function | getAllContributingAlgorithmsToBest | No summary |
Function | extractBestAlgorithms | No summary |
Function | get_used_instance_list | Undocumented |
Assigns :py:data:`bestAlgorithmEntries`. This function is needed to set the global variable :py:data:`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. :py:data:`bestAlgorithmEntries` is a dictionary accessed by providing a tuple :py:data:`(dimension, function)`. This returns an instance of :py:class:`BestAlgSet`. The data is that of specific algorithms (depending on the Testbed used).
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.
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...
Computes first the artificial best algorithm from given algorithm list algnamelist, constructed by extracting for each target/function pair thalgorithm with best aRT 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...
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 aRT - its own aRT lies within a factor f_factor of the best aRT - there is no algorithm within a factor of f_factor of the best aRT and the current algorithm is the second best.