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

StochasticTunnelingOptimizer._accept()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
6
import numpy as np
7
8
from .simulated_annealing import SimulatedAnnealingOptimizer
9
from ...search import Search
10
11
12
class StochasticTunnelingOptimizer(SimulatedAnnealingOptimizer, Search):
13
    def __init__(self, search_space, gamma=0.5, **kwargs):
14
        super().__init__(search_space, **kwargs)
15
16
    def _accept(self):
17
        f_stun = 1 - np.exp(-self._opt_args_.gamma * self._score_norm())
18
        return np.exp(-f_stun / self.temp)
19