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

test_inertia()   A

Complexity

Conditions 2

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 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