Fitness function run twice / stopping a GA
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello.
I have currently two problem with my GA code. My elements are defined by 4 value, and each time my fitness function is called, I display the values. What I get is :
-0.1827 0.2077 -0.0817 0.0275
-0.1827 0.2077 -0.0817 0.0275
0.8208 -0.6566 0.1232 0.0194
-0.8640 0.7799 -0.1599 0.0242
As you can see, the first element is plotted twice,meaning the fitness function is called twice with that element. But if I look at the population, it is not in it.
Here is my "run" code :
clear all
ObjectiveFunction = @fitnescalc;
nvars = 4; % Number of variables
ConstraintFunction = @constraint;
CreationFcn=@populationInit;
IP=[populationInit()]
for i=1:2
IP = [IP;populationInit()]; % Population MAtrix goes here
end
options = optimoptions('ga','InitialPopulationMatrix',IP,'OutputFcn',@gaoutfun,'PopulationSize',length(IP(:,1)));
[x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],[],[], ...
ConstraintFunction,options);
Do you see where it could come from ? Thank you
2 comentarios
Geoff Hayes
el 23 de Mayo de 2018
Boris - what does populationInit() do? i.e. what is the code for this function? Does it return a single element or multiple ones? It looks like you initialize IP as
IP=[populationInit()]
and then update it twice with two calls to this same function so how large is your initial population?
Please copy and paste the code for populationInit to your question.
Boris Huljak
el 23 de Mayo de 2018
Editada: Boris Huljak
el 23 de Mayo de 2018
Respuestas (0)
Ver también
Categorías
Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!