set fmincon function tolerance
39 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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?
0 Commenti
Risposta accettata
Alan Weiss
il 3 Dic 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 Commenti
Alan Weiss
il 4 Dic 2018
You need to either run the example as written as a nested function so that history is available, or follow the ideas in this example and use persistent history (note that the ga output function uses a different syntax, I just wanted to point you to how to do it using persistent variables).
Alan Weiss
MATLAB mathematical toolbox documentation
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!