Skip to content

Instantly share code, notes, and snippets.

@jfinkels
Created January 13, 2010 21:17
Show Gist options
  • Save jfinkels/276582 to your computer and use it in GitHub Desktop.
Save jfinkels/276582 to your computer and use it in GitHub Desktop.
List<MyIndividual> initialPopulation = new Vector<MyIndividual>();
// add the initial individuals to the population
//
// ...
//
EvolutionContext<MyIndividual> context = new GAEvolutionContext<MyIndividual>(initialPopulation);
// set the necessary properties on the EvolutionContext
//
// ...
//
CompletionCondition<MyIndividual> condition = new MaxGenerationCompletionCondition<MyIndividual>();
condition.setMaxGenerations(10);
try {
while (!condition.execute(context)) {
context.stepGeneration();
}
} catch (CompletionException exception) {
// handle the exception
} catch (EvolutionException exception) {
// handle the exception
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment