The problem is in your crossover function. It looks like you're implementing RWS just fine. Tournament seleciton or truncation selection is better.Įdit: > The selection pressure decreases when the fitness values converges.Ī has a 50% chance to be selected but B and C only 25%.Īfter some generations you have: f(A) = 100, f(B)=95, f(C)=95.Ī, B anc C now almost have the same probabilty to be selected.
The selection pressure decreases when the fitness values converges. You are using a list of probabilties not a list of intervals.Īditional note: a routlette wheel selection is one of the worst selections possible for genetic algorihms.
I briefly looked at your code and I don't know python.īut I guess this part of your code is wrong: select new individuals while the population is not full while(len(newPopulation) j.getProb():