| Total Complexity | 4 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 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 |