Fmincon does not even try other points other than initial x0

34 ビュー (過去 30 日間)
Conrado Neto
Conrado Neto 2020 年 6 月 10 日
コメント済み: Conrado Neto 2020 年 6 月 11 日
I am running into a problem I cannot understand,
I have an objective function that uses some external .exe programs to obtain its value, thus I believe a complex one
I ask matlab to provide the x values being used in the objective function at each iteration, and for some reason, fmincon always uses the exact same values of x0 several times, and then it says it found that the initial point is the local optimal.
wasn't fmincon supposed to try other values of x before getting to that final result? what could I be doing wrong?
  • I tried the same code using ga and it does try different x and gives different results at each iteration, for that reason I believe the code I used for fmincon should not have any basic mistake (such as the objective function being constant).
thanks,

採用された回答

Matt J
Matt J 2020 年 6 月 11 日
編集済み: Matt J 2020 年 6 月 11 日
wasn't fmincon supposed to try other values of x before getting to that final result?
No, fmincon is a gradient-based solver (unlike ga) so if x0 is feasible and the gradient there is already zero, then fmincon has no reason to try other points. Often this happens because you have discretization operations like round() or ceil() in your objective function, which make it locally flat almost everwhere. For example, this 1D function is locally flat at all points except the integers:
fun=@(x) floor(x);
opts=optimoptions('fmincon','Display','none');
fplot(fun,[0,5]); xlabel 'x', ylabel 'Objective'
and therefore almost any initial point you choose will be locally optimal,
>> fmincon(fun,1.5,[],[],[],[],0,5,[],opts)
ans =
1.5000
>> fmincon(fun,2.7,[],[],[],[],0,5,[],opts)
ans =
2.7000
>> fmincon(fun,3.99,[],[],[],[],0,5,[],opts)
ans =
3.9900
  4 件のコメント
Matt J
Matt J 2020 年 6 月 11 日
Yes, some people manage to address the problem by increasing the DiffMinChange parameter. That way, the finite differencing operations used to calculate gradients will take larger steps. However, I think it is better to trace the cause of the local plateaus in the objective function and remove them.
Conrado Neto
Conrado Neto 2020 年 6 月 11 日
Thanks again,
the problem is that due to the nature of the problem that I solving, a small change in x surely wont represent the actual change in the objective function. the change in the objective function would be a result of small "errors" in the calculation
in my analysis the change in x is only representative when it is significant.
so it does make sense to change the DiffMinChange parameter.
as a last question, do you happen to have any reference about solving a problem of this nature?

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

その他の回答 (1 件)

Alan Weiss
Alan Weiss 2020 年 6 月 11 日
The documentation has some suggestions about this type of thing.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 件のコメント
Conrado Neto
Conrado Neto 2020 年 6 月 11 日
Thanks Alan
this is very helpful

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by