| @@ 14-44 (lines=31) @@ | ||
| 11 | _name_ = "random_annealing" |
|
| 12 | __name__ = "RandomAnnealingOptimizer" |
|
| 13 | ||
| 14 | def __init__( |
|
| 15 | self, |
|
| 16 | search_space, |
|
| 17 | initialize={"grid": 4, "random": 2, "vertices": 4}, |
|
| 18 | constraints=[], |
|
| 19 | random_state=None, |
|
| 20 | rand_rest_p=0, |
|
| 21 | nth_process=None, |
|
| 22 | epsilon=0.03, |
|
| 23 | distribution="normal", |
|
| 24 | n_neighbours=3, |
|
| 25 | annealing_rate=0.98, |
|
| 26 | start_temp=10, |
|
| 27 | ): |
|
| 28 | super().__init__( |
|
| 29 | search_space=search_space, |
|
| 30 | initialize=initialize, |
|
| 31 | constraints=constraints, |
|
| 32 | random_state=random_state, |
|
| 33 | rand_rest_p=rand_rest_p, |
|
| 34 | nth_process=nth_process, |
|
| 35 | epsilon=epsilon, |
|
| 36 | distribution=distribution, |
|
| 37 | n_neighbours=n_neighbours, |
|
| 38 | ) |
|
| 39 | self.epsilon = epsilon |
|
| 40 | self.distribution = distribution |
|
| 41 | self.n_neighbours = n_neighbours |
|
| 42 | self.annealing_rate = annealing_rate |
|
| 43 | self.start_temp = start_temp |
|
| 44 | self.temp = start_temp |
|
| 45 | ||
| 46 | @HillClimbingOptimizer.track_new_pos |
|
| 47 | @HillClimbingOptimizer.random_iteration |
|
| @@ 19-47 (lines=29) @@ | ||
| 16 | optimizer_type = "local" |
|
| 17 | computationally_expensive = False |
|
| 18 | ||
| 19 | def __init__( |
|
| 20 | self, |
|
| 21 | search_space, |
|
| 22 | initialize={"grid": 4, "random": 2, "vertices": 4}, |
|
| 23 | constraints=[], |
|
| 24 | random_state=None, |
|
| 25 | rand_rest_p=0, |
|
| 26 | nth_process=None, |
|
| 27 | epsilon=0.03, |
|
| 28 | distribution="normal", |
|
| 29 | n_neighbours=3, |
|
| 30 | annealing_rate=0.97, |
|
| 31 | start_temp=1, |
|
| 32 | ): |
|
| 33 | super().__init__( |
|
| 34 | search_space=search_space, |
|
| 35 | initialize=initialize, |
|
| 36 | constraints=constraints, |
|
| 37 | random_state=random_state, |
|
| 38 | rand_rest_p=rand_rest_p, |
|
| 39 | nth_process=nth_process, |
|
| 40 | epsilon=epsilon, |
|
| 41 | distribution=distribution, |
|
| 42 | n_neighbours=n_neighbours, |
|
| 43 | ) |
|
| 44 | ||
| 45 | self.annealing_rate = annealing_rate |
|
| 46 | self.start_temp = start_temp |
|
| 47 | self.temp = start_temp |
|
| 48 | ||
| 49 | def _p_accept_default(self): |
|
| 50 | # the 'minus' is omitted, because we maximize a score |
|