I use the weight in random.choice, so if I remove after selection, I'm afraid it would mess up the weight. pop_fit_sorted is an array of arrays using numpy and percentage is an aray with the weights.
parents_list = random.choices(pop_fit_sorted, weights=percentage, k=2)
That's the code i'm using. But it can sometimes select the same array twice. How to alway select 2 different arrays?
Aucun commentaire:
Enregistrer un commentaire