Total Complexity | 4 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # Author: Simon Blanke |
||
2 | # Email: [email protected] |
||
3 | # License: MIT License |
||
4 | |||
5 | import random |
||
6 | import numpy as np |
||
7 | |||
8 | |||
9 | from . import HillClimbingOptimizer |
||
10 | from ...search import Search |
||
11 | from scipy.spatial.distance import euclidean |
||
12 | |||
13 | |||
14 | class TabuOptimizer(HillClimbingOptimizer, Search): |
||
15 | def __init__(self, search_space, tabu_factor=3): |
||
16 | super().__init__(search_space) |
||
17 | |||
18 | self.tabus = [] |
||
19 | self.tabu_factor = tabu_factor |
||
20 | self.epsilon_mod = 1 |
||
21 | |||
22 | @HillClimbingOptimizer.iter_dec |
||
23 | def iterate(self): |
||
24 | return self._move_climb(self.pos_current) |
||
25 | |||
26 | def evaluate(self, score_new): |
||
27 | super().evaluate(score_new) |
||
28 | |||
29 | if score_new <= self.score_current: |
||
30 | self.epsilon_mod = self.tabu_factor |
||
31 | else: |
||
32 | self.epsilon_mod = 1 |
||
33 | |||
34 |