Function evaluations (F-count) in fmincon

조회 수: 31 (최근 30일)
Chaitanya Awasthi
Chaitanya Awasthi 2021년 5월 17일
댓글: Chaitanya Awasthi 2021년 5월 20일
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');

채택된 답변

Alan Weiss
Alan Weiss 2021년 5월 20일
Please see the documentation on Iterations and Function Counds. To quote the relevant paragraph:
  • 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.
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
  댓글 수: 1
Chaitanya Awasthi
Chaitanya Awasthi 2021년 5월 20일
Hi Alan,
Thank you for your response. I had already gone through the link that you quoted, however, I guess I was still a little confused with the wording. I think I get it now.
When the quoted paragrah said "...the F-count reports only the number of points where function evaluations took place, not the total number of evaluations of constraint functions... " for some reason I thought it was talking about objective function evaluations only.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by