Get Jacobian when using problem-based approach in Optimization Toolbox

1 回表示 (過去 30 日間)
Philipp Glira
Philipp Glira 2021 年 2 月 19 日
コメント済み: Alan Weiss 2021 年 2 月 21 日
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 Center および File ExchangeProblem-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