Skip to content
Snippets Groups Projects
Commit 2daf29c6 authored by Muller Sacha's avatar Muller Sacha
Browse files

A vu d'oeil toutes les fonctions de selection ne produisent plus d'erreur

parent 70323d17
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ class Population: ...@@ -31,7 +31,7 @@ class Population:
y=self.indiv[t] y=self.indiv[t]
vu.add(t) vu.add(t)
vu.add(m) vu.add(m)
p=random(0,1) p=random()
if p>x.score/(x.score+y.score): if p>x.score/(x.score+y.score):
newself.append(y) newself.append(y)
else: else:
...@@ -115,7 +115,7 @@ class Population: ...@@ -115,7 +115,7 @@ class Population:
while len(newself)<p: while len(newself)<p:
m=m=randrange(0, self.n) m=m=randrange(0, self.n)
x=self.indiv[m] x=self.indiv[m]
p=random(0,1) p=random()
if p<=x.score/somme: if p<=x.score/somme:
newself.append(x) newself.append(x)
self = self.modifier_population(newself) self = self.modifier_population(newself)
...@@ -152,11 +152,11 @@ def test(): ...@@ -152,11 +152,11 @@ def test():
# popu.selection_par_rang() # popu.selection_par_rang()
# print("\n SELECTION PAR RANG \n") # print("\n SELECTION PAR RANG \n")
# afficher(popu) # afficher(popu)
popu.reproduction() popu.reproduction(selection = popu.selection_proportionelle)
print("\n REPRODUCTION \n") print("\n REPRODUCTION \n")
afficher(popu) afficher(popu)
# test() test()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment