Passed
Push — master ( bac9d4...455948 )
by Simon
04:25
created

tests.test_optimizers.test_parameter.test_tpe_para_init   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A objective_function() 0 3 1
A test_hill_climbing_para() 0 3 1
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
import pytest
6
import numpy as np
7
8
from gradient_free_optimizers import TreeStructuredParzenEstimators
9
from ._base_para_test import _base_para_test_func
10
11
12
def objective_function(para):
13
    score = -para["x1"] * para["x1"]
14
    return score
15
16
17
search_space = {"x1": np.arange(-10, 11, 1)}
18
19
20
warm_start_smbo = (
21
    np.array([[-10, -10], [30, 30], [0, 0]]),
22
    np.array([-1, 0, 1]),
23
)
24
25
26
bayesian_optimizer_para = [
27
    ({"gamma_tpe": 0.001}),
28
    ({"gamma_tpe": 0.5}),
29
    ({"gamma_tpe": 0.9}),
30
    ({"warm_start_smbo": None}),
31
    ({"warm_start_smbo": warm_start_smbo}),
32
    ({"rand_rest_p": 0}),
33
    ({"rand_rest_p": 0.5}),
34
    ({"rand_rest_p": 1}),
35
    ({"rand_rest_p": 10}),
36
]
37
38
39
pytest_wrapper = ("opt_para", bayesian_optimizer_para)
40
41
42
@pytest.mark.parametrize(*pytest_wrapper)
43
def test_hill_climbing_para(opt_para):
44
    _base_para_test_func(opt_para, TreeStructuredParzenEstimators)
45