"parents" is a matrix with size (n_individuals) x (number of parents per child)
So, e.g. two parents per child -> two columns.
So "parent" in line 15 is a random integer betweeen 1 and 2, and
so only population.ind{1} or population.ind{2} will be chosen if no crossover
happens.
I guess you meant to take the parents index, so it should be
15 parent = parents(i,randi(size(parents,2)));
Is that correct?
Kind regards,
Joe
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
hm, not much traffic here.
Anyway, I guess I found another bug concerning the non-crossover reproduction.
In reproduction.m if no crossover happens, the child is supposed to be a
a copy of a parent:
15 parent = randi(size(parents,2));
16 population.ind{i+settings.n_ind} = population.ind{parent};
"parents" is a matrix with size (n_individuals) x (number of parents per child)
So, e.g. two parents per child -> two columns.
So "parent" in line 15 is a random integer betweeen 1 and 2, and
so only population.ind{1} or population.ind{2} will be chosen if no crossover
happens.
I guess you meant to take the parents index, so it should be
15 parent = parents(i,randi(size(parents,2)));
Is that correct?
Kind regards,
Joe