class Forrester(AbstractFunction):

    _forrester = hpobench.Forrester()

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

    INVERT = True

    @classmethod
    def base_function(cls, x):
        return cls._forrester.objective_function(x)["function_value"]
import numpy as np

import hpolib.benchmarks.synthetic_functions as hpobench

import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D

# Use the 1d Forrester function and add artifical noise depending
# on the 'dateset size'
f = hpobench.SyntheticNoiseAndCost(hpobench.Forrester(), 0, 2, 0.1, 1, 2, 2)

# grid for plotting
X = np.linspace(0, 1, 50)
d = np.linspace(0, 1, 50)
X, D = np.meshgrid(X, d)

# compute target values and costs
T = []
C = []

for x, d in zip(X.flatten(), D.flatten()):
    mew = f.objective_function([x], dataset_fraction=d)
    T.append(mew['function_value'])
    C.append(mew['cost'])
T = np.array(T).reshape(X.shape)
C = np.array(C).reshape(X.shape)

# make some decent looking plots
fig = plt.figure()
ax = fig.add_subplot(121, projection='3d')
Exemple #3
0
import numpy as np

import hpolib.benchmarks.synthetic_functions as hpobench

import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D

# Let's use the 1d Forrester function and add some artifical, dateset size dependend noise
f = hpobench.Forrester()

# grid for plotting
X = np.linspace(0, 1, 50)
fids = np.linspace(0, 1, 50)
X, F = np.meshgrid(X, fids)

# compute target values
T = []

for x, g in zip(X.flatten(), F.flatten()):
    mew = f.objective_function([x], fidelity=g)
    T.append(mew['function_value'])
T = np.array(T).reshape(X.shape)

# make some descent looking plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.set_title('The Forrester function with an artificial fidelity dimension')
ax.set_xlabel('x')
ax.set_ylabel('fidelity')
ax.set_zlabel('f(x,dataset_fraction')
 def __init__(self, path=None):
     super().__init__(synthetic_functions.Forrester(), path)