Get Jacobian when using problem-based approach in Optimization Toolbox

4 vues (au cours des 30 derniers jours)
Philipp Glira
Philipp Glira le 19 Fév 2021
Commenté : Alan Weiss le 21 Fév 2021
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?

Réponse acceptée

Alan Weiss
Alan Weiss le 21 Fév 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 commentaires
Philipp Glira
Philipp Glira le 21 Fév 2021
Thank you.
I've tried to use the prob2struct. It works!
However, it seems that AD is used with solve(...), but not with lsqnonlin(...).
Here the output for solve(...)
Solving problem using lsqnonlin.
Norm of First-order
Iteration Func-count f(x) step optimality
0 1 3.47967 604
1 2 0.0755244 0.0178525 2.96
2 3 0.075441 8.92775e-05 7.32e-05
3 4 0.075441 2.21069e-09 9.17e-12
Optimization completed: The first-order optimality measure, 9.170276e-12,
is less than options.OptimalityTolerance = 1.000000e-06.
and here for lsqnonlin(...):
Norm of First-order
Iteration Func-count f(x) step optimality
0 3 3.47967 604
1 6 0.0755244 0.0178525 2.96
2 9 0.075441 8.92774e-05 7.32e-05
3 12 0.075441 2.5088e-09 5.66e-08
Optimization completed: The first-order optimality measure, 5.656498e-08,
is less than options.OptimalityTolerance = 1.000000e-06.
Is there any way to activate AD also in the lsqnonlin-Version?
I'm using the beta of Matlab 2021a.
Alan Weiss
Alan Weiss le 21 Fév 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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Systems of Nonlinear Equations dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by