This page was created by the IDL library routine
mk_html_help2.
Last modified: Mon May 5 18:17:35 2025.
NAME:
AMOEBA
PURPOSE:
Multidimensional minimization of a function FUNC(X), where
X is an N-dimensional vector, using the downhill simplex
method of Nelder and Mead, 1965, Computer Journal, Vol 7, pp 308-313.
This routine is based on the AMOEBA routine, Numerical
Recipes in C: The Art of Scientific Computing (Second Edition), Page
411, and is used by permission.
CATEGORY:
Function minimization/maximization. Simplex method.
CALLING SEQUENCE:
Result = AMOEBA(Ftol, ....)
INPUTS:
FTOL: the fractional tolerance to be achieved in the function
value. e.g. the fractional decrease in the function value in the
terminating step. This should never be less than the
machine's single or double precision.
KEYWORD PARAMETERS:
FUNCTION_NAME: a string containing the name of the function to
be minimized. If omitted, the function FUNC is minimized.
This function must accept an Ndim vector as its only parameter and
return a scalar single or double precision floating point value as its
result.
FUNCTION_VALUE: (output) on exit, an Ndim+1 element vector
containing the function values at the simplex points. The first
element contains the function minimum.
NCALLS: (output) the of times the function was evaluated.
NMAX: the maximum number of function evaluations allowed
before terminating. Default = 5000.
P0: Initial starting point, an Ndim element vector. The starting
point must be specified using either the keyword SIMPLEX, or P0 and
SCALE. P0 may be either single or double precision floating.
For example, in a 3-dimensional problem, if the initial guess
is the point [0,0,0], and it is known that the function's
minimum value occurs in the interval: -10 <
X(0) < 10, -100 < X(1) < 100, -200 < X(2) < 200, specify: P0=[0,0,0],
SCALE=[10, 100, 200].
SCALE: a scalar or Ndim element vector contaiing the problem's
characteristic length scale for each dimension.
SCALE is used with P0 to form an initial (Ndim+1) point simplex.
If all dimensions have the same scale, specify a scalar.
SIMPLEX: (output and/or optional input) On input, if P0 and SCALE
are not set, SIMPLEX contains the Ndim+1 vertices, each of
Ndim elements, of starting simplex, in either single or double
precision floating point, in an (Ndim, Ndim+1) array. On output,
SIMPLEX contains the simplex, of dimensions (Ndim, Ndim+1), enclosing
the function minimum. The first point, Simplex(*,0), corresponds to
the function's minimum.
OUTPUTS:
Result: If the minimum is found, an Ndim vector, corresponding to
the Function's minimum value is returned. If a function minimum
within the given tolerance, is NOT found in the given number of
evaluations, a scalar value of -1 is returned.
COMMON BLOCKS:
None.
SIDE EFFECTS:
None.
PROCEDURE:
This procedure implements the Simplex method, described in
Numerical Recipes, Section 10.4. See also the POWELL procedure.
Advantages: requires only function evaluations, not
derivatives, may be more reliable than the POWELL method.
Disadvantages: not as efficient as Powell's method, and usually
requires more function evaluations.
Results are performed in the mode (single or double precision)
returned by the user-supplied function. The mode of the inputs P0,
SCALE, or SIMPLEX, should match that returned by the function. The
mode of the input vector supplied to the user-written function, is
determined by P0, SCALE, or SIMPLEX.
EXAMPLE:
Use Amoeba to find the slope and intercept of a straight line fitting
a given set of points minimizing the maximum error:
The function to be minimized returns the maximum error,
given p(0) = intercept, and p(1) = slope:
FUNCTION FUNC, p
COMMON FUNC_XY, x, y
RETURN, MAX(ABS(y - (p(0) + p(1) * x)))
END
Put the data points into a common block so they are accessible to the
function:
COMMON FUNC_XY, x, y
Define the data points:
x = findgen(17)*5
y = [ 12.0, 24.3, 39.6, 51.0, 66.5, 78.4, 92.7, 107.8, 120.0, $
135.5, 147.5, 161.0, 175.4, 187.4, 202.5, 215.4, 229.9]
Call the function. Fractional tolerance = 1 part in 10^5,
Initial guess = [0,0], and the minimum should be found within
a distance of 100 of that point:
r = AMOEBA(1.0e-5, SCALE=1.0e2, P0 = [0, 0], FUNCTION_VALUE=fval)
Check for convergence:
if n_elements(r) eq 1 then message,'AMOEBA failed to converge'
Print results.
print, 'Intercept, Slope:', r, 'Function value (max error): ', fval(0)
Intercept, Slope: 11.4100 2.72800
Function value: 1.33000
MODIFICATION HISTORY:
DMS, May, 1996. Written.
(See projects/maven/sep/deconvolve/mvn_sep_amoeba.pro)