neldermead
- sherpa.optmethods.optfcts.neldermead(fcn, x0, xmin, xmax, ftol=1.1920928955078125e-07, maxfev=None, initsimplex=0, finalsimplex=9, step=None, iquad=1, verbose=0, reflect=True)[source] [edit on github]
Nelder-Mead Simplex optimization method.
The Nelder-Mead Simplex algorithm, devised by J.A. Nelder and R. Mead 1, is a direct search method of optimization for finding a local minimum of an objective function of several variables. The implementation of the Nelder-Mead Simplex algorithm is a variation of the algorithm outlined in 2 and 3. As noted, terminating the simplex is not a simple task:
“For any non-derivative method, the issue of termination is problematical as well as highly sensitive to problem scaling. Since gradient information is unavailable, it is provably impossible to verify closeness to optimality simply by sampling f at a finite number of points. Most implementations of direct search methods terminate based on two criteria intended to reflect the progress of the algorithm: either the function values at the vertices are close, or the simplex has become very small.”
“Either form of termination-close function values or a small simplex-can be misleading for badly scaled functions.”
- Parameters
fcn (function reference) – Returns the current statistic and per-bin statistic value when given the model parameters.
x0 (sequence of number) – The starting point, minimum, and maximum values for each parameter.
xmin (sequence of number) – The starting point, minimum, and maximum values for each parameter.
xmax (sequence of number) – The starting point, minimum, and maximum values for each parameter.
ftol (number) – The function tolerance to terminate the search for the minimum; the default is sqrt(DBL_EPSILON) ~ 1.19209289551e-07, where DBL_EPSILON is the smallest number x such that
1.0 != 1.0 + x
.maxfev (int or
None
) – The maximum number of function evaluations; the default value ofNone
means to use1024 * n
, wheren
is the number of free parameters.initsimplex (int) – Dictates how the non-degenerate initial simplex is to be constructed. Default is
0
; see the “cases for initsimplex” section below for details.finalsimplex (int) – At each iteration, a combination of one of the following stopping criteria is tested to see if the simplex has converged or not. Full details are in the “cases for finalsimplex” section below.
step (array of number or
None
) – A list of lengthn
(number of free parameters) to initialize the simplex; see theinitsimplex
for details. The default ofNone
means to use a step of 0.4 for each free parameter.iquad (int) – A boolean flag which indicates whether a fit to a quadratic surface is done. If iquad is set to
1
(the default) then a fit to a quadratic surface is done; if iquad is set to0
then the quadratic surface fit is not done. If the fit to the quadratic surface is not positive semi-definitive, then the search terminated prematurely. The code to fit the quadratic surface was written by D. E. Shaw, CSIRO, Division of Mathematics & Statistics, with amendments by R. W. M. Wedderburn, Rothamsted Experimental Station, and Alan Miller, CSIRO, Division of Mathematics & Statistics. See also 1.verbose (int) – The amount of information to print during the fit. The default is
0
, which means no output.reflect (bool) – When a parameter exceeds a limit should the parameter be reflected, so moved back within bounds (
True
, the default) or should the model evaluation return DBL_MAX, causing the current set of parameters to be excluded from the simplex.
Notes
The
initsimplex
option determines how the non-degenerate initial simplex is to be constructed:when
initsimplex
is0
:Then x_(user_supplied) is one of the vertices of the simplex. The other
n
vertices are:for ( int i = 0; i < n; ++i ) { for ( int j = 0; j < n; ++j ) x[ i + 1 ][ j ] = x_[ j ]; x[ i + 1 ][ i ] = x_[ i ] + step[ i ]; }
where step[i] is the ith element of the option step.
if
initsimplex
is1
:Then x_(user_supplied) is one of the vertices of the simplex. The other
n
vertices are:{ x_[j] + pn, if i - 1 != j { x[i][j] = { { { x_[j] + qn, otherwise
for 1 <= i <= n, 0 <= j < n and:
pn = ( sqrt( n + 1 ) - 1 + n ) / ( n * sqrt(2) ) qn = ( sqrt( n + 1 ) - 1 ) / ( n * sqrt(2) )
The
finalsimplex
option determines whether the simplex has converged:case a (if the max length of the simplex is small enough):
max( | x_i - x_0 | ) <= ftol max( 1, | x_0 | ) 1 <= i <= n
case b (if the standard deviation the simplex is <
ftol
):n - 2 === ( f - f ) \ i 2 / ----------- <= ftol ==== sqrt( n ) i = 0
case c (if the function values are close enough):
f_0 < f_(n-1) within ftol
The combination of the above stopping criteria are:
case 0: same as case a
case 1: case a, case b and case c have to be met
case 2: case a and either case b or case c have to be met.
The
finalsimplex
value controls which of these criteria need to hold:if
finalsimplex=0
then convergence is assumed if case 1 is met.if
finalsimplex=1
then convergence is assumed if case 2 is met.if
finalsimplex=2
then convergence is assumed if case 0 is met at two consecutive iterations.if
finalsimplex=3
then convergence is assumed if case 0 then case 1 are met on two consecutive iterations.if
finalsimplex=4
then convergence is assumed if case 0 then case 1 then case 0 are met on three consecutive iterations.if
finalsimplex=5
then convergence is assumed if case 0 then case 1 then case 0 are met on three consecutive iterations.if
finalsimplex=6
then convergence is assumed if case 1 then case 1 then case 0 are met on three consecutive iterations.if
finalsimplex=7
then convergence is assumed if case 2 then case 1 then case 0 are met on three consecutive iterations.if
finalsimplex=8
then convergence is assumed if case 0 then case 2 then case 0 are met on three consecutive iterations.if
finalsimplex=9
then convergence is assumed if case 0 then case 1 then case 1 are met on three consecutive iterations.if
finalsimplex=10
then convergence is assumed if case 0 then case 2 then case 1 are met on three consecutive iterations.if
finalsimplex=11
then convergence is assumed if case 1 is met on three consecutive iterations.if
finalsimplex=12
then convergence is assumed if case 1 then case 2 then case 1 are met on three consecutive iterations.if
finalsimplex=13
then convergence is assumed if case 2 then case 1 then case 1 are met on three consecutive iterations.otherwise convergence is assumed if case 2 is met on three consecutive iterations.
References
- 1(1,2)
“A simplex method for function minimization”, J.A. Nelder and R. Mead (Computer Journal, 1965, vol 7, pp 308-313) https://doi.org/10.1093%2Fcomjnl%2F7.4.308
- 2
“Convergence Properties of the Nelder-Mead Simplex Algorithm in Low Dimensions”, Jeffrey C. Lagarias, James A. Reeds, Margaret H. Wright, Paul E. Wright , SIAM Journal on Optimization, Vol. 9, No. 1 (1998), pages 112-147. http://citeseer.ist.psu.edu/3996.html
- 3
“Direct Search Methods: Once Scorned, Now Respectable” Wright, M. H. (1996) in Numerical Analysis 1995 (Proceedings of the 1995 Dundee Biennial Conference in Numerical Analysis, D.F. Griffiths and G.A. Watson, eds.), 191-208, Addison Wesley Longman, Harlow, United Kingdom. http://citeseer.ist.psu.edu/155516.html