Created
January 6, 2011 01:30
-
-
Save fearofcode/767365 to your computer and use it in GitHub Desktop.
main loop of simple genetic algorithm (real-to-real function optimizer)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public double[] runGenerations(int generations, int tournamentSize) { | |
int generation = 1; | |
while(generation <= generations) { | |
computeFitness(); | |
double[][] parents = selectParentsByTournament(tournamentSize); | |
double[][] children = breedChildrenFromParents(parents); | |
for(double[] child : children) { | |
insertChild(child); | |
} | |
generation++; | |
} | |
return fittestIndividual(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment