Passed
Push — master ( 07671f...674edd )
by Simon
03:40
created

gradient_free_optimizers.optimizers.population.base_population_optimizer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A BasePopulationOptimizer.__init__() 0 12 1
A BasePopulationOptimizer._iterations() 0 6 2
A BasePopulationOptimizer.finish_initialization() 0 2 1
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
import numpy as np
6
from ...converter import Converter
7
from ...results_manager import ResultsManager
8
9
10
class BasePopulationOptimizer:
11
    def __init__(
12
        self,
13
        search_space,
14
        initialize={"grid": 4, "random": 2, "vertices": 4},
15
    ):
16
        super().__init__()
17
        self.conv = Converter(search_space)
18
        self.results_mang = ResultsManager(self.conv)
19
        self.initialize = initialize
20
21
        self.eval_times = []
22
        self.iter_times = []
23
24
    def _iterations(self, positioners):
25
        nth_iter = 0
26
        for p in positioners:
27
            nth_iter = nth_iter + len(p.pos_new_list)
28
29
        return nth_iter
30
31
    def finish_initialization(self):
32
        pass