Created
November 27, 2017 17:25
-
-
Save NicolleLouis/099a68be841050ca06fbb630d5be1edd to your computer and use it in GitHub Desktop.
Intramutation Knapsack
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 mutate_one_individual(individual): | |
i = int(len(individual) * random.random()) | |
individual[i] = not individual[i] | |
return individual | |
def mutate_population(population, mutationRate): | |
for i in population: | |
if (100 * random.random() < mutationRate): | |
i = mutate_one_individual(i) | |
return (population) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment