0

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.

beatngu13
  • 7,201
  • 6
  • 37
  • 66
WoLfulus
  • 1,948
  • 1
  • 14
  • 21

2 Answers2

3

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.

brain
  • 5,496
  • 1
  • 26
  • 29
0

As all metaheuristics, genetic algorithms do not guarantee optimal solutions or provide any estimate of how good your solution is in comparison to the optimal solution. Therefore, I do not see a way to find the top N solutions using genetic algorithms.

  • The do compare solutions against each other though, so you can get the top N in the current population. – brain Oct 08 '14 at 08:04
  • If the top N solutions of the current population are what is wanted, then of course your approach is the way to go. –  Oct 08 '14 at 11:29