Failure in initial objective function evaluation. FMINUNC cannot continue.
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
I tried to evaluate this function but I am getting this error Failure in initial objective function evaluation.
FMINUNC cannot continue.
Please what is the best way to evaluate this function
f = x(2)^2*x(9)^2 + x(2)^2*x(9) + x(2)^3*x(9) - x(3)*x(5)*x(9)^2 + x(6)*x(8)*x(9)^2 + x(6)*x(8)*x(9)^3 + x(2)*x(6)*x(8)*x(9)^2;
採用された回答
Unless it is already in a function file, it needs to be an anonymous function:
f = @(x) x(2)^2*x(9)^2 + x(2)^2*x(9) + x(2)^3*x(9) - x(3)*x(5)*x(9)^2 + x(6)*x(8)*x(9)^2 + x(6)*x(8)*x(9)^3 + x(2)*x(6)*x(8)*x(9)^2;
If it is in a function file (and you have passed the function handle to fminunc correctly), the initial parameter estimates could be the problem. Please post those.
9 件のコメント
These are the code, am I doing anyhthing wrong? Sorry I am new to matlab
fun =@(x)x(2)^2*x(9)^2 + x(2)^2*x(9) + x(2)^3*x(9) - x(3)*x(5)*x(9)^2 + x(6)*x(8)*x(9)^2 + x(6)*x(8)*x(9)^3 + x(2)*x(6)*x(8)*x(9)^2;
x0 = [-.5, 0];
options = optimoptions('fminunc','Algorithm','quasi-newton');
options.Display = 'iter';
[x, fval, exitflag, output] = fminunc(fun,x0,options);
You have 9 parameters, so ‘x0’ must have 9 elements.
For example —
fun =@(x)x(2)^2*x(9)^2 + x(2)^2*x(9) + x(2)^3*x(9) - x(3)*x(5)*x(9)^2 + x(6)*x(8)*x(9)^2 + x(6)*x(8)*x(9)^3 + x(2)*x(6)*x(8)*x(9)^2;
x0 = rand(9,1);
options = optimoptions('fminunc','Algorithm','quasi-newton');
options.Display = 'iter';
[x, fval, exitflag, output] = fminunc(fun,x0,options);
This runs without error, however I doubt the result is what you want.
Thanks very much Sir, it runs but ends up with this problem. How do I solve it? Thanks once agian.
fminunc stopped because the objective function value is less than
or equal to the default value of the objective function limit.
That is not an error or a problem. It is simply a message from fminunc that it stopped, and the reason.
Meanwhile, consider changing your fminunc call to:
[x, fval, exitflag, output] = fminunc(@(x)norm(fun(x)), x0, options);
That may be the result you want.
Wow thank you Sir for your quick reply, it produced this line, is that a problem?
fminunc stopped because it cannot decrease the objective function
along the current search direction.
Mr Star strider, thank you very much. I have gotten the result I want.
As always, my pleasure!
It is not a probllem. Again, fminunc is simply telling you that it stopped, and the reason.
Mohammed Ouallal
2020 年 8 月 15 日
編集済み: Bruno Luong
2020 年 8 月 15 日
It seems that you resolve the problem but did not show how! please be kind and share the complete solution.
Thank you for the understanding!
Yes, I did!
‘Unless it is already in a function file, it needs to be an anonymous function’
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Solver Outputs and Iterative Display についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!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)
