Title: | R Functions for Generalized Simulated Annealing |
---|---|
Description: | Performs search for global minimum of a very complex non-linear objective function with a very large number of optima. |
Authors: | Sylvain Gubian, Yang Xiang, Brian Suomela, Julia Hoeng, PMP SA. |
Maintainer: | Sylvain Gubian <[email protected]> |
License: | GPL-2 |
Version: | 1.1.14.1 |
Built: | 2024-11-21 06:22:08 UTC |
Source: | CRAN |
This function searches for global minimum of a very complex non-linear objective function with a very large number of optima.
GenSA(par = NULL, fn, lower, upper, control = list(), ...)
GenSA(par = NULL, fn, lower, upper, control = list(), ...)
par |
Vector. Initial values for the components to be optimized.
Default is |
fn |
A function to be minimized, with first argument the vector of parameters over which minimization is to take place. It should return a scalar result. |
lower |
Vector with length of |
upper |
Vector with length of |
control |
The argument is a list that can be used to control the behavior of the algorithm
|
... |
allows the user to pass additional arguments to the function
|
The default values of the control components are set for a complex
optimization problem.
For usual optimization problem with medium complexity, GenSA can find a
reasonable solution quickly sot he user is recommended to let GenSA stop
earlier by setting threshold.stop
. If threshold.stop
is the
expected function value, or by setting max.time
. If the user just
want to run GenSA for max.time
seconds, or by setting max.call
.
If the user just want to run GenSA within max.call
function calls.
Please refer to the examples below. For very complex optimization problems,
the user is recommended to increase maxit
and temp
.
The returned value is a list with the following fields:
Numeric. The value of fn
corresponding to par
.
Vector. The best set of parameters found.
A matrix which contains the history of the algorithm. (By columns: Step number, temperature, current objective function value, current minimal objective function value).
Integer. Total number of calls of the objective function.
Yang Xiang, Sylvain Gubian, Brian Suomela, Julia Hoeng, PMP SA. . (Y.Xiang and S.Gubian are equal contributors)
Xiang Y, Gubian S, Martin F (2017). "Generalized Simulated Annealing." IntechOpen, Computational Optimization in Engineering, Chapter 2.
Xiang Y, Gubian S, Suomela B, Hoeng (2013). "Generalized Simulated Annealing for Efficient Global Optimization: the GenSA Package for R". The R Journal Volume 5/1, June 2013.
Xiang Y, Sun DY, Gong XG (2000). "Generalized Simulated Annealing Studies on Structures and Properties of Nin (n=2-55) Clusters." Journal of Physical Chemistry A, 104, 2746–2751.
Xiang Y, Gong XG (2000a). "Efficiency of Generalized Simulated Annealing." PHYSICAL REVIEW E, 62, 4473.
Xiang Y, Sun DY, Fan W, Gong XG (1997). "Generalized Simulated Annealing Algorithm and Its Application to the Thomson Model." Physics Letters A, 233, 216–220.
Tsallis C, Stariolo DA (1996). "Generalized Simulated Annealing." Physica A, 233, 395–406.
Tsallis C (1988). "Possible generalization of Boltzmann-Gibbs statistics." Journal of Statistical Physics, 52, 479–487.
library(GenSA) # Try Rastrgin function (The objective function value for global minimum # is 0 with all components of par are 0.) Rastrigin <- function(x) { sum(x^2 - 10 * cos(2 * pi * x)) + 10 * length(x) } # Perform the search on a 30 dimensions rastrigin function. Rastrigin # function with dimension 30 is known as the most # difficult optimization problem according to "Yao X, Liu Y, Lin G (1999). # \Evolutionary Programming Made Faster." # IEEE Transactions on Evolutionary Computation, 3(2), 82-102. # GenSA will stop after finding the targeted function value 0 with # absolute tolerance 1e-13 set.seed(1234) # The user can use any seed. dimension <- 30 global.min <- 0 tol <- 1e-13 lower <- rep(-5.12, dimension) upper <- rep(5.12, dimension) out <- GenSA(lower = lower, upper = upper, fn = Rastrigin, control=list(threshold.stop=global.min+tol,verbose=TRUE)) out[c("value","par","counts")] # GenSA will stop after running for about 2 seconds # Note: The time for solving this problem by GenSA may vary # depending on the computer used. set.seed(1234) # The user can use any seed. dimension <- 30 global.min <- 0 tol <- 1e-13 lower <- rep(-5.12, dimension) upper <- rep(5.12, dimension) out <- GenSA(lower = lower, upper = upper, fn = Rastrigin, control=list(max.time=2)) out[c("value","par","counts")]
library(GenSA) # Try Rastrgin function (The objective function value for global minimum # is 0 with all components of par are 0.) Rastrigin <- function(x) { sum(x^2 - 10 * cos(2 * pi * x)) + 10 * length(x) } # Perform the search on a 30 dimensions rastrigin function. Rastrigin # function with dimension 30 is known as the most # difficult optimization problem according to "Yao X, Liu Y, Lin G (1999). # \Evolutionary Programming Made Faster." # IEEE Transactions on Evolutionary Computation, 3(2), 82-102. # GenSA will stop after finding the targeted function value 0 with # absolute tolerance 1e-13 set.seed(1234) # The user can use any seed. dimension <- 30 global.min <- 0 tol <- 1e-13 lower <- rep(-5.12, dimension) upper <- rep(5.12, dimension) out <- GenSA(lower = lower, upper = upper, fn = Rastrigin, control=list(threshold.stop=global.min+tol,verbose=TRUE)) out[c("value","par","counts")] # GenSA will stop after running for about 2 seconds # Note: The time for solving this problem by GenSA may vary # depending on the computer used. set.seed(1234) # The user can use any seed. dimension <- 30 global.min <- 0 tol <- 1e-13 lower <- rep(-5.12, dimension) upper <- rep(5.12, dimension) out <- GenSA(lower = lower, upper = upper, fn = Rastrigin, control=list(max.time=2)) out[c("value","par","counts")]