MATLAB: Fmincon minimum number of iterations

fminconMATLABoptimizationOptimization Toolbox

Are there any way to set minimum number of iterations in fmincon.
I don't want to stop algorithm when
options.OptimalityTolerance = 0,
options.ConstraintTolerance = 0, and
options.StepTolerance = 0.
I want fmincon to stop at the desired iterations for comparing with other algorithms.

Best Answer

This shows how you can force fmincon to keep searching until a fixed number of iterations is reached. It uses a simple objective function, but fmincon still run to 1000 iterations.
opts = optimoptions('fmincon', ...
'OptimalityTolerance', 0, ...
'StepTolerance', 0, ...
'MaxFunctionEvaluations', inf,...
'MaxIterations', 1000);
[X,f,~,out] = fmincon(@(x) x.^2, 1, [], [], [], [], [], [], [], opts);