Passed
Push — master ( d39371...69bf6f )
by Simon
03:38
created

gradient_free_optimizers.optimizers.population.base_population_optimizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A BasePopulationOptimizer.__init__() 0 6 1
A BasePopulationOptimizer._iterations() 0 6 2
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
import numpy as np
6
7
8
class BasePopulationOptimizer:
9
    def __init__(self, search_space):
10
        self.search_space = search_space
11
        self.space_dim = np.array([array.size - 1 for array in search_space])
12
13
        self.eval_times = []
14
        self.iter_times = []
15
16
    def _iterations(self, positioners):
17
        nth_iter = 0
18
        for p in positioners:
19
            nth_iter = nth_iter + len(p.pos_new_list)
20
21
        return nth_iter
22