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