Search code examples
javaalgorithmgenetic-algorithmjenetics

Genetic Algorithm with Top N solutions


Basically I need to find the top N solutions of a genetic algorithm using Java (the solutions with the highest scores). I'm using the Jenetics library for the genetic algorithm, but I can't find how I'll be able to get those results without hacking the library's source code.

I can use another library if anyone knows a better one that has good documentation/examples.


Solution

  • You can get all the solutions by calling getPopulation() and then you can sort them by the fitness function by calling sort() and then just iterate through the first N solutions.