What is the difference between flag 1 and flag 2?

17 vues (au cours des 30 derniers jours)
Deepshikha Acharya
Deepshikha Acharya le 29 Oct 2020
Hi,
I am using the interior-point (default) method to minimize my optimization function using fmincon. I am a little confused about which flag truly represents "solution found". Especially confused about the difference in a flag 2 and a flag 1 answer.
Thanks for the help :)

Réponse acceptée

Walter Roberson
Walter Roberson le 30 Oct 2020
Exit flag 1: stopped because the optimality was low enough, and the constraints are not too badly violated
Exit flag 2: stopped because the step size was low enough, and the constraints are not too badly violated
fmincon does not know how small the function value can get, or how "bumpy" the surface is (the more bumpy a surface is, the more likely you got stuck in a local minimum that is not the best available in the area.) So fmincon has algorithms to guess how well it is doing on the optimization, with it creating a statistic that it calls "first-order optimality". It measures factors such as relative change in function values. It does not try to find the absolute best it can find in the area: it stops when it figures that the change is "not very much" -- because a lot of time, getting the absolute best possible value is a waste of time (and not justified by the accuracy of the inputs.) When it stops because it figures it has done a "good enough" job, the exit flag is 1.
But sometimes it can think there is still room for improvement, but it has reached the limit of how small of a step that has been configured to take. When it stops for this reason, the exit flag is 2.
Imagine two functions that have the same minimum, but in one case the function is broad and locally shallow: then it might be time to give up with exit flag 1 "because this is getting boring, not much is changing." Compare to a function that is locally steep by comparison, where fmincon is stopping because you asked it not to bother with changing the positions by too little, the exit flag 2 case.
  1 commentaire
Deepshikha Acharya
Deepshikha Acharya le 30 Oct 2020
Thanks for the easy explanation!
This helps a lot!!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by