Get Jacobian when using problem-based approach in Optimization Toolbox

조회 수: 1 (최근 30일)
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?

채택된 답변

Alan Weiss
Alan Weiss 2021년 2월 21일
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
Philipp Glira
Philipp Glira 2021년 2월 21일
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 2021년 2월 21일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by