Skip to content

Instantly share code, notes, and snippets.

@viniciusarruda
Created January 31, 2019 02:00
Show Gist options
  • Save viniciusarruda/e01e26322ef6d34659fb0626e489956e to your computer and use it in GitHub Desktop.
Save viniciusarruda/e01e26322ef6d34659fb0626e489956e to your computer and use it in GitHub Desktop.
Python based pseudo-code of a Genetic Algorithm
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