Use simulated annealing to find the global minimum

sa(f, x, temp = 10000, rate = 1e-04)

tspsa(x, temp = 100, rate = 1e-04)

Arguments

f

function representing f

x

an initial estimate of the minimum

temp

the initial temperature

rate

the cooling rate

Value

the x value of the minimum found

Details

Simulated annealing finds a global minimum by mimicing the metallurgical process of annealing.

See also

Examples

f <- function(x) { x^6 - 4 * x^5 - 7 * x^4 + 22 * x^3 + 24 * x^2 + 2}
sa(f, 0)
#> [1] 3.612758

f <- function(x) { (x[1] - 1)^2 + (x[2] - 1)^2 }
sa(f, c(0, 0), 0.05)
#> [1] 0 0