What is the meaning of function count in the genetic algorithm in matlab optimization?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Emily Senay
il 12 Giu 2015
Commentato: Emily Senay
il 15 Giu 2015
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
0 Commenti
Risposta accettata
Alan Weiss
il 12 Giu 2015
Modificato: Alan Weiss
il 12 Giu 2015
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 Commenti
Alan Weiss
il 15 Giu 2015
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
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Genetic Algorithm in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!