set fmincon function tolerance

71 views (last 30 days)
AM
AM on 3 Dec 2018
Edited: AM on 4 Dec 2018
Hello,
I am using fmincon and I want to set the function tolerance and I thought that it meant that if |f(xi) – f(xi+1)| < TolFun the iterations stop. I thought here f was the objective function but is it actually the first order optimality measure?
I set my options as follows:
options = optimoptions(@fmincon,'Algorithm', 'sqp','Display','iter','OutputFcn',@outfun,'TolFun',1e-2);
options.FiniteDifferenceType='central';
options.AlwaysHonorConstraints='none';
And my results are
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the selected value of the optimality tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
Elapsed time is 62.872469 seconds.
Optimization completed: The relative first-order optimality measure, 4.994050e-03,
is less than options.OptimalityTolerance = 1.000000e-02, and the relative maximum constraint
violation, 0.000000e+00, is less than options.ConstraintTolerance = 1.000000e-06.
Optimization Metric Options
relative first-order optimality = 4.99e-03 OptimalityTolerance = 1e-02 (selected)
relative max(constraint violation) = 0.00e+00 ConstraintTolerance = 1e-06 (default)
I don't really understand what the first order optimality is (I know what it represents) so I would like to apply my tolerance to the value of the objective function, how can I do this?

Accepted Answer

Alan Weiss
Alan Weiss on 3 Dec 2018
If you check the fmincon options description you see the following for the OptimalityTolerance entry:
Termination tolerance on the first-order optimality, a positive scalar. The default is 1e-6. See First-Order Optimality Measure.
For optimset, the name is TolFun. See Current and Legacy Option Name Tables.
As you see, using TolFun does not set the function tolerance (despite the name), it sets the optimality tolerance. The FunctionTolerance option exists for the 'trust-region-reflective' algorithm and the 'active-set' algorithm, but not the 'sqp' algorithm.
The only way I know to achieve this stopping criterion with the 'sqp' algorithm is to write your own using an output function.
Alan Weiss
MATLAB mathematical toolbox documentation
  3 Comments
AM
AM on 4 Dec 2018
Edited: AM on 4 Dec 2018
It works, thank you!

Sign in to comment.

More Answers (0)

Products


Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!