MATLAB: Do I have the number of function evaluations growing with the number of iterations in patternsearch

optimizationpatternsearch

I'm using patternsearch to minimize the negative log likelihood.
I have 14 paramters parameters.
When I run the patternsearch, I realized that the number of function evaluations for each iteration was increasing as the iterations when on.
Here is the options that I used for the patternsearch:
options = optimoptions(@patternsearch, 'Display','iter','UseCompletePoll',true,'Cache','On')
[x,fval,exitflag,output] = patternsearch(myfun,myinit,[],[],[],[],[],[],mynonlcon,options)
where myinit is a 14 by 1 vector and myfun is the negative log likelihood.
Writing out the option in full:
options
ans =
  patternsearch options:
   Set properties:
                   Display: 'iter'
   Default properties:
            AccelerateMesh: 0
       ConstraintTolerance: 1.0000e-06
         FunctionTolerance: 1.0000e-06
    MaxFunctionEvaluations: '2000*numberOfVariables'
             MaxIterations: '100*numberOfVariables'
                   MaxTime: Inf
     MeshContractionFactor: 0.5000
       MeshExpansionFactor: 2
             MeshTolerance: 1.0000e-06
                   PlotFcn: []
                PollMethod: 'GPSPositiveBasis2N'
        PollOrderAlgorithm: 'consecutive'
                 ScaleMesh: 1
                 SearchFcn: []
             StepTolerance: 1.0000e-06
         UseCompleteSearch: 0
               UseParallel: 0
             UseVectorized: 0
The constaint that I'm using looks like this:
function [c, ceq] = mynonlcn(x)
A = reshape(x(6:9),[2,2]);
c = max(abs(eig(A)))-0.99999;
ceq = [];
end
This just makes sure that the 6~9th element of my parameters are a matrix with its elements within a unit circle.
Here, when I run the patternsearch, I get the results below. This shows that Func-count per iteration is way more than what the MATLAB documatation suggests (It should be 14*2 since I'm using GPSPositiveBasis2N):
Max
Iter Func-count f(x) Constraint MeshSize Method
0 1 -467.269 0 1
1 23 -467.269 0 0.009772 Update multipliers
2 190 -467.269 0 0.000955 Update multipliers
3 468 -467.269 0 9.333e-05 Update multipliers
4 830 -467.269 0 9.12e-06 Update multipliers
5 1276 -467.269 0 8.913e-07 Update multipliers
Optimization terminated: mesh size less than options.MeshTolerance
and constraint violation is less than options.ConstraintTolerance.
I'm not sure what is happening here. The problem gets more severe in my other applications using the same method. I get up to 28000 function evaluations (where the patternsearch stops due to exceeding MaxFunIter) while the number of iterations are only 5.
Could this be happening due to my constraint? Or is there something else at play here that I'm not aware of? Any help would be greatly appreciated.

Best Answer

The algorithm you are referring to is not used when there are nonlinear constraints