What is first order optimality for fsolve?
6 ビュー (過去 30 日間)
古いコメントを表示
Apologies for what is a very basic question, but when running fsolve, it terminates later than I expect because while the function tolerance I have used is satisfied, it seems to want to keep working to get the first-order optimality as small as it can. I'm not really sure what first-order optimality is in the context of solving a non-linear system though - there's no reason to expect the gradient of the function to go to zero at the zero of the function and no reason to care about it in any case. What am I misunderstanding?
2 件のコメント
採用された回答
Ameer Hamza
2020 年 5 月 1 日
The documentation defines function tolerance as the difference between the function values in two consecutive iterations. So there is no direct way to specify the tolerance for the function value itself. The only way I found is to use the outputFcn property of the optimoptions. The fsolve() runs this function at the end of each iteration, and we can signal fsolve() when to stop its iteration. See the following example. I used an example objective function to illustrate the idea
options = optimoptions('fsolve','OutputFcn',@outFcn,'Display','iter');
finalomega = fsolve(@(x) sum(norm(x-3).*exp(x-2.5)),rand(1,4),options);
function stop = outFcn(x,optimValues,state)
if optimValues.fval < 1e-6
stop = 1;
else
stop = 0;
end
end
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
