Set Optimization Options
How to Set Options
You can specify optimization parameters using an
that you create using the
You then pass
options as an input to the optimization
function, for example, by calling
x = fminbnd(fun,x1,x2,options)
fminsearch with the syntax
x = fminsearch(fun,x0,options)
For example, to display output from the algorithm at each iteration,
Display option to
options = optimset('Display','iter');
A flag indicating whether intermediate steps appear on the screen.
Check whether objective function values are valid.
The maximum number of function evaluations allowed. The
default value is
The maximum number of iterations allowed. The default
Display information on the iterations of the solver.
The default is
Plot information on the iterations of the solver. The
The termination tolerance for the function value. The
default value is
The termination tolerance for x. The default value is
Tolerances and Stopping Criteria
The number of iterations in an optimization depends on the stopping criteria for the solver. These criteria include several tolerances you can set. Generally, a tolerance is a threshold which, if crossed, stops the iterations of a solver.
Generally, set the
TolX tolerances to well
eps, and usually above
Setting small tolerances does not 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. This tip does not apply to
uses a default value of
TolXis a lower bound on the size of a step, meaning the norm of (xi – xi+1). If the solver attempts to take a step that is smaller than
TolX, the iterations end. Solvers generally use
TolXas a relative bound, meaning iterations end when |(xi – xi+1)| <
TolX*(1 + |xi|), or a similar relative measure.
TolFunis a lower bound on the change in the value of the objective function during a step. If |f(xi) – f(xi+1)| <
TolFun, the iterations end. Solvers generally use
TolFunas a relative bound, meaning iterations end when |f(xi) – f(xi+1)| <
TolFun(1 + |f(xi)|), or a similar relative measure.
MaxIteris a bound on the number of solver iterations.
MaxFunEvalsis a bound on the number of function evaluations.
Unlike other solvers,
when it satisfies both
output structure includes the number
of function evaluations, the number of iterations, and the algorithm.
The structure appears when you provide
a fourth output argument, as in
[x,fval,exitflag,output] = fminbnd(@humps,0.3,1);
The details of the
output structure for each
solver are on the function reference pages.
output structure is not an option that
you choose with
optimset. It is an optional output