Get Jacobian when using problem-based approach in Optimization Toolbox
4 views (last 30 days)
Show older comments
When using lsqnonlin to solve a least squares problem, the jacobian gets returned as last argument:
[x,resnorm,residual,exitflag,output,lambda,jacobian] = lsqnonlin(___)
However, when using the problem-based approach, the jacobian isn't returned:
[sol,fval,exitflag,output,lambda] = solve(___)
Is there any way to get the jacobian also in this case?
0 Comments
Accepted Answer
Alan Weiss
on 21 Feb 2021
Unfortunately, you cannot get the Jacobian output when using the problem-based approach. If you need it, then convert your problem using prob2struct and sove using lsqnonlin.
Alan Weiss
MATLAB mathematical toolbox documentation
2 Comments
Alan Weiss
on 21 Feb 2021
You are quite right, AD does not apply to the lsqnonlin version. The only thing that I can think to try sounds terrible: run using solve first, then feed that solution as a starting point into lsqnonlin in order to get a Jacobian estimate.
By the way, if you are showing me results from your real problem, then the first-order optimality output shows that the Jacobian is either zero or you have some bound constraints.
Alan Weiss
MATLAB mathematical toolbox documentation
More Answers (0)
See Also
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!