Created
January 31, 2019 02:00
-
-
Save viniciusarruda/e01e26322ef6d34659fb0626e489956e to your computer and use it in GitHub Desktop.
Python based pseudo-code of a Genetic Algorithm
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
def genetic_algorithm(n): | |
population = init_population(n) | |
for _ in xrange(epochs): | |
fn = fitness(population) | |
parents = selection(n, fn) | |
offspring = crossover(parents) | |
offspring = mutation(offspring) | |
population = parents + offspring | |
return best(population) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment