Skip to content

Instantly share code, notes, and snippets.

@Ifihan
Created December 16, 2021 17:37
Show Gist options
  • Save Ifihan/af584a7ea6f56588a5eec4968259640b to your computer and use it in GitHub Desktop.
Save Ifihan/af584a7ea6f56588a5eec4968259640b to your computer and use it in GitHub Desktop.
Mutation algorithm implementation in Python
import random
def mutation(individual, mutation_rate):
for i in range(len(individual)):
if random.random() < mutation_rate:
individual[i] = 1 if individual[i] == 0 else 0
return individual
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment