Examples for 'nloptr::neldermead'


Nelder-Mead Simplex

Aliases: neldermead

Keywords:

### ** Examples


# Fletcher and Powell's helic valley
fphv <- function(x)
    100*(x[3] - 10*atan2(x[2], x[1])/(2*pi))^2 +
        (sqrt(x[1]^2 + x[2]^2) - 1)^2 +x[3]^2
x0 <- c(-1, 0, 0)
neldermead(x0, fphv)    #  1 0 0
$par
[1] 1.000000e+00 4.940772e-08 6.181353e-08

$value
[1] 5.887553e-14

$iter
[1] 282

$convergence
[1] 4

$message
[1] "NLOPT_XTOL_REACHED: Optimization stopped because xtol_rel or xtol_abs (above) was reached."
# Powell's Singular Function (PSF)
psf <- function(x)  (x[1] + 10*x[2])^2 + 5*(x[3] - x[4])^2 +
                    (x[2] - 2*x[3])^4 + 10*(x[1] - x[4])^4
x0 <- c(3, -1, 0, 1)
neldermead(x0, psf)     #  0 0 0 0, needs maximum number of function calls
$par
[1] -4.085274e-11  4.085274e-12 -3.522447e-11 -3.522447e-11

$value
[1] 3.721119e-41

$iter
[1] 1000

$convergence
[1] 5

$message
[1] "NLOPT_MAXEVAL_REACHED: Optimization stopped because maxeval (above) was reached."
## Not run: 
##D # Bounded version of Nelder-Mead
##D rosenbrock <- function(x) { ## Rosenbrock Banana function
##D     100 * (x[2] - x[1]^2)^2 + (1 - x[1])^2 + 
##D     100 * (x[3] - x[2]^2)^2 + (1 - x[2])^2
##D }
##D lower <- c(-Inf, 0,   0)
##D upper <- c( Inf, 0.5, 1)
##D x0 <- c(0, 0.1, 0.1)
##D S <- neldermead(c(0, 0.1, 0.1), rosenbrock, lower, upper, nl.info = TRUE)
##D # $xmin = c(0.7085595, 0.5000000, 0.2500000)
##D # $fmin = 0.3353605
## End(Not run)

[Package nloptr version 2.0.3 Index]