Passed
Push — master ( 44bd28...268666 )
by Simon
03:57
created

tests.test_optimizer_parameter.test_ParticleSwarm   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 6

3 Functions

Rating   Name   Duplication   Size   Complexity  
A test_social_weight() 0 4 2
A test_cognitive_weight() 0 4 2
A test_inertia() 0 4 2
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