Problem using FSOLVE 'OptimalityTolerance' is not an option

7 views (last 30 days)
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.

Accepted Answer

Alan Weiss
Alan Weiss on 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

More Answers (0)

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!