I've started to implement my own genetic algorithm and I'm at the stage of deciding how to select the parents for the new generation. I've done some reading and it seems there's a number of different ways to go about it.
I'm aware of the various selection techniques (tournament, roulette) but the information I can't seem to find is exactly how many parents should be selected.
The initial population size I'll be dealing with will be anywhere between 50-75 individuals. I was thinking of perhaps selecting half of the population for the next generation, so every generation the population decreases by exactly half, not sure if that's the best route to take though.
Any advice would be great.
I took a course in genetic algorithms as part of my master's degree study.
As @et_l correctly said, the population generally should be the same size each iteration, so it doesn't make sense that you want less and less solutions each generation (decreasing the population by half as you say). A population of 50-75 is also very small. I'd suggest to have at least a 100 solutions in your population.
How many parents to select is entirely up to you. You can select your whole population, or only a few. The number of parents usually only effects how quickly your population will converge to a single solution. Generally the less parents you select the more quickly you converge.
Now say (for example) you choose the top 10 solutions of your population of 100 as parents for your next generation. You kill off the other 90 of your population and keep the top 10. (Note that there are variations on how many you kill off too, this doesn't always need to be the part of your population that didn't get in the top and became a parent.)
Next you combine your 10 parents to create new solutions. There are many ways to combine. At this step it is important to get your population back to the intial size of your population, which is 100. You can choose to keep your 10 parents in your new generation, or kill them off too and have a population entirely made of 100 children combined of the 10 parents as opposed to a population of 10 parents + 90 children.
Optionally, you can now also perform some mutation on your new population to get a wider variety of solutions. Whether you do so is entirely up to you, and I would suggest to experiment with this to see what kind of effects this might have. If you choose to include mutation, usually only a small percentage of your population should mutate.
Finally you have your new population and you can start another iteration if you like. Keep doing iterations until you get solutions you are satisfied with in your population.
I hope I've made it clear there are many ways to implement a genetic algorithm, and it takes some experimentation to find out what implementation is best for your specific problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With