A mutation rate controls how often offspring receive randomized changes to their genetic material during evolutionary reproduction. In a genetic algorithm, each gene may be tested independently after crossover. Lower rates preserve specialization and stability; higher rates increase variation but can prevent individuals from reaching optimum performance. section 2.6 section 2.5.9
Listing 2.18 EDL_2_5_Genetic_Algorithms.ipynb: Mutation
def mutation(individual, mutation_rate):
for i in range(len(individual)): #1
if random.random() < mutation_rate: #2
individual[i] = 1 - individual[i] #2
return individual
mutation(pop[parent[0]], .5)
A simple mutation function loops over an individual, compares a random value with mutation_rate, and flips each selected binary gene. section 2.5.7
Use mutation rate as an experimental control:
- Set it between 0 and 1; a demonstration may use 0.5, although typical rates are described as below 5%. section 2.4.2 section 2.5.7
- Increase it to introduce more population variety, or decrease it to encourage specialization and potentially more stable evolution. section 2.5.9
- Rerun the evolutionary notebook after changing the value and inspect whether the population converges faster, improves, or fails to stabilize. section 2.4.2 section 6.2.1
