MATLAB: Is fmincon ending in points it knows are sub-optimal

fminconoptimization

So I'm running fmincon on some complex function.
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 6 1.264764e+04 0.000e+00 6.529e+09
1 13 -3.111363e+04 0.000e+00 1.043e+10 1.485e+01
2 19 -3.413651e+04 0.000e+00 7.615e+09 8.769e+03
3 25 -3.861130e+04 0.000e+00 1.613e+09 6.264e+02
4 34 -3.840241e+04 0.000e+00 1.376e+09 9.530e-03
5 41 -3.843143e+04 0.000e+00 5.582e+09 9.954e-01
I get this and it ends there at Iteration 5, returning the parameter values of that iteration and calling it an optimum. However, clearly, iteration 3 had found a superior feasable solution.
Any clue as to why this is happening? And how to stop that? The program that ultimately calls on fmincon is a complex code written by someone else, that I don't understand fully. Could he have put some option to stop fmincon from returning the values at iteration 3 instead of the ones at the last iteration?

Best Answer

It appears that the first-order optimality measure is nowhere near zero, so I am sure that fmincon does not claim that it reached a minimum. It probably stopped because the norm of the step was too small, meaning it could not proceed. For suggestions on what to do in this case, see Local Minimum Possible.
Alan Weiss
MATLAB mathematical toolbox documentation