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

tests.test_optimizers.test_parameter.test_random_annealing_para_init   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A test_hill_climbing_para() 0 3 1
A objective_function() 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 RandomAnnealingOptimizer
9
from .test_hill_climbing_para_init import hill_climbing_para
10
from ._base_para_test import _base_para_test_func
11
12
13
def objective_function(para):
14
    score = -para["x1"] * para["x1"]
15
    return score
16
17
18
search_space = {"x1": np.arange(-100, 101, 1)}
19
20
21
random_annealing_para = hill_climbing_para + [
22
    ({"annealing_rate": 0.5}),
23
    ({"annealing_rate": 0.8}),
24
    ({"annealing_rate": 0.9}),
25
    ({"annealing_rate": 1}),
26
    ({"start_temp": 1}),
27
    ({"start_temp": 2}),
28
    ({"start_temp": 0.5}),
29
]
30
31
32
pytest_wrapper = ("opt_para", random_annealing_para)
33
34
35
@pytest.mark.parametrize(*pytest_wrapper)
36
def test_hill_climbing_para(opt_para):
37
    _base_para_test_func(opt_para, RandomAnnealingOptimizer)
38