Contents Previous Next Subchapters

Optimization Using the Nelder Mead Simplex Method
Syntax [xoutnf] = neldermead(function f...
        xindxxtolftolmfvallevel)
See Also fmins , conjdir , nlsq

Description
Uses a variation of the Nelder Mead simplex method is used to minimize a function of multiple variables without derivatives.

xout
is a vector with the same dimension as xin that contains the approximate minimizer of f(x).

nf
is the number of function evaluations used by neldermead. If more than mfval evaluations are required for convergence, nf is set to mfval + 1.

f(
x)
This function call returns a scalar value where x is a real or double-precision column vector with the same length as xin.

xin
The real or double-precision column vector xin specifies the location to start the minimization procedure at.

dx
The real or double-precision vector dx has the same dimension as xin and specifies the points in the initial simplex relative to simplex point xin. The j+1-th point in the initial simplex is displaced dx(j) units from xin in the j-th coordinate direction. All the elements of dx must be greater than zero. (Note that the current simplex size is used to detect convergence relative to the value of xtol.)

xtol
The real or double-precision vector xtol has the same dimension as xin and specifies the convergence criteria in argument space. It must be greater than or equal to zero.

ftol
The real or double-precision scalar ftol specifies the convergence criteria in function value units. It must be greater than or equal to zero.

mfval
The integer scalar mfval specifies the maximum number of function evaluations to attempt. If this number is exceeded without either of the convergence criteria being met,
     nf = mfval + 1


level
The integer scalar level specifies the amount of tracing that is printed during the minimization. The following table corresponds the value of level with what variables are printed and what their meaning is. Note that every line that is printed by this routine begins with the text neldermead:.
Level Heading Meaning
level > 1 dia diameter of the simplex
level > 1 nf number of function evaluations
level > 1 sf function values on simplex vertices
level == 2 xmin minimum x values in simplex
level == 2 xmax maximum x values in simplex
level == 3 sx all of the vertices in the simplex
Example
The following example minimizes the function
     f(x) = exp[(x  - 1)^2 ] + (x  - 2)^2
                  1              2
Note that the value of x that minimizes this function is
     /1\
     \2/


clear
function f(x) begin
     return exp( (x(1) - 1.)^2 ) + (x(2) - 2.)^2
end
one   = {1., 1.}
xin   = 0e0  * one
dx    = 1e0  * one
xtol  = 1e-3 * one
ftol  = 1e-6
mfval = 100
level = 0
neldermead(function f, xin, dx, xtol, ftol, mfval, level)

Mlmode

Syntax
In Mlmode , this function is accessed using the following syntax:
     fmins(
fxinoptions)
where the argument options is optional. In addition, each call of the form f(x) in neldermead is translated to a call of the form feval(fx). The following table has the correspondence between that arguments to neldermead and options. The value zero for an element of options is equivalent to using the default value below:
fmins Default neldermead
options(1) 0 level
options(2) 1e-4 all elements of xtol
options(3) 1e-4 ftol
options(14) 100 n-variables mfval
In addition the argument dx is given by
            / 100 xtol   if xin  = 0
     dx  = <          j         j
       j    \ .1 xin     otherwise
                       j

Example
The following example minimizes the function
     f(x) = (x  - 1)^2 + (x  - 2)^2
              1            2
Note that the value of x that minimizes this function is
     /1\
     \2/
If the file fun.m in the current directory contains the text
     function y = fun(x)
     y =  exp( (x(1) - 1.)^2 ) + (x(2) - 2.)^2;
and in Mlmode you enter
     clear
     xin   = [0. , 0.];
     f     = 'fun';
     fmins(f, xin)
O-Matrix will respond with an approximate minimizer for f(x).