giacomelli / GeneticSharp

GeneticSharp is a fast, extensible, multi-platform and multithreading C# Genetic Algorithm library that simplifies the development of applications using Genetic Algorithms (GAs).
MIT License
1.26k stars 330 forks source link

Multiple occurances of same chromosome instance in generation #92

Closed NesCafe62 closed 1 year ago

NesCafe62 commented 3 years ago

Because RankSelection, RouletteWheelSelection and TournamentSelection can produce a generation where multiple instances of same chromosome occures it might result in mutation will affect all occurances of that chromosome.

Possible solutions:

  1. use Clone method of IChromosome inside these selections
  2. before saving chromosmes into new generation create new collection that comtains their copies, using Clone method
  3. make mutations produce new chromosome instead of modifying current one (might better for perfromance compare to 1 and 2)

p.s. I'v not tested if it actually happens, only read the code (I'm working on a project that has similar stuff). I searched for all places where Clone method is called and did not found any usages that can solve this potential issue.