Optimization Toolbox Previous page   Next Page
fminsearch

Find a minimum of an unconstrained multivariable function

where x is a vector and f(x) is a function that returns a scalar.

Syntax

Description

fminsearch finds a minimum of a scalar function of several variables, starting at an initial estimate. This is generally referred to as unconstrained nonlinear optimization.

x = fminsearch(fun,x0) starts at the point x0 and finds a local minimum x of the function described in fun. x0 can be a scalar, vector, or matrix.

x = fminsearch(fun,x0,options) minimizes with the optimization parameters specified in the structure options. Use optimset to set these parameters.

x = fminsearch(fun,x0,options,P1,P2,...) passes the problem-dependent parameters P1, P2, etc. directly to the function fun. Use options = [] as a placeholder if no options are set.

[x,fval] = fminsearch(...) returns in fval the value of the objective function fun at the solution x.

[x,fval,exitflag] = fminsearch(...) returns a value exitflag that describes the exit condition of fminsearch.

[x,fval,exitflag,output] = fminsearch(...) returns a structure output that contains information about the optimization.

Input Arguments

Function Arguments contains general descriptions of arguments passed in to fminsearch. This section provides function-specific details for fun and options:

fun
The function to be minimized. fun is a function that accepts a vector x and returns a scalar f, the objective function evaluated at x. The function fun can be specified as a function handle.
  • x = fminsearch(@myfun,x0,A,b)
    
where myfun is a MATLAB function such as
  • function f = myfun(x)
    f = ...            % Compute function value at x
    
fun can also be an inline object.
  • x = fminsearch(inline('norm(x)^2'),x0,A,b);
    

options
Options provides the function-specific details for the options parameters.

Output Arguments

Function Arguments contains general descriptions of arguments returned by fminsearch. This section provides function-specific details for exitflag and output:

exitflag
Describes the exit condition:

> 0
The function converged to a solution x.

0
The maximum number of function evaluations or iterations was exceeded.

< 0
The function did not converge to a solution.
output
Structure containing information about the optimization. The fields of the structure are

iterations
Number of iterations taken

funcCount
Number of function evaluations

algorithm
Algorithm used

Options

Optimization options parameters used by fminsearch. You can use optimset to set or change the values of these fields in the parameters structure options. See Optimization Parameters, for detailed information:

Display
Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final' displays just the final output; 'notify' (default) displays output only if the function does not converge.
MaxFunEvals
Maximum number of function evaluations allowed.
MaxIter
Maximum number of iterations allowed.
OutputFcn
Specify a user-defined function that an opimization function calls at each iteration. See Output Function.
TolFun
Termination tolerance on the function value.
TolX
Termination tolerance on x.

Examples

Minimize the one-dimensional function f(x) = sin(x) + 3.

To use an M-file, i.e., fun = 'myfun', create a file myfun.m.

Then call fminsearch to find a minimum of fun near 2.

To minimize the function f(x) = sin(x) + 3 using an inline object:

Algorithms

fminsearch uses the simplex search method of [1]. This is a direct search method that does not use numerical or analytic gradients as in fminunc.

If n is the length of x, a simplex in n-dimensional space is characterized by the n+1 distinct vectors that are its vertices. In two-space, a simplex is a triangle; in three-space, it is a pyramid. At each step of the search, a new point in or near the current simplex is generated. The function value at the new point is compared with the function's values at the vertices of the simplex and, usually, one of the vertices is replaced by the new point, giving a new simplex. This step is repeated until the diameter of the simplex is less than the specified tolerance.

fminsearch is generally less efficient than fminunc for problems of order greater than two. However, when the problem is highly discontinuous, fminsearch might be more robust.

Limitations

fminsearch can often handle discontinuity, particularly if it does not occur near the solution. fminsearch might only give local solutions.

fminsearch only minimizes over the real numbers, that is, x must only consist of real numbers and f(x) must only return real numbers. When x has complex variables, they must be split into real and imaginary parts.

See Also

@ (function_handle), fminbnd, fminunc, inline, optimset

References

[1]  Lagarias, J.C., J. A. Reeds, M. H. Wright, and P. E. Wright, "Convergence Properties of the Nelder-Mead Simplex Method in Low Dimensions," SIAM Journal of Optimization, Vol. 9, Number 1, pp.112-147, 1998.


Previous page  fminimax fminunc Next page

Learn more about the latest releases of MathWorks products:

 © 1994-2009 The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS