What is first order optimality for fsolve?

6 ビュー (過去 30 日間)
Steven Rose
Steven Rose 2020 年 4 月 30 日
回答済み: Ameer Hamza 2020 年 5 月 1 日
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
Ameer Hamza 2020 年 4 月 30 日
Can you show how you have specified the function tolerance?
Steven Rose
Steven Rose 2020 年 4 月 30 日
Sure thing.
function ret = solvesystemreal(data,changes)
N = data.N; J = data.J;
objective = @(o) systemRHSreal(data,changes,o) - o;
init = ones(N,1);
options = optimoptions('fsolve','TolFun',1e-6,'Display','iter');
finalomega = fsolve(objective,init,options);
ret.omegahat = finalomega;
The kind of output I'm getting is shown below - I'm just not sure why it reports first-order optimality at all? I don't really care that it's taking a bit longer than I'd like (it's taking a while on my laptop but once I'm convinced everything's working I'm just sending it to my uni's supercomputer anyway) - it's just clear I have some lack of understanding about fsolve.

サインインしてコメントする。

採用された回答

Ameer Hamza
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 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by