示例#1
0
    def test_sin_one(self):
        f = synthetic_functions.SinOne()

        for x in f.get_meta_information()["optima"]:
            np.testing.assert_approx_equal(f(x),
                                           f.get_meta_information()["f_opt"],
                                           significant=9)
示例#2
0
class SinOne(AbstractFunction):

    _sin_one = hpobench.SinOne()

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

    INVERT = True

    @classmethod
    def base_function(cls, x):
        return cls._sin_one.objective_function(x)["function_value"]
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),
))

CONFIGURATIONS = tuple(({
    "benchmark": benchmark,
    "method": method
output_path = "./experiments/RoBO/synthetic_funcs/"

if benchmark == "branin":
    b = hpobench.Branin()
elif benchmark == "hartmann3":
    b = hpobench.Hartmann3()
elif benchmark == "hartmann6":
    b = hpobench.Hartmann6()
elif benchmark == "camelback":
    b = hpobench.Camelback()
elif benchmark == "goldstein_price":
    b = hpobench.GoldsteinPrice()
elif benchmark == "rosenbrock":
    b = hpobench.Rosenbrock()
elif benchmark == "sin_one":
    b = hpobench.SinOne()
elif benchmark == "sin_two":
    b = hpobench.SinTwo()
elif benchmark == "bohachevsky":
    b = hpobench.Bohachevsky()
elif benchmark == "levy":
    b = hpobench.Levy()

info = b.get_meta_information()

scenario = Scenario({
    "run_obj": "quality",
    "runcount-limit": n_iters,
    "cs": b.get_configuration_space(),
    "deterministic": "true",
    "initial_incumbent": "RANDOM",
 def __init__(self, path=None):
     super().__init__(synthetic_functions.SinOne(), path)