- If the problem has constraints, the F-count reports only the number of points where function evaluations took place, not the total number of evaluations of constraint functions. So, if the problem has many constraints, the F-count can be significantly less than the total number of function evaluations.
Function evaluations (F-count) in fmincon
14 views (last 30 days)
Show older comments
Chaitanya Awasthi
on 17 May 2021
Commented: Chaitanya Awasthi
on 20 May 2021
I have been doing some experiments to see how the number of function evaluations (F-count) change depending on the type of gradient information that is passed (objective gradient vs. constraint gradient). Here are the results of a test case (decision space: 60 variables) alongwith the time it took to converge to a solution (using tic-toc):
Case 1: No gradient info. is passed
F-count: 6451 Time: 71.03 secs
Case 2: Only objective gradient info. is passed
F-count: 6462 Time: 24.64 secs
Case 3: Only constraint gradient info. is passed
F-count: 6343 Time: 15.54 secs
I understand that F-count only reports the total number of objective function evaluations, regardless of the presence of constraint functions (Iterations and Function Counts). I also understand that because my constraints are fairly complex, providing constraint gradient info. results in more speedup than providing objective gradient info (Case 3 vs. Case 2). What I do not understand is why F-count is very similar in Cases 2 and 3? I was under the impression that Case 2 will have significantly lower F-count value since I am already providing objective gradient.
For reference, here is my options file:
options = optimoptions(@fmincon, 'ScaleProblem',true,'TolFun', 1.0e-06,'OptimalityTolerance',1.0e-06,'SpecifyObjectiveGradient',true,...
'SpecifyConstraintGradient',false,'checkgradients',false,'FiniteDifferenceType','central',...
'MaxIter', 10000,'MaxFunEvals', 300000,'Display','iter', ...
'StepTolerance',1.0e-6,'DiffMinChange', 1.0e-3, 'Algorithm', 'interior-point');
0 Comments
Accepted Answer
Alan Weiss
on 20 May 2021
In other words, unless you specify both constraint gradients and objective gradients, the F-count is going to be about the same. Any difference relates to the different number of iterations in different circumstances.If you specify both gradients, then no finite differencing takes place, and the F-count will be much smaller, almost equal to the iteration number.
Alan Weiss
MATLAB mathematical toolbox documentation
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!