Exemple #1
0
    def test_hartmann6(self):
        f = synthetic_functions.Hartmann6()

        for x in f.get_meta_information()["optima"]:
            np.testing.assert_approx_equal(f(x),
                                           f.get_meta_information()["f_opt"],
                                           significant=9)
 def __init__(self, path=None):
     super().__init__(synthetic_functions.Hartmann6(), path)
     self._x0 = np.array([
         0.1335990371483741, 0.2743781816448671, 0.2879962344461537,
         0.10242147970254536, 0.3959197145814795, 0.5982863622683936
     ])
     self._old_max_value = self._max_value
     self._max_value = 1.
class Hartmann6D(AbstractFunction):

    _hartmann = hpobench.Hartmann6()

    ORIGINAL_MAX_ARGUMENT = np.array([[1.] * 6])
    ORIGINAL_MAX = _hartmann.objective_function(
        ORIGINAL_MAX_ARGUMENT[0])["function_value"]
    ORIGINAL_MIN = _hartmann.get_meta_information()["f_opt"]
    ORIGINAL_MIN_ARGUMENT = np.array(
        _hartmann.get_meta_information()["optima"])
    ORIGINAL_UPPER_BOUNDS = np.array([1.] * 6)
    ORIGINAL_LOWER_BOUNDS = np.array([0.] * 6)

    INVERT = True

    @classmethod
    def base_function(cls, x):
        return cls._hartmann.objective_function(x)["function_value"]
Exemple #4
0
import numpy as np
import scipy.optimize as spopt

import hpolib.benchmarks.synthetic_functions as hpobench

# Run Scipy.minimize on artificial testfunctions

h3 = hpobench.Hartmann3()
h6 = hpobench.Hartmann6()
b = hpobench.Branin()

for f in [b, h3, h6]:
    info = f.get_meta_information()

    print("=" * 50)
    print(info['name'])

    bounds = np.array(info['bounds'])

    res = spopt.minimize(f, (bounds[:, 0] + bounds[:, 1]) / 2,
                         bounds=bounds,
                         method='SLSQP')

    assert (np.allclose(res.fun, info['f_opt']))

    for o in info['optima']:
        print("There is an optimum at \t "
              "x={} with f(x) = {}".format(o, info['f_opt']))

    print("scipy.optimize found \t x={} with f(x) = {}".format(res.x, res.fun))
sys.path.insert(0, path_join(dirname(__file__), "pysgmcmc_development"))
from collections import OrderedDict
from functools import partial
from itertools import product

from pysgmcmc_experiments.experiment_wrapper import to_experiment

import numpy as np
from robo.fmin import (bayesian_optimization, entropy_search, random_search,
                       bohamiann)
from robo.fmin.keras_bohamiann import bohamiann as keras_bohamiann
import hpolib.benchmarks.synthetic_functions as hpobench

BENCHMARKS = OrderedDict(
    (("branin", hpobench.Branin()), ("hartmann3", hpobench.Hartmann3()),
     ("hartmann6", hpobench.Hartmann6()), ("camelback", hpobench.Camelback()),
     ("goldstein_price", hpobench.GoldsteinPrice()), ("rosenbrock",
                                                      hpobench.Rosenbrock()),
     ("sin_one", hpobench.SinOne()), ("sin_two", hpobench.SinTwo()),
     ("bohachevsky", hpobench.Bohachevsky()), ("levy", hpobench.Levy())))

METHODS = OrderedDict((
    ("rf", partial(bayesian_optimization, model_type="rf")),
    ("gp", partial(bayesian_optimization, model_type="gp")),
    ("gp_mcmc", partial(bayesian_optimization, model_type="gp_mcmc")),
    ("entropy_search", entropy_search),
    ("random_search", random_search),
    ("bohamiann", bohamiann),
    ("keras_bohamiann", keras_bohamiann),
))
Exemple #6
0
 def make_hpo_fn(self):
     return synthetic_functions.Hartmann6()