Completed
Push — master ( ce1e03...f67568 )
by Simon
14:21
created

RandomSearchOptimizer._init_iteration()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
6
from ...base_optimizer import BaseOptimizer
7
8
9
class RandomSearchOptimizer(BaseOptimizer):
10
    def __init__(self, _opt_args_):
11
        super().__init__(_opt_args_)
12
        self.n_positioners = 1
13
14
    def _iterate(self, i, _cand_):
15
        if i < 1:
16
            self._init_iteration(_cand_)
17
        else:
18
            self.p_list[0].move_random(_cand_)
19
            self._optimizer_eval(_cand_, self.p_list[0])
20
21
            self._update_pos(_cand_, self.p_list[0])
22
23
        return _cand_
24
25
    def _init_iteration(self, _cand_):
26
        p = super()._init_base_positioner(_cand_)
27
28
        self._optimizer_eval(_cand_, p)
29
        self._update_pos(_cand_, p)
30
31
        return p
32