salut
je veux créer une fonction qui fait le croisement entre deux individus mais j'ai obtenu le résultat attendu.S'il vous plait pouvez vous m'aider
sachant que la fonction une liste comme ca [0 1 0 0 1 0 0 1 0 1 ] et l est la taille de liste
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 def croisement_deux (self , i1 , i2,l): a = l / 2 childrens=[] father=i1.get_random() mother=i2.get_random() child1=father[:a]+mother[a:] childrens.append(child1) child2=mother[:a]+father[a:] childrens.append(child2) return childrens
Merci d'avance
Partager