(octave.info)Minimizers
20.2 Minimizers
===============
Often it is useful to find the minimum value of a function rather than
just the zeroes where it crosses the x-axis. ‘fminbnd’ is designed for
the simpler, but very common, case of a univariate function where the
interval to search is bounded. For unbounded minimization of a function
with potentially many variables use ‘fminunc’ or ‘fminsearch’. The two
functions use different internal algorithms and some knowledge of the
objective function is required. For functions which can be
differentiated, ‘fminunc’ is appropriate. For functions with
discontinuities, or for which a gradient search would fail, use
‘fminsearch’. Note: Optimization, for minimization with the presence
of constraint functions. Note that searches can be made for maxima by
simply inverting the objective function (‘Fto_max = -Fto_min’).
-- : [X, FVAL, INFO, OUTPUT] = fminbnd (FUN, A, B, OPTIONS)
Find a minimum point of a univariate function.
FUN should be a function handle or name. A, B specify a starting
interval. OPTIONS is a structure specifying additional options.
Currently, ‘fminbnd’ recognizes these options: "FunValCheck",
"OutputFcn", "TolX", "MaxIter", "MaxFunEvals". For a description
of these options, see Note: optimset.
On exit, the function returns X, the approximate minimum point and
FVAL, the function value thereof.
INFO is an exit flag that can have these values:
• 1 The algorithm converged to a solution.
• 0 Maximum number of iterations or function evaluations has
been exhausted.
• -1 The algorithm has been terminated from user output
function.
Notes: The search for a minimum is restricted to be in the interval
bound by A and B. If you only have an initial point to begin
searching from you will need to use an unconstrained minimization
algorithm such as ‘fminunc’ or ‘fminsearch’. ‘fminbnd’ internally
uses a Golden Section search strategy.
See also: Note: fzero, Note: fminunc, Note:
fminsearch, Note: optimset.
-- : fminunc (FCN, X0)
-- : fminunc (FCN, X0, OPTIONS)
-- : [X, FVAL, INFO, OUTPUT, GRAD, HESS] = fminunc (FCN, ...)
Solve an unconstrained optimization problem defined by the function
FCN.
FCN should accept a vector (array) defining the unknown variables,
and return the objective function value, optionally with gradient.
‘fminunc’ attempts to determine a vector X such that ‘FCN (X)’ is a
local minimum.
X0 determines a starting guess. The shape of X0 is preserved in
all calls to FCN, but otherwise is treated as a column vector.
OPTIONS is a structure specifying additional options. Currently,
‘fminunc’ recognizes these options: "FunValCheck", "OutputFcn",
"TolX", "TolFun", "MaxIter", "MaxFunEvals", "GradObj",
"FinDiffType", "TypicalX", "AutoScaling".
If "GradObj" is "on", it specifies that FCN, when called with two
output arguments, also returns the Jacobian matrix of partial first
derivatives at the requested point. ‘TolX’ specifies the
termination tolerance for the unknown variables X, while ‘TolFun’
is a tolerance for the objective function value FVAL. The default
is ‘1e-7’ for both options.
For a description of the other options, see ‘optimset’.
On return, X is the location of the minimum and FVAL contains the
value of the objective function at X.
INFO may be one of the following values:
1
Converged to a solution point. Relative gradient error is
less than specified by ‘TolFun’.
2
Last relative step size was less than ‘TolX’.
3
Last relative change in function value was less than ‘TolFun’.
0
Iteration limit exceeded—either maximum number of algorithm
iterations ‘MaxIter’ or maximum number of function evaluations
‘MaxFunEvals’.
-1
Algorithm terminated by ‘OutputFcn’.
-3
The trust region radius became excessively small.
Optionally, ‘fminunc’ can return a structure with convergence
statistics (OUTPUT), the output gradient (GRAD) at the solution X,
and approximate Hessian (HESS) at the solution X.
Application Notes: If the objective function is a single nonlinear
equation of one variable then using ‘fminbnd’ is usually a better
choice.
The algorithm used by ‘fminunc’ is a gradient search which depends
on the objective function being differentiable. If the function
has discontinuities it may be better to use a derivative-free
algorithm such as ‘fminsearch’.
See also: Note: fminbnd, *note fminsearch:
XREFfminsearch, Note: optimset.
-- : X = fminsearch (FUN, X0)
-- : X = fminsearch (FUN, X0, OPTIONS)
-- : X = fminsearch (FUN, X0, OPTIONS, FUN_ARG1, FUN_ARG2, ...)
-- : [X, FVAL, EXITFLAG, OUTPUT] = fminsearch (...)
Find a value of X which minimizes the function FUN.
The search begins at the point X0 and iterates using the Nelder &
Mead Simplex algorithm (a derivative-free method). This algorithm
is better-suited to functions which have discontinuities or for
which a gradient-based search such as ‘fminunc’ fails.
Options for the search are provided in the parameter OPTIONS using
the function ‘optimset’. Currently, ‘fminsearch’ accepts the
options: "TolX", "TolFun", "MaxFunEvals", "MaxIter", "Display",
"FunValCheck", and "OutputFcn". For a description of these
options, see ‘optimset’.
Additional inputs for the function FUN can be passed as the fourth
and higher arguments. To pass function arguments while using the
default OPTIONS values, use ‘[]’ for OPTIONS.
On exit, the function returns X, the minimum point, and FVAL, the
function value at the minimum.
The third return value EXITFLAG is
1
if the algorithm converged (size of the simplex is smaller
than ‘OPTIONS.TolX’ *AND* the step in the function value
between iterations is smaller than ‘OPTIONS.TolFun’).
0
if the maximum number of iterations or the maximum number of
function evaluations are exceeded.
-1
if the iteration is stopped by the "OutputFcn".
The fourth return value is a structure OUTPUT with the fields,
‘funcCount’ containing the number of function calls to FUN,
‘iterations’ containing the number of iteration steps, ‘algorithm’
with the name of the search algorithm (always: "Nelder-Mead simplex
direct search"), and ‘message’ with the exit message.
Example:
fminsearch (@(x) (x(1)-5).^2+(x(2)-8).^4, [0;0])
See also: Note: fminbnd, Note: fminunc,
Note: optimset.
The function ‘humps’ is a useful function for testing zero and
extrema finding functions.
-- : Y = humps (X)
-- : [X, Y] = humps (X)
Evaluate a function with multiple minima, maxima, and zero
crossings.
The output Y is the evaluation of the rational function:
1200*X^4 - 2880*X^3 + 2036*X^2 - 348*X - 88
Y = - ---------------------------------------------
200*X^4 - 480*X^3 + 406*X^2 - 138*X + 17
X may be a scalar, vector or array. If X is omitted, the default
range [0:0.05:1] is used.
When called with two output arguments, [X, Y], X will contain the
input values, and Y will contain the output from ‘humps’.
Programming Notes: ‘humps’ has two local maxima located near X =
0.300 and 0.893, a local minimum near X = 0.637, and zeros near X =
-0.132 and 1.300. ‘humps’ is a useful function for testing
algorithms which find zeros or local minima and maxima.
Try ‘demo humps’ to see a plot of the ‘humps’ function.
See also: Note: fzero, Note: fminbnd, Note:
fminunc, Note: fminsearch.
automatically generated by info2www version 1.2.2.9