|
2 | 2 |
|
3 | 3 |
|
4 | 4 | class SimulatedAnnealing(_BaseGFOadapter): |
| 5 | + """Simulated annealing optimizer. |
| 6 | +
|
| 7 | + Parameters |
| 8 | + ---------- |
| 9 | + search_space : dict[str, list] |
| 10 | + The search space to explore. A dictionary with parameter |
| 11 | + names as keys and a numpy array as values. |
| 12 | + initialize : dict[str, int] |
| 13 | + The method to generate initial positions. A dictionary with |
| 14 | + the following key literals and the corresponding value type: |
| 15 | + {"grid": int, "vertices": int, "random": int, "warm_start": list[dict]} |
| 16 | + constraints : list[callable] |
| 17 | + A list of constraints, where each constraint is a callable. |
| 18 | + The callable returns `True` or `False` dependend on the input parameters. |
| 19 | + random_state : None, int |
| 20 | + If None, create a new random state. If int, create a new random state |
| 21 | + seeded with the value. |
| 22 | + rand_rest_p : float |
| 23 | + The probability of a random iteration during the the search process. |
| 24 | + epsilon : float |
| 25 | + The step-size for the climbing. |
| 26 | + distribution : str |
| 27 | + The type of distribution to sample from. |
| 28 | + n_neighbours : int |
| 29 | + The number of neighbours to sample and evaluate before moving to the best |
| 30 | + of those neighbours. |
| 31 | + annealing_rate : float |
| 32 | + The rate at which the temperature is annealed. |
| 33 | + start_temp : float |
| 34 | + The initial temperature. |
| 35 | + n_iter : int, default=100 |
| 36 | + The number of iterations to run the optimizer. |
| 37 | + verbose : bool, default=False |
| 38 | + If True, print the progress of the optimization process. |
| 39 | + experiment : BaseExperiment, optional |
| 40 | + The experiment to optimize parameters for. |
| 41 | + Optional, can be passed later via ``set_params``. |
| 42 | + """ |
| 43 | + |
| 44 | + def __init__( |
| 45 | + self, |
| 46 | + search_space=None, |
| 47 | + initialize=None, |
| 48 | + constraints=None, |
| 49 | + random_state=None, |
| 50 | + rand_rest_p=0.1, |
| 51 | + epsilon=0.01, |
| 52 | + distribution="normal", |
| 53 | + n_neighbours=10, |
| 54 | + annealing_rate=0.97, |
| 55 | + start_temp=1, |
| 56 | + n_iter=100, |
| 57 | + verbose=False, |
| 58 | + experiment=None, |
| 59 | + ): |
| 60 | + self.random_state = random_state |
| 61 | + self.rand_rest_p = rand_rest_p |
| 62 | + self.epsilon = epsilon |
| 63 | + self.distribution = distribution |
| 64 | + self.n_neighbours = n_neighbours |
| 65 | + self.annealing_rate = annealing_rate |
| 66 | + self.start_temp = start_temp |
| 67 | + self.search_space = search_space |
| 68 | + self.initialize = initialize |
| 69 | + self.constraints = constraints |
| 70 | + self.n_iter = n_iter |
| 71 | + self.experiment = experiment |
| 72 | + self.verbose = verbose |
| 73 | + |
| 74 | + super().__init__() |
5 | 75 |
|
6 | 76 | def _get_gfo_class(self): |
7 | 77 | """Get the GFO class to use. |
|
0 commit comments