| Total Complexity | 6 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # Author: Simon Blanke |
||
| 2 | # Email: [email protected] |
||
| 3 | # License: MIT License |
||
| 4 | |||
| 5 | import numpy as np |
||
| 6 | |||
| 7 | from gradient_free_optimizers import ParticleSwarmOptimizer |
||
| 8 | from ._base_test import _base_test |
||
| 9 | |||
| 10 | n_iter = 100 |
||
| 11 | opt = ParticleSwarmOptimizer |
||
| 12 | |||
| 13 | |||
| 14 | def test_inertia(): |
||
| 15 | for inertia in [0.1, 0.9]: |
||
| 16 | opt_para = {"inertia": inertia} |
||
| 17 | _base_test(opt, n_iter, opt_para=opt_para) |
||
| 18 | |||
| 19 | |||
| 20 | def test_cognitive_weight(): |
||
| 21 | for cognitive_weight in [0.1, 0.9]: |
||
| 22 | opt_para = {"cognitive_weight": cognitive_weight} |
||
| 23 | _base_test(opt, n_iter, opt_para=opt_para) |
||
| 24 | |||
| 25 | |||
| 26 | def test_social_weight(): |
||
| 27 | for social_weight in [0.1, 0.9]: |
||
| 28 | opt_para = {"social_weight": social_weight} |
||
| 29 | _base_test(opt, n_iter, opt_para=opt_para) |
||
| 30 |