GeneticAlgorithmPython
GeneticAlgorithmPython copied to clipboard
(documentation)Custom Code for Mutation as error in it
The following code is buggy : def mutation_func(offspring, ga_instance):
for chromosome_idx in range(offspring.shape[0]):
random_gene_idx = numpy.random.choice(range(offspring.shape[0]))
offspring[chromosome_idx, random_gene_idx] += numpy.random.random()
return offspring
The following line : random_gene_idx = numpy.random.choice(range(offspring.shape[0])) should be : random_gene_idx = numpy.random.choice(range(offspring.shape[1]))