Exemplo n.º 1
0
def test_optimum_on_bounds(function, initial_point, bounds, actual, seed):
    random.seed(seed)
    np.random.seed(seed)

    solver = RvfSolver(function, initial_point, bounds)
    point, value = solver.anneal(max_steps=4000)

    # tolerances
    tol_point = 0.1
    tol_value = 0.1

    actual = np.array(actual)

    assert abs(value - function(*actual)) < tol_value
    assert helpers.distance(actual, point) < tol_point
Exemplo n.º 2
0
def test_initialized_with_initial_point_out_of_bounds(function, point, bounds):
    with pytest.raises(ValueError):
        RvfSolver(function, point, bounds)
Exemplo n.º 3
0
def test_initialized_with_wrong_shapes(function, point, bounds):
    with pytest.raises(ValueError):
        RvfSolver(function, point, bounds)
Exemplo n.º 4
0
def test_initialized_with_bad_objective():
    with pytest.raises(ValueError):
        solver = RvfSolver(rvf_1_basic, [1], [[-1, 1]], objective="blah")
Exemplo n.º 5
0
def test_initialized_with_bad_function(bad_value):
    with pytest.raises(TypeError):
        solver = RvfSolver(bad_value, [0, 0], [[-1, 1], [-1, 1]])
Exemplo n.º 6
0
def test_initialized_with_bad_bounds(bad_value):
    with pytest.raises(ValueError):
        RvfSolver(rvf_1_basic, [1], bad_value)