How to use lsqnonlin with jacobian?
12 views (last 30 days)
Show older comments
I'm using the Optimization toolbox in order to solve a LS problem. I was using the fminunc solver, that gives me good results when I supply externally the gradient.
Recently I found the lsqnonlin solver, that seems to be more suitable for the problem I'm trying to solve.
However, when I use this solver with the pre-computer gradient, it gives me the same results as I'm not supplying it. In fact, even setting or not the "Jacobian" option to "on" or "off", I obtain always the same results that, even more, are exactly the same that I obtained with the fminunc solver when the "GradObj" option was set to "off".
This is the code (I'm omitting details about the fun):
options = optimoptions('lsqnonlin','Algorithm', 'levenberg-marquardt', 'Display','none','FinDiffType', 'central','Jacobian','on','tolFun',1e-20,'tolX',1e-20);
x = lsqnonlin(fun,k0,[],[],options);
Am I currently missing some options in this few lines or does it can depend on the function itself to which I'm applying the solver?
0 Comments
Answers (1)
Star Strider
on 14 Nov 2015
I am not certain what you are asking. The gradient-descent least squares solvers calculate a numeric Jacobian (using the finite-difference method) if you do not provide an analytical Jacobian function to them.
4 Comments
Star Strider
on 15 Nov 2015
The only way to know if it is using your analytic Jacobian is to insert a fprintf call in its code to tell you:
fprintf('Analytic Jacobian called\n')
However, it should use your analytic Jacobian if you tell it to.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!