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

gradient_free_optimizers.optimizers.random.random_annealing   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A RandomAnnealingOptimizer.__init__() 0 4 1
A RandomAnnealingOptimizer.iterate() 0 5 1
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
6
from ..local import HillClimbingOptimizer
7
from ...search import Search
8
9
10
class RandomAnnealingOptimizer(HillClimbingOptimizer, Search):
11
    def __init__(self, search_space, annealing_rate=0.99, start_temp=100):
12
        super().__init__(search_space)
13
        self.annealing_rate = annealing_rate
14
        self.temp = start_temp
15
16
    def iterate(self):
17
        pos = self._move_climb(self.pos_current, epsilon_mod=self.temp / 10)
18
        self.temp = self.temp * self.annealing_rate
19
20
        return pos
21