| Total Complexity | 2 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |