I am trying to do crossover on a Genetic Algorithm population using numpy. I have sliced the population using parent 1 and parent 2.
population = np.random.randint(2, size=(4,8))
p1 = population[::2]
p2 = population[1::2]
But I am not able to figure out any lambda or numpy command to do uniform crossover over parents. The concept is to take ith row pf p1
and randomly swap some bits with ith row of p2
.
Aucun commentaire:
Enregistrer un commentaire