| Total Complexity | 2 |
| Total Lines | 35 |
| 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 RepulsingHillClimbingOptimizer |
||
| 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 | tabu_search = hill_climbing_para + [ |
||
| 22 | ({"repulsion_factor": 1}), |
||
| 23 | ({"repulsion_factor": 2}), |
||
| 24 | ({"repulsion_factor": 2.5}), |
||
| 25 | ({"repulsion_factor": 10}), |
||
| 26 | ] |
||
| 27 | |||
| 28 | |||
| 29 | pytest_wrapper = ("opt_para", tabu_search) |
||
| 30 | |||
| 31 | |||
| 32 | @pytest.mark.parametrize(*pytest_wrapper) |
||
| 33 | def test_hill_climbing_para(opt_para): |
||
| 34 | _base_para_test_func(opt_para, RepulsingHillClimbingOptimizer) |
||
| 35 |