Closed stephenll closed 4 years ago
The subs = rand(1:populationSize) and offspring[subs] = population[fitidx[i]] can easily overwrite the most elite with one that isn't the best.
You are right. That random index can point to a previously copied elite individual. Moreover, it overwrites some of the newly generated offspring which is the waist.
When I wrote my own GA in the past for a company I was working for, I made sure the new generation was nElite = ceil(elitepctnPopulation), nCrossOver = round(crossPct(nPopulation - nElite)), nMutate = nPopulation - nElite - nCrossOver. I am just learning Julia or I would try to help more.
nMutate = nPopulation - nElite - nCrossOver
So, you never applied mutation to the crossover offspring. Why?
Caveat: I don't have formal training in Genetic Algorithms. I feel that applying a mutation to a crossover is applying changes twice and goes against what a GA is fundamentally laying out. Some of the population is going to be from the elite group, another portion is going to be from the crossover of select parents, and some are going to be from the mutation of the parents. Mutating a crossover seemed overkill. Restricting the number of elite moving forward and a form of scaling for the parent selection can make for a better diverse population.
I couldn't find clear answer as well, but giving small joint probability of simultaneous crossover and mutation operations, applying both to the offspring should not be a problem.
I dug around a little.
Per David Goldberg’s book: Genetic Algorithms in Search, Optimization and Machine Learning, the mutation is supposed to protect from the crossover function losing important information or being "overzealous.”
Based on that, I would say that the mutation should be based off the parent and not a crossover.
I am going to continue reading the book and see what else I can learn.
Digging around more the examples in the book indicate that crossovers do mutate. I guess that makes sense if the rate of mutation is very low.
On Mar 23, 2020, at 2:10 PM, Art notifications@github.com wrote:
I couldn't find clear answer as well, but giving small joint probability of simultaneous crossover and mutation operations, applying both to the offspring should not be a problem.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wildart/Evolutionary.jl/issues/44#issuecomment-602768386, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWM7NJFD2O6AT476QRKS5TRI6QZJANCNFSM4LLJ4KQQ.
I would think that when setting up the GA with a setting utilizing
elite
the best fit in each population should be guaranteed to survive. It seems it is possible to overwrite for example the best fit with one that isn't.I would expect that if we are selection a certain percentage or number of elite to move to the next population that the
best
n of them would be available.I have seen in multiple runs where I have an initial population that contains the best known to date, I will see the
best
in a population be actually worse than thebest
I set in the initial population.I can trace the problem in ga.jl to the code below. The
subs = rand(1:populationSize
andoffspring[subs] = population[fitidx[i]]
can easily overwrite the most elite with one that isn't thebest
.I had a run where the best of a population was in location 10, then was assigned to position 19 in
offspring
, then another elite that wasn't as good as the best, was assigned over that location of 19. Now the best in the population doesn't move forward.