コード例 #1
0
ファイル: test_domains.py プロジェクト: YutFut/TMO
def branin():
    """
    The Branin, or Branin-Hoo, function has three global minima,
    and is roughly an angular trough across a 2D input space.

        f(x, y) = a (y - b x ** 2 + c x - r ) ** 2 + s (1 - t) cos(x) + s

    The recommended values of a, b, c, r, s and t are:
        a = 1
        b = 5.1 / (4 pi ** 2)
        c = 5 / pi
        r = 6
        s = 10
        t = 1 / (8 * pi)

    Global Minima:
      [(-pi, 12.275),
       (pi, 2.275),
       (9.42478, 2.475)]

    Source: http://www.sfu.ca/~ssurjano/branin.html
    """
    x = hp.uniform("x", -5.0, 10.0)
    y = hp.uniform("y", 0.0, 15.0)
    pi = float(np.pi)
    loss = (
        (y - (old_div(5.1, (4 * pi ** 2))) * x ** 2 + 5 * x / pi - 6) ** 2
        + 10 * (1 - old_div(1, (8 * pi))) * scope.cos(x)
        + 10
    )
    return {"loss": loss, "loss_variance": 0, "status": base.STATUS_OK}
コード例 #2
0
ファイル: test_domains.py プロジェクト: abiteboul/hyperopt
def branin():
    """
    The Branin, or Branin-Hoo, function has three global minima,
    and is roughly an angular trough across a 2D input space.

        f(x, y) = a (y - b x ** 2 + c x - r ) ** 2 + s (1 - t) cos(x) + s

    The recommended values of a, b, c, r, s and t are:
        a = 1
        b = 5.1 / (4 pi ** 2)
        c = 5 / pi
        r = 6
        s = 10
        t = 1 / (8 * pi)

    Global Minima:
      [(-pi, 12.275),
       (pi, 2.275),
       (9.42478, 2.475)]

    Source: http://www.sfu.ca/~ssurjano/branin.html
    """
    x = hp.uniform('x', -5., 10.)
    y = hp.uniform('y', 0., 15.)
    pi = float(np.pi)
    loss = ((y - (old_div(5.1, (4 * pi ** 2))) * x ** 2 + 5 * x / pi - 6) ** 2 +
            10 * (1 - old_div(1, (8 * pi))) * scope.cos(x) + 10)
    return {'loss': loss,
            'loss_variance': 0,
            'status': base.STATUS_OK}