Skip to contents

Reflection 1, expansion 2, contraction 1/2 and shrink 1/2 with the ordering and acceptance rules of Lagarias et al. (1998); the initial simplex is x0 plus step_i e_i, step_i = 0.1 max(1, |x0_i|). Stops when the simplex diameter about the best vertex is at most xtol and the value spread at most ftol.

Usage

NelderMead(f, x0, step = NULL, xtol = 1e-10, ftol = 1e-10, max_iter = NULL)

Arguments

f

Objective.

x0

Starting point.

step

Initial edge lengths (scalar or vector); NULL for the default.

xtol, ftol

Tolerances.

max_iter

Iteration cap (default 200 n).

Value

list(x, fun, n_iter, n_fev, converged, simplex).

References

Nelder, J. A. and Mead, R. (1965). A simplex method for function minimization. Computer Journal 7, 308-313. Lagarias, J. C., Reeds, J. A., Wright, M. H. and Wright, P. E. (1998). SIAM Journal on Optimization 9, 112-147.

Examples

NelderMead(function(x) (x[1] - 1)^2 + (x[2] + 2)^2, c(0, 0))$x
#> [1]  1 -2