Skip to content

Commit

Permalink
Merge pull request #1017 from numbbo/development
Browse files Browse the repository at this point in the history
merge of development branch into master before release
  • Loading branch information
brockho committed May 11, 2016
2 parents fa9e611 + 8069e42 commit fab1bec
Show file tree
Hide file tree
Showing 26 changed files with 1,316 additions and 652 deletions.
162 changes: 4 additions & 158 deletions code-postprocessing/bbob_pproc/bestalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
to access best algorithm data set.
The best algorithm data set can be accessed by the
:py:data:`bestalgentries2009` variable. This variable needs to be
initialized by executing functions :py:func:`loadBBOB2009()`
:py:data:`bestAlgorithmEntries` variable. This variable needs to be
initialized by executing functions :py:func:`load_best_algorithm()`
This module can also be used generate the best algorithm data set
with its generate method.
Expand All @@ -29,14 +29,9 @@
from . import readalign, pproc
from .toolsdivers import print_done
from .ppfig import Usage
from . import toolsstats, genericsettings
from . import toolsstats, testbedsettings

bestAlgorithmEntries = {}
bestalgentries2009 = {}
bestalgentries2010 = {}
bestalgentries2012 = {}
bestalgentriesever = {}
bestbiobjalgentries2016 = {}

algs2009 = ("ALPS", "AMALGAM", "BAYEDA", "BFGS", "Cauchy-EDA",
"BIPOP-CMA-ES", "CMA-ESPLUSSEL", "DASA", "DE-PSO", "DIRECT", "EDA-PSO",
Expand Down Expand Up @@ -343,7 +338,7 @@ def load_best_algorithm(force=False):
if not force and bestAlgorithmEntries:
return bestAlgorithmEntries

bestAlgorithmFilename = genericsettings.current_testbed.best_algorithm_filename
bestAlgorithmFilename = testbedsettings.current_testbed.best_algorithm_filename

# If the file name is not specified then we skip the load.
if not bestAlgorithmFilename:
Expand Down Expand Up @@ -372,155 +367,6 @@ def load_best_algorithm(force=False):
return bestAlgorithmEntries


def loadBBOB2009(force=False):
"""Assigns :py:data:`bestalgentries2009`.
This function is needed to set the global variable
:py:data:`bestalgentries2009`. It unpickles file
:file:`bestalgentries2009.pickle.gz`
:py:data:`bestalgentries2009` 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 algorithms submitted to BBOB 2009, the list of
which can be found in variable :py:data:`algs2009`.
"""
global bestalgentries2009
# global statement necessary to change the variable bestalg.bestalgentries2009

if not force and bestalgentries2009:
return

print "Loading best algorithm data from BBOB-2009...",
sys.stdout.flush()

bestalgfilepath = os.path.split(__file__)[0]
# picklefilename = os.path.join(bestalgfilepath, 'bestalgentries2009.pickle')
# cocofy(picklefilename)
# fid = open(picklefilename, 'r')

picklefilename = os.path.join(bestalgfilepath, 'bestalgentries2009.pickle.gz')
fid = gzip.open(picklefilename, 'r')
try:
bestalgentries2009 = pickle.load(fid)
except:
warnings.warn("no best algorithm loaded")
# raise # outcomment to diagnose
bestalgentries2009 = None
fid.close()
print_done()

def loadBBOB2010():
"""Assigns :py:data:`bestalgentries2010`.
This function is needed to set the global variable
:py:data:`bestalgentries2010`. It unpickles file
:file:`bestalgentries2010.pickle.gz`
:py:data:`bestalgentries2010` 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 algorithms submitted to BBOB 20&0, the list of
which can be found in variable :py:data:`algs2010`.
"""
global bestalgentries2010
# global statement necessary to change the variable bestalg.bestalgentries2010

print "Loading best algorithm data from BBOB-2010...",
bestalgfilepath = os.path.split(__file__)[0]
picklefilename = os.path.join(bestalgfilepath, 'bestalgentries2010.pickle.gz')
# cocofy(picklefilename)
fid = gzip.open(picklefilename, 'r')
bestalgentries2010 = pickle.load(fid)
fid.close()
print " done."

def loadBBOB2012():
"""Assigns :py:data:`bestalgentries2012`.
This function is needed to set the global variable
:py:data:`bestalgentries2012`. It unpickles file
:file:`bestalgentries2012.pickle.gz`
:py:data:`bestalgentries2012` 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 algorithms submitted to BBOB 20&0, the list of
which can be found in variable :py:data:`algs2012`.
"""
global bestalgentries2012
# global statement necessary to change the variable bestalg.bestalgentries2012

print "Loading best algorithm data from BBOB-2012...",
bestalgfilepath = os.path.split(__file__)[0]
picklefilename = os.path.join(bestalgfilepath, 'bestalgentries2012.pickle.gz')
# cocofy(picklefilename)
fid = gzip.open(picklefilename, 'r')
bestalgentries2012 = pickle.load(fid)
fid.close()
print " done."

def loadBBOBever():
"""Assigns :py:data:`bestalgentriesever`.
This function is needed to set the global variable
:py:data:`bestalgentriesever`. It unpickles file
:file:`bestalgentriesever.pickle.gz`
:py:data:`bestalgentriesever` 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 algorithms submitted to BBOB 2009 and 2010, the
list of which is the union in variables :py:data:`algs2009`
and :py:data:`algs2010`.
"""
global bestalgentriesever
# global statement necessary to change the variable bestalg.bestalgentriesever

print "Loading best algorithm data from BBOB...",
bestalgfilepath = os.path.split(__file__)[0]
picklefilename = os.path.join(bestalgfilepath, 'bestalgentriesever.pickle.gz')
# cocofy(picklefilename)
fid = gzip.open(picklefilename, 'r')
bestalgentriesever = pickle.load(fid)
fid.close()
print " done."

def loadBestBiobj2016():
"""Assigns :py:data:`bestbiobjalgentries2016`.
This function is needed to set the global variable
:py:data:`bestbiobjalgentries2016`. It unpickles file
:file:`bestbiobjalgentries2016.pickle.gz`
:py:data:`bestbiobjalgentries2016` is a dictionary accessed by providing
a tuple :py:data:`(dimension, function)`. This returns an instance
of :py:class:`BestAlgSet`.
"""
global bestbiobjalgentries2016
# global statement necessary to change the variable bestalg.bestbiobjalgentries2016

if bestbiobjalgentries2016:
return

print "Loading best bi-objective algorithm data from BBOB-2016...",
sys.stdout.flush()

bestalgfilepath = os.path.split(__file__)[0]
#picklefilename = os.path.join(bestalgfilepath, 'bestbiobjalgentries2016.pickle.gz')
picklefilename = os.path.join(bestalgfilepath, 'bestbiobjalgentries2016.pickle')
#fid = gzip.open(picklefilename, 'r')
fid = open(picklefilename, 'r')
bestbiobjalgentries2016 = pickle.load(fid)
fid.close()
print_done()


def usage():
print __doc__ # same as: sys.modules[__name__].__doc__, was: main.__doc__

Expand Down
4 changes: 2 additions & 2 deletions code-postprocessing/bbob_pproc/comp2/ppfig2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import numpy as np

from .. import toolsstats, readalign, ppfigparam, genericsettings, toolsdivers
from .. import toolsstats, readalign, ppfigparam, testbedsettings, toolsdivers
from ..toolsstats import ranksumtest
from ..ppfig import saveFigure, plotUnifLogXMarkers
#try:
Expand Down Expand Up @@ -421,7 +421,7 @@ def main(dsList0, dsList1, minfvalue=1e-8, outputdir='', verbose=True):
if func in funInfos.keys():
plt.title(funInfos[func])

if func in genericsettings.current_testbed.functions_with_legend:
if func in testbedsettings.current_testbed.functions_with_legend:
toolsdivers.legend(loc='best')

# save
Expand Down
12 changes: 6 additions & 6 deletions code-postprocessing/bbob_pproc/comp2/ppscatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
except ImportError:
# compatibility matplotlib 0.8
from matplotlib.transforms import blend_xy_sep_transform as blend
from .. import genericsettings, htmldesc, ppfigparam
from .. import genericsettings, htmldesc, ppfigparam, testbedsettings
from ..ppfig import saveFigure
from .. import toolsdivers
from .. import pproc
Expand Down Expand Up @@ -79,10 +79,10 @@ def prepare_figure_caption():
40:{\color{magenta}$\Diamond$}. """


if genericsettings.current_testbed.name == genericsettings.testbed_name_bi:
if testbedsettings.current_testbed.name == testbedsettings.testbed_name_bi:
# NOTE: no runlength-based targets supported yet
caption = caption_start_fixed + caption_finish
elif genericsettings.current_testbed.name == genericsettings.testbed_name_single:
elif testbedsettings.current_testbed.name == testbedsettings.testbed_name_single:
if genericsettings.runlength_based_targets:
caption = caption_start_rlbased + caption_finish
else:
Expand All @@ -95,10 +95,10 @@ def prepare_figure_caption():

def figure_caption(for_html = False):

targets = genericsettings.current_testbed.ppscatter_target_values
targets = testbedsettings.current_testbed.ppscatter_target_values
if for_html:
caption = htmldesc.getValue('##bbobppscatterlegend' +
genericsettings.current_testbed.scenario + '##')
testbedsettings.current_testbed.scenario + '##')
else:
caption = prepare_figure_caption()

Expand Down Expand Up @@ -167,7 +167,7 @@ def main(dsList0, dsList1, outputdir, verbose=True):
dictFunc1 = dsList1.dictByFunc()
funcs = set(dictFunc0.keys()) & set(dictFunc1.keys())

targets = genericsettings.current_testbed.ppscatter_target_values
targets = testbedsettings.current_testbed.ppscatter_target_values
if isinstance(targets, pproc.RunlengthBasedTargetValues):
linewidth = linewidth_rld_based
else:
Expand Down
16 changes: 8 additions & 8 deletions code-postprocessing/bbob_pproc/comp2/pptable2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os, warnings
import numpy
import matplotlib.pyplot as plt
from .. import genericsettings, bestalg, toolsstats, pproc
from .. import genericsettings, testbedsettings, bestalg, toolsstats, pproc
from ..pptex import tableLaTeX, tableLaTeXStar, writeFEvals2, writeFEvalsMaxPrec, writeLabels
from ..toolsstats import significancetest

Expand All @@ -25,7 +25,7 @@
samplesize = genericsettings.simulated_runlength_bootstrap_sample_size

def get_table_caption():
""" Sets table caption, based on the genericsettings.current_testbed
""" Sets table caption, based on the testbedsettings.current_testbed
and genericsettings.runlength_based_targets.
"""

Expand All @@ -40,7 +40,7 @@ def get_table_caption():
target, the corresponding best \aRT\
in the first row. The different target \Df-values are shown in the top row.
\#succ is the number of trials that reached the (final) target
$\fopt + """ + genericsettings.current_testbed.hardesttargetlatex + r"""$.
$\fopt + """ + testbedsettings.current_testbed.hardesttargetlatex + r"""$.
"""
table_caption_two2 = r"""%
run-length based target, the corresponding best \aRT\
Expand All @@ -55,7 +55,7 @@ def get_table_caption():
90\%-tile of (bootstrapped) runtimes is shown for the different
target \Df-values as shown in the top row.
\#succ is the number of trials that reached the last target
$\hvref + """ + genericsettings.current_testbed.hardesttargetlatex + r"""$.
$\hvref + """ + testbedsettings.current_testbed.hardesttargetlatex + r"""$.
"""
table_caption_rest = (r"""%
The median number of conducted function evaluations is additionally given in
Expand All @@ -66,14 +66,14 @@ def get_table_caption():
following the $\star$ symbol, with Bonferroni correction of #1.""" +
(r"""A $\downarrow$ indicates the same tested against the best
algorithm of BBOB-2009."""
if not (genericsettings.current_testbed.name == genericsettings.testbed_name_bi)
if not (testbedsettings.current_testbed.name == testbedsettings.testbed_name_bi)
else "")
)

if genericsettings.current_testbed.name == genericsettings.testbed_name_bi:
if testbedsettings.current_testbed.name == testbedsettings.testbed_name_bi:
# NOTE: no runlength-based targets supported yet
table_caption = table_caption_bi + table_caption_rest
elif genericsettings.current_testbed.name == genericsettings.testbed_name_single:
elif testbedsettings.current_testbed.name == testbedsettings.testbed_name_single:
if genericsettings.runlength_based_targets:
table_caption = table_caption_one + table_caption_two2 + table_caption_rest
else:
Expand All @@ -89,7 +89,7 @@ def main(dsList0, dsList1, dimsOfInterest, outputdir, info='', verbose=True):

#TODO: method is long, split if possible

testbed = genericsettings.current_testbed
testbed = testbedsettings.current_testbed
targetsOfInterest = testbed.pptable2_targetsOfInterest


Expand Down
Loading

0 comments on commit fab1bec

Please sign in to comment.