example4_wild_fun {roptim} | R Documentation |
Example 4: Minimize a "wild" function using SANN and BFGS
Description
Minimize a "wild" function using SANN and BFGS.
Usage
example4_wild_fun()
Examples
## "wild" function , global minimum at about -15.81515
fw <- function (x)
10*sin(0.3*x)*sin(1.3*x^2) + 0.00001*x^4 + 0.2*x+80
plot(fw, -50, 50, n = 1000, main = "optim() minimising 'wild function'")
res <- optim(50, fw, method = "SANN",
control = list(maxit = 20000, temp = 20, parscale = 20))
res
## Now improve locally {typically only by a small bit}:
(r2 <- optim(res$par, fw, method = "BFGS"))
points(r2$par, r2$value, pch = 8, col = "red", cex = 2)
## corresponding C++ implementation:
example4_wild_fun()
[Package roptim version 0.1.6 Index]