Documentation Center |
On this page… |
---|
You can specify optimization parameters using an options structure that you create using the optimset function. You then pass options as an input to the optimization function, for example, by calling fminbnd with the syntax
x = fminbnd(fun,x1,x2,options)
or fminsearch with the syntax
x = fminsearch(fun,x0,options)
For example, to display output from the algorithm at each iteration, set the Display option to 'iter':
options = optimset('Display','iter');
Option | Description | Solvers |
---|---|---|
A flag indicating whether intermediate steps appear on the screen.
| fminbnd, fminsearch, fzero, lsqnonneg | |
FunValCheck | Check whether objective function values are valid.
| fminbnd, fminsearch, fzero |
The maximum number of function evaluations allowed. The default value is 500 for fminbnd and 200*length(x0) for fminsearch. | fminbnd, fminsearch | |
The maximum number of iterations allowed. The default value is 500 for fminbnd and 200*length(x0) for fminsearch. | fminbnd, fminsearch | |
OutputFcn | Display information on the iterations of the solver. The default is [] (none). See Output Functions. | fminbnd, fminsearch, fzero |
PlotFcns | Plot information on the iterations of the solver. The default is [] (none). For available predefined functions, see Plot Functions. | fminbnd, fminsearch, fzero |
The termination tolerance for the function value. The default value is 1.e-4. See Tolerances and Stopping Criteria. | fminsearch | |
The termination tolerance for x. The default value is 1.e-4. See Tolerances and Stopping Criteria. | fminbnd, fminsearch, fzero, lsqnonneg |
The number of iterations in an optimization depends on a solver's stopping criteria. These criteria include several tolerances you can set. Generally, a tolerance is a threshold which, if crossed, stops the iterations of a solver.
Tip Generally, set the TolFun and TolX tolerances to well above eps, and usually above 1e-14. Setting small tolerances doesn't guarantee accurate results. Instead, a solver can fail to recognize when it has converged, and can continue futile iterations. A tolerance value smaller than eps effectively disables that stopping condition. |
TolX is a lower bound on the size of a step, meaning the norm of (x_{i} – x_{i+1}). If the solver attempts to take a step that is smaller than TolX, the iterations end. Solvers sometimes use TolX as a relative bound, meaning iterations end when |(x_{i} – x_{i+1})| < TolX*(1 + |x_{i}|), or a similar relative measure.
TolFun is a lower bound on the change in the value of the objective function during a step. If |f(x_{i}) – f(x_{i+1})| < TolFun, the iterations end. Solvers sometimes use TolFun as a relative bound, meaning iterations end when |f(x_{i}) – f(x_{i+1})| < TolFun(1 + |f(x_{i})|), or a similar relative measure.
MaxIter is a bound on the number of solver iterations. MaxFunEvals is a bound on the number of function evaluations.
The output structure includes the number of function evaluations, the number of iterations, and the algorithm. The structure appears when you provide fminbnd or fminsearch with a fourth output argument, as in
[x,fval,exitflag,output] = fminbnd(@humps,0.3,1);
or
[x,fval,exitflag,output] = fminsearch(@three_var,v);
The output structure is not an option that you choose with optimset. It is an optional output for fminbnd and fminsearch.