| Total Complexity | 2 |
| Total Lines | 43 |
| 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 EvolutionStrategyOptimizer |
||
| 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 | ({"mutation_rate": 0.5}), |
||
| 22 | ({"mutation_rate": 0.9}), |
||
| 23 | ({"mutation_rate": 0.1}), |
||
| 24 | ({"mutation_rate": 0}), |
||
| 25 | ({"mutation_rate": 2}), |
||
| 26 | ({"crossover_rate": 0.5}), |
||
| 27 | ({"crossover_rate": 0.9}), |
||
| 28 | ({"crossover_rate": 0.1}), |
||
| 29 | ({"crossover_rate": 0}), |
||
| 30 | ({"crossover_rate": 2}), |
||
| 31 | ({"rand_rest_p": 0}), |
||
| 32 | ({"rand_rest_p": 0.5}), |
||
| 33 | ({"rand_rest_p": 1}), |
||
| 34 | ] |
||
| 35 | |||
| 36 | |||
| 37 | pytest_wrapper = ("opt_para", parallel_tempering_para) |
||
| 38 | |||
| 39 | |||
| 40 | @pytest.mark.parametrize(*pytest_wrapper) |
||
| 41 | def test_hill_climbing_para(opt_para): |
||
| 42 | _base_para_test_func(opt_para, EvolutionStrategyOptimizer) |
||
| 43 |