Description Usage Arguments Details Value Note References See Also Examples

An implementation of the Nelder-Mead algorithm for derivative-free optimization / function minimization.

1 2 3 4 5 6 7 |

`fn` |
nonlinear function to be minimized. |

`x0` |
starting point for the iteration. |

`adapt` |
logical; adapt to parameter dimension. |

`tol` |
terminating limit for the variance of function values;
can be made *very* small, like |

`maxfeval` |
maximum number of function evaluations. |

`step` |
size and shape of initial simplex; relative magnitudes of its elements should reflect the units of the variables. |

`...` |
additional arguments to be passed to the function. |

`lower, upper` |
lower and upper bounds. |

Also called a ‘simplex’ method for finding the local minimum of a function of several variables. The method is a pattern search that compares function values at the vertices of the simplex. The process generates a sequence of simplices with ever reducing sizes.

The simplex function minimisation procedure due to Nelder and Mead (1965), as implemented by O'Neill (1971), with subsequent comments by Chambers and Ertel 1974, Benyon 1976, and Hill 1978. For another elaborate implementation of Nelder-Mead in R based on Matlab code by Kelley see package ‘dfoptim’.

`eldermead`

can be used up to 20 dimensions (then ‘tol’ and ‘maxfeval’
need to be increased). With `adapt=TRUE`

it applies adaptive
coefficients for the simplicial search, depending on the problem dimension
– see Fuchang and Lixing (2012). This approach especially reduces the
number of function calls.

With upper and/or lower bounds, `neldermeadb`

applies `transfinite`

to define the function on all of R^n and to retransform the solution to the
bounded domain. Of course, if the optimum is near to the boundary, results
will not be as accurate as when the minimum is in the interior.

List with following components:

`xmin` |
minimum solution found. |

`fmin` |
value of |

`fcount` |
number of iterations performed. |

`restarts` |
number of restarts. |

`errmess` |
error message |

Original FORTRAN77 version by R O'Neill; MATLAB version by John Burkardt under LGPL license. Re-implemented in R by Hans W. Borchers.

Nelder, J., and R. Mead (1965). A simplex method for function minimization. Computer Journal, Volume 7, pp. 308-313.

O'Neill, R. (1971). Algorithm AS 47: Function Minimization Using a Simplex Procedure. Applied Statistics, Volume 20(3), pp. 338-345.

J. C. Lagarias et al. (1998). Convergence properties of the Nelder-Mead simplex method in low dimensions. SIAM Journal for Optimization, Vol. 9, No. 1, pp 112-147.

Fuchang Gao and Lixing Han (2012). Implementing the Nelder-Mead simplex algorithm with adaptive parameters. Computational Optimization and Applications, Vol. 51, No. 1, pp. 259-277.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | ```
## Classical tests as in the article by Nelder and Mead
# Rosenbrock's parabolic valley
rpv <- function(x) 100*(x[2] - x[1]^2)^2 + (1 - x[1])^2
x0 <- c(-2, 1)
neldermead(rpv, x0) # 1 1
# 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(fphv, x0) # 1 0 0
# 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(psf, x0) # 0 0 0 0, needs maximum number of function calls
# Bounded version of Nelder-Mead
lower <- c(-Inf, 0, 0)
upper <- c( Inf, 0.5, 1)
x0 <- c(0, 0.1, 0.1)
neldermeadb(fnRosenbrock, c(0, 0.1, 0.1), lower = lower, upper = upper)
# $xmin = c(0.7085595, 0.5000000, 0.2500000)
# $fmin = 0.3353605
## Not run:
# Can run Rosenbrock's function in 30 dimensions in one and a half minutes:
neldermead(fnRosenbrock, rep(0, 30), tol=1e-20, maxfeval=10^7)
# $xmin
# [1] 0.9999998 1.0000004 1.0000000 1.0000001 1.0000000 1.0000001
# [7] 1.0000002 1.0000001 0.9999997 0.9999999 0.9999997 1.0000000
# [13] 0.9999999 0.9999994 0.9999998 0.9999999 0.9999999 0.9999999
# [19] 0.9999999 1.0000001 0.9999998 1.0000000 1.0000003 0.9999999
# [25] 1.0000000 0.9999996 0.9999995 0.9999990 0.9999973 0.9999947
# $fmin
# [1] 5.617352e-10
# $fcount
# [1] 1426085
# elapsed time is 96.008000 seconds
## End(Not run)
``` |

```
$xmin
[1] 0.9999999 0.9999998
$fmin
[1] 1.157529e-14
$fcount
[1] 196
$restarts
[1] 0
$xmin
[1] 1.000050e+00 7.717336e-05 9.456440e-05
$fmin
[1] 9.124543e-08
$fcount
[1] 187
$restarts
[1] 0
$xmin
[1] 0.020206448 -0.002035466 0.013110918 0.013000534
$fmin
[1] 7.474131e-07
$fcount
[1] 348
$restarts
[1] 1
$xmin
[1] 0.7085595 0.5000000 0.2500000
$fmin
[1] 0.3353605
$fcount
[1] 1710
$restarts
[1] 5
$xmin
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
$fmin
[1] 2.329965e-15
$fcount
[1] 523242
$restarts
[1] 3
```

adagio documentation built on May 17, 2018, 3:01 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.