What is first order optimality for fsolve?

8 visualizaciones (últimos 30 días)
Steven Rose
Steven Rose el 30 de Abr. de 2020
Respondida: Ameer Hamza el 1 de Mayo de 2020
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 comentarios
Ameer Hamza
Ameer Hamza el 30 de Abr. de 2020
Can you show how you have specified the function tolerance?
Steven Rose
Steven Rose el 30 de Abr. de 2020
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.

Iniciar sesión para comentar.

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 1 de Mayo de 2020
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

Más respuestas (0)

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by