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

tests.test_optimizers.test_parameter.test_parallel_tempering_para_init   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 37
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 ParallelTemperingOptimizer
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(-100, 101, 1)}
18
19
20
parallel_tempering_para = [
21
    ({"n_iter_swap": 1}),
22
    ({"n_iter_swap": 2}),
23
    ({"n_iter_swap": 10}),
24
    ({"n_iter_swap": 100}),
25
    ({"rand_rest_p": 0}),
26
    ({"rand_rest_p": 0.5}),
27
    ({"rand_rest_p": 1}),
28
]
29
30
31
pytest_wrapper = ("opt_para", parallel_tempering_para)
32
33
34
@pytest.mark.parametrize(*pytest_wrapper)
35
def test_hill_climbing_para(opt_para):
36
    _base_para_test_func(opt_para, ParallelTemperingOptimizer)
37