tests.test_optimizers.test_parameter.test_simulated_annealing_para_init   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 41
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 SimulatedAnnealingOptimizer
9
from .test_stochastic_hill_climbing_para_init import (
10
    stochastic_hill_climbing_para,
11
)
12
from ._base_para_test import _base_para_test_func
13
14
15
def objective_function(para):
16
    score = -para["x1"] * para["x1"]
17
    return score
18
19
20
search_space = {"x1": np.arange(-100, 101, 1)}
21
22
23
simulated_annealing_para = [
24
    ({"annealing_rate": 0.9}),
25
    ({"annealing_rate": 0.8}),
26
    ({"annealing_rate": 0.5}),
27
    ({"annealing_rate": 1}),
28
    ({"start_temp": 1}),
29
    ({"start_temp": 0.5}),
30
    ({"start_temp": 3}),
31
    ({"start_temp": 10}),
32
]
33
34
35
pytest_wrapper = ("opt_para", simulated_annealing_para)
36
37
38
@pytest.mark.parametrize(*pytest_wrapper)
39
def test_hill_climbing_para(opt_para):
40
    _base_para_test_func(opt_para, SimulatedAnnealingOptimizer)
41