How to replace my optimset with equivalent optimoptions ?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi all
using Fsolve, I am getting into difficulties and want to use Jacobian and Hessian as well , but first I need to pass from optimset to optimoptions
currently my Options are :
options = optimset('Display','iter','MaxFunEvals',1e6,'MaxIter',1e6,'TolFun',1e-3,'DerivativeCheck','on','Diagnostics','on');
so first, I need to have the equivalent optimoptions and then include Jacobian and Hessian.
since for some of my input data no solution is found ( Func-Count = 1.5e+7 ) , I need to imrpove my solution
採用された回答
Why not just,
options = optimoptions(@fsolve, 'Display','iter','MaxFunEvals',1e6,'MaxIter',1e6,...
'TolFun',1e-3,'DerivativeCheck','on','Diagnostics','on');
22 件のコメント
thank you
what about Hessian and Jacob ?
For the Jacobian, set 'SpecifyObjectiveGradient' to true, and follow instructions and examples here,
thank you
this is suggested in the page :
options = optimoptions('fsolve','SpecifyObjectiveGradient','on')
I get
Error: Invalid value for OPTIONS parameter SpecifyObjectiveGradient: must be logical TRUE or FALSE.
options = optimoptions(@fsolve,'SpecifyObjectiveGradient',true)
That is a documentation error. You should set to true.
that is as you said, the problem is that Matlab does not accept 'on' for Jacobian
Now I did :
options = optimoptions(@fsolve,'Display','iter','MaxFunEvals',1e6,'MaxIter',1e6,'TolFun',1e-3,'DerivativeCheck','on','Diagnostics','on', 'SpecifyObjectiveGradient',true);
but now I get the error :
too many output arguments ! is the definition right ? and how to ask for more output arguments ?
Without code and the full error message, the problem is undiagnosable. However, I suspect you forgot to provide the Jacobian computation in your objective function code.
@farzad:
Did you ask for the number of output arguments in your code ?
https://de.mathworks.com/help/optim/ug/nonlinear-equations-with-jacobian.html
I can't share my full code. I hope this way I resolve it..
I have a bit of diffulty in using your link @Torsten , since I have defined my function in another m file and I call the
[x,fval,exitflag,output] = fsolve(fun,xstart,options);
in my main file. So based on this tutorial you shared, I should add thos Jacobian calc lines in the function definition m file ?
Of course, where else ?
And with the if statement about the number of output arguments.
I didn't understand your last phrase
Look at the function file provided in the link:
if nargout > 1
Supply Jacobian
end
jacobian(f,x) is a Symbolic Math Toolbox function. It only takes symbolic variables f and x as input and only returns symbolic results. And it is slow.
Thank you, but from the link you shared, I could not learn how to calculate my own function's Jacobian. Where did that 4 coefficient come from in the jacobian when all the main function coeffs are 3.
From the
terms.
Still not clear
I don't understand the C ,D and E matrix size selection , also in c ,d, and e
How about the following ?
[diff(f1,x), diff(f1, y); diff(f2, x), diff(f2, y)]
No, diff(f1,x) is also a symbolic function. It is probably better for you to use the fundamental definition of the Jacobian,
to compute the Jacobian for your specific function.
Are you Sure diff is symbolic ?
and why can't I use symbolic ? shall you help me understand ?
Do you understand the difference between symbolic and numeric computation? In symbolic computation, you present the expression for a function, and the software tries to take its derivatives analytically, as you or I would in a calculus course. The result is an analytical expression for the derivative, not a number.
But fsolve is a numeric solver. It puts in numbers for x and expects your code to give back numbers for the resulting Jacobian(x). On top of that, it does this repeatedly with different x, in its search for a solution. For the sake of speed, therefore, you don't want your code redoing the calculus to get expressions for the Jacobian every time it is called.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Calculus についてさらに検索
参考
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
