Fmincon seems to repeat a number of times the same set of variables

2 ビュー (過去 30 日間)
Robert Jones
Robert Jones 2022 年 7 月 14 日
コメント済み: Torsten 2022 年 7 月 14 日
Hello,
Fmincon seems to repeat a number of times the same set of variables.
Not sure why?
What am I missing?
Thanks

回答 (1 件)

Steven Lord
Steven Lord 2022 年 7 月 14 日
Do you mean that fmincon appears to evaluate your function at the same point multiple times?
If so, how have you checked that those points are actually identical? It's possible they are very slightly different, but that the change is small enough that it doesn't change how the number is displayed in the default format if that's how you're checking. In the example below a and b are displayed the same but their stored values are not the same.
a = pi
a = 3.1416
b = a + 1e-6
b = 3.1416
b == a % false
ans = logical
0
  2 件のコメント
Robert Jones
Robert Jones 2022 年 7 月 14 日
I see. I have displayed only 2 digits. I will extend to 6 digits
Thank you
Torsten
Torsten 2022 年 7 月 14 日
In a fixed point x0, fmincon has to calculate the gradient of your objective function and the Hessian numerically. This is done via finite-difference approximations:
df/dxi @ x=x0 ~ (f(x10,...,xi0+h,...,xn0) - f(x10,...,xi0,...,xn0))/h
So if you output x in your objective function with a limited number of digits, you might get the impression that
(x10,...,xi0+h,...,xn0) equals (x10,...,xi0,...,xn0).

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by