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

Uniform Mutation trying to mutate genes outside of the chromossome array #124

Open JJ223 opened 3 months ago

JJ223 commented 3 months ago

I am using Genetic Sharp to generate the Best team of Drones for a mission. Each gene in my chromossome stores the amount of a specific type of drone. The algorithm works perfectly fine except sometimes when performing a Uniform mutation it will try to change a gene outside of the chromossome. How could this happen? Am I doing something wrong?

Here is my code:

JJ223 commented 3 months ago

Managed to fix it by changing the UniformMutation constructer from UniforMutation(true) to UniformMutation(mutableGenesIndexes) with the indexes of the chromossome.