GeneticAlgorithmPython icon indicating copy to clipboard operation
GeneticAlgorithmPython copied to clipboard

(documentation)Custom Code for Mutation as error in it

Open Carlsans opened this issue 1 year ago • 0 comments

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]))

Carlsans avatar Aug 08 '22 02:08 Carlsans