What is the meaning of function count in the genetic algorithm in matlab optimization?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Emily Senay
el 12 de Jun. de 2015
Comentada: Emily Senay
el 15 de Jun. de 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 comentarios
Respuesta aceptada
Alan Weiss
el 12 de Jun. de 2015
Editada: Alan Weiss
el 12 de Jun. de 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 comentarios
Alan Weiss
el 15 de Jun. de 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
Más respuestas (0)
Ver también
Categorías
Más información sobre Genetic Algorithm en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!