Created
July 8, 2016 13:59
-
-
Save Yuemashi/b1d7b6ee2a71281deb2853af81bb58b6 to your computer and use it in GitHub Desktop.
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
crossover = -> parents, position { | |
[] << parents[0].take(position) + parents[1].drop(position) << | |
parents[1].take(position) + parents[0].drop(position) } | |
mutate = -> individual, position, genotypeDefinition { | |
individual[position] = genotypeDefinition.curry(1) | |
individual.flatten } | |
selection = -> population { | |
(population + population).sort_by{ |n| -fitness[n]}.take(population.length) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment