| @@ 42-53 (lines=12) @@ | ||
| 39 | system.temp = 1.1 ** random.uniform(0, 25) |
|
| 40 | self.optimizers = self.systems |
|
| 41 | ||
| 42 | def _swap_pos(self): |
|
| 43 | for _p1_ in self.systems: |
|
| 44 | _systems_temp = copy.copy(self.systems) |
|
| 45 | if len(_systems_temp) > 1: |
|
| 46 | _systems_temp.remove(_p1_) |
|
| 47 | ||
| 48 | rand = random.uniform(0, 1) * 100 |
|
| 49 | _p2_ = np.random.choice(_systems_temp) |
|
| 50 | ||
| 51 | p_accept = self._accept_swap(_p1_, _p2_) |
|
| 52 | if p_accept > rand: |
|
| 53 | _p1_.temp, _p2_.temp = (_p2_.temp, _p1_.temp) |
|
| 54 | ||
| 55 | def _accept_swap(self, _p1_, _p2_): |
|
| 56 | s = (_p1_.score_current - _p2_.score_current) / ( |
|
| @@ 35-46 (lines=12) @@ | ||
| 32 | system.temp = 1.1 ** random.uniform(0, 25) |
|
| 33 | self.optimizers = self.systems |
|
| 34 | ||
| 35 | def _swap_pos(self): |
|
| 36 | for _p1_ in self.systems: |
|
| 37 | _systems_temp = copy.copy(self.systems) |
|
| 38 | if len(_systems_temp) > 1: |
|
| 39 | _systems_temp.remove(_p1_) |
|
| 40 | ||
| 41 | rand = random.uniform(0, 1) * 100 |
|
| 42 | _p2_ = np.random.choice(_systems_temp) |
|
| 43 | ||
| 44 | p_accept = self._accept_swap(_p1_, _p2_) |
|
| 45 | if p_accept > rand: |
|
| 46 | _p1_.temp, _p2_.temp = (_p2_.temp, _p1_.temp) |
|
| 47 | ||
| 48 | def _accept_swap(self, _p1_, _p2_): |
|
| 49 | denom = _p1_.score_current + _p2_.score_current |
|