Problem using FSOLVE 'OptimalityTolerance' is not an option
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Javier Mora Torres
am 31 Okt. 2020
Beantwortet: Alan Weiss
am 2 Nov. 2020
Hi
I'm trying to do Nonlinear regression with Levenberg Marquardt, but I have this problem.
Error using optimoptions (line 105)
'OptimalityTolerance' is not an option for FSOLVE.
A list of options can be found on the FSOLVE documentation page.
Error in Transfer_function_corrected (line 116)
options =
optimoptions(@fsolve,'TolFun',1e-54,'Algorithm','levenberg-marquardt','MaxIter',1e16,'Display','off','TolFun',1e-12,'OptimalityTolerance',1e-12);
My code..
[l,a]=size(H);
for y=1:a
for z=1:l
myfun = @(x) [((H(z,y)-(D(y)*exp(-1i*x(1)*(r(y+1)-r(1))))))^2];
options = optimoptions(@fsolve,'TolFun',1e-54,'Algorithm','levenberg-marquardt','MaxIter',1e16,'Display','off','TolFun',1e-12,'OptimalityTolerance',1e-12);
[K(z,y),fval(z,y)] = fsolve(myfun, [0],options);
c=c+1;
waitbar(c/n)
end
end
Thank you so much.
0 Kommentare
Akzeptierte Antwort
Alan Weiss
am 2 Nov. 2020
I am surprised that you got that error, but here is what the fsolve documentation has to say about that option:
Internally, the 'levenberg-marquardt' algorithm uses an optimality tolerance (stopping criterion) of 1e-4 times FunctionTolerance and does not use OptimalityTolerance.
I would also like to point out that many of your chosen options and tolerances do not make sense. To quote from that link: Generally set tolerances such as OptimalityTolerance and StepTolerance to be well above eps, and usually above 1e-14. Setting small tolerances does not always result in accurate results. Instead, a solver can fail to recognize when it has converged, and can continue futile iterations. A tolerance value smaller than eps effectively disables that stopping condition.
Alan Weiss
MATLAB mathematical toolbox documentation
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surrogate Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!