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

Plus d'erreur pour le test (mais ca marche pas tres bien quand meme)

parent 9b0ee3ab
No related branches found
No related tags found
No related merge requests found
import numpy import numpy
from RotTable import RotTable from RotTable import RotTable
from individu import Individu
ROT_TABLE = {\ ROT_TABLE = {\
"AA": [35.62, 7.2, -154, 0.06, 0.6, 0],\ "AA": [35.62, 7.2, -154, 0.06, 0.6, 0],\
...@@ -22,17 +23,17 @@ ROT_TABLE = {\ ...@@ -22,17 +23,17 @@ ROT_TABLE = {\
def croisement_un_point(parent1, parent2): def croisement_un_point(parent1, parent2):
enfant1 = RotTable() enfant1 = Individu(RotTable())
enfant2 = RotTable() enfant2 = Individu(RotTable())
comp = 0 comp = 0
point_crois= numpy.random.random_integers(0,16) point_crois= numpy.random.random_integers(0,16)
for doublet in ROT_TABLE: for doublet in ROT_TABLE:
if comp < point_crois: if comp < point_crois:
enfant1.rot_table[doublet] = parent1.rot_table[doublet] enfant1.table.rot_table[doublet] = parent1.table.rot_table[doublet]
enfant2.rot_table[doublet] = parent2.rot_table[doublet] enfant2.table.rot_table[doublet] = parent2.table.rot_table[doublet]
else : else :
enfant1.rot_table[doublet] = parent2.rot_table[doublet] enfant1.table.rot_table[doublet] = parent2.table.rot_table[doublet]
enfant2.rot_table[doublet] = parent1.rot_table[doublet] enfant2.table.rot_table[doublet] = parent1.table.rot_table[doublet]
comp += 1 comp += 1
return enfant1, enfant2 return enfant1, enfant2
......
...@@ -20,8 +20,8 @@ class Population: ...@@ -20,8 +20,8 @@ class Population:
p = (self.n)//2 p = (self.n)//2
newself=[] newself=[]
vu=set() vu=set()
m=None m=randrange(0,self.n)
t=None #méthode des duels pondérée: si x=10 et y=1, y a une chance sur 11 de passer t=randrange(0,self.n) #méthode des duels pondérée: si x=10 et y=1, y a une chance sur 11 de passer
while len(newself)<p: while len(newself)<p:
while m in vu: while m in vu:
m=randrange(0,self.n) m=randrange(0,self.n)
...@@ -44,14 +44,12 @@ class Population: ...@@ -44,14 +44,12 @@ class Population:
p = (self.n)//2 p = (self.n)//2
newself=[] newself=[]
vu=set() vu=set()
t=None t=randrange(0,self.n)
m=None m=randrange(0,self.n)
while len(newself)<p: while len(newself)<p:
while m in vu: while m in vu:
print("self.n", self.n)
m=randrange(0,self.n) m=randrange(0,self.n)
while t in vu: while t in vu:
print("self.n", self.n)
t=randrange(0,self.n) t=randrange(0,self.n)
x=self.indiv[m] x=self.indiv[m]
y=self.indiv[t] y=self.indiv[t]
...@@ -135,7 +133,9 @@ class Population: ...@@ -135,7 +133,9 @@ class Population:
t=randrange(0,self.n) t=randrange(0,self.n)
x=newself[m] x=newself[m]
y=newself[t] y=newself[t]
newself.append(enfant(x,y)) couple_enfant = enfant(x,y)
newself.append(couple_enfant[0])
newself.append(couple_enfant[1])
self = self.modifier_population(newself) self = self.modifier_population(newself)
def afficher(popu): def afficher(popu):
......
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