フィルターのクリア

What is the meaning of function count in the genetic algorithm in matlab optimization?

5 ビュー (過去 30 日間)
Where is the function count coming from? Why does it not increase the same amount between generations?
Function:
function y = fitness(x)
a=1;
b=1;
c=1;
y =sin(a*x(1)^2+b*x(2)+c);
Constraint Function:
function [c, ceq] = constraint(x)
c = [];
ceq = [];
Optimization Code:
ObjectiveFunction = @fitness;
nvars = 2; % Number of variables
LB = [,]; % Lower bound
UB = [,]; % Upper bound
ConstraintFunction = @constraint;
for i=1:5
options = gaoptimset('MutationFcn',{@mutationuniform, .01}, 'Display','iter',...
'Generations',100,'FitnessLimit', -.9999,...
'PopulationSize',127);
[x,fval,exitflag, output] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,...
ConstraintFunction,[],options)
%record = [record; fval];
z(i)=output.generations
k(i)=output.funccount
end

採用された回答

Alan Weiss
Alan Weiss 2015 年 6 月 12 日
編集済み: Alan Weiss 2015 年 6 月 12 日
When you use a nonlinear constraint in ga, the solution algorithm is different than without the nonlinear constraint. See nonlinear constraint solver. In particular, note the paragraph:
Each subproblem solution represents one generation.
The number of function evaluations per generation is
therefore much higher when using nonlinear constraints
than otherwise.
Even though your constraint function is not calculating anything, the fact that you have a nonlinear constraint function means that ga uses the nonlinear constraint solver. If you really don't have a nonlinear constraint, set the ConstraintFunction argument to [].
Alan Weiss
MATLAB mathematical toolbox documentation
  3 件のコメント
Alan Weiss
Alan Weiss 2015 年 6 月 15 日
No, you misunderstand how the nonlinear constraint solver works. Read the link that I gave. There can be many iterations in each subproblem solution, so the number of function evaluations can be large.
Alan Weiss
MATLAB mathematical toolbox documentation
Emily Senay
Emily Senay 2015 年 6 月 15 日
I see now. So if I get rid of the nonlinear constraint shouldn't what I stated above be true..that the function count should equal or be less than the number of generations multiplied by the population size?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by