Corana et al.’ Simulated Annealing (CSA)¶
- class pypop7.optimizers.sa.csa.CSA(problem, options)¶
Corana et al.’ Simulated Annealing (CSA).
- Parameters:
problem (dict) –
- problem arguments with the following common settings (keys):
’fitness_function’ - objective function to be minimized (func),
’ndim_problem’ - number of dimensionality (int),
’upper_boundary’ - upper boundary of search range (array_like),
’lower_boundary’ - lower boundary of search range (array_like).
options (dict) –
- optimizer options with the following common settings (keys):
’max_function_evaluations’ - maximum of function evaluations (int, default: np.Inf),
’max_runtime’ - maximal runtime to be allowed (float, default: np.Inf),
’seed_rng’ - seed for random number generation needed to be explicitly set (int);
- and with the following particular settings (keys):
’sigma’ - initial global step-size (float),
’temperature’ - annealing temperature (float),
’n_sv’ - frequency of step variation (int, default: 20),
’c’ - factor of step variation (float, default: 2.0),
- ’n_tr’ - frequency of temperature reduction (int, default:
np.maximum(100, 5*problem[‘ndim_problem’])),
’f_tr’ - factor of temperature reduction (int, default: 0.85).
Examples
Use the optimizer to minimize the well-known test function Rosenbrock:
1>>> import numpy 2>>> from pypop7.benchmarks.base_functions import rosenbrock # function to be minimized 3>>> from pypop7.optimizers.sa.csa import CSA 4>>> problem = {'fitness_function': rosenbrock, # define problem arguments 5... 'ndim_problem': 2, 6... 'lower_boundary': -5*numpy.ones((2,)), 7... 'upper_boundary': 5*numpy.ones((2,))} 8>>> options = {'max_function_evaluations': 5000, # set optimizer options 9... 'seed_rng': 2022, 10... 'x': 3*numpy.ones((2,)), 11... 'sigma': 1.0, 12... 'temperature': 100} 13>>> csa = CSA(problem, options) # initialize the optimizer class 14>>> results = csa.optimize() # run the optimization process 15>>> # return the number of function evaluations and best-so-far fitness 16>>> print(f"CSA: {results['n_function_evaluations']}, {results['best_so_far_y']}") 17CSA: 5000, 0.0023146719686626344
For its correctness checking of coding, refer to this code-based repeatability report for more details.
- c¶
factor of step variation.
- Type:
float
- f_tr¶
factor of temperature reduction.
- Type:
int
- n_sv¶
frequency of step variation
- Type:
int
- n_tr¶
frequency of temperature reduction
- Type:
int
- sigma¶
initial global step-size.
- Type:
float
- temperature¶
annealing temperature.
- Type:
float
References
Corana, A., Marchesi, M., Martini, C. and Ridella, S., 1987. Minimizing multimodal functions of continuous variables with the “simulated annealing” algorithm. ACM Transactions on Mathematical Software, 13(3), pp.262-280. https://dl.acm.org/doi/abs/10.1145/29380.29864 https://dl.acm.org/doi/10.1145/66888.356281
Kirkpatrick, S., Gelatt, C.D. and Vecchi, M.P., 1983. Optimization by simulated annealing. Science, 220(4598), pp.671-680. https://science.sciencemag.org/content/220/4598/671