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

croissance (peut etre)

parent 246bb57c
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -16,30 +16,24 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"): ...@@ -16,30 +16,24 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
brin = ''.join(lineList[1:])''' brin = ''.join(lineList[1:])'''
L=[] L=[]
People=Population(N) People=Population(N)
# afficher(People)
for i in range(tmax): for i in range(tmax):
print("\n \n NOUVELLE GENERATION \n \n") print(i)
max=0 max=0
best=None best=None
for individu in People.indiv:
individu.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
People.reproduction(p = proportion, proba_mutation= pmutation) People.reproduction(p = proportion, proba_mutation= pmutation)
# for individu in People.indiv:
# individu.mutation(pmutation)
for individu in People.indiv: for individu in People.indiv:
individu.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
if individu.score>max: if individu.score>max:
best=individu best=individu
max=individu.score max=individu.score
afficher(People)
L.append(max) L.append(max)
#print(L)
plt.plot([i for i in range(tmax)], L) plt.plot([i for i in range(tmax)], L)
plt.show() plt.show()
return(best) return(best)
main(10,50,0,5) main(100,100,0.1,50)
...@@ -12,7 +12,7 @@ class Individu(): ...@@ -12,7 +12,7 @@ class Individu():
def __init__(self, table): def __init__(self, table):
self.table = table self.table = table
self.score = None self.score = self.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
def evaluate(self, brin): def evaluate(self, brin):
traj = Traj3D() traj = Traj3D()
...@@ -31,9 +31,11 @@ class Individu(): ...@@ -31,9 +31,11 @@ class Individu():
# print(rot_traj) # print(rot_traj)
# print(rot_computed) # print(rot_computed)
#diff_angle = sum(abs(rot_computed - rot_traj)) #diff_angle = sum(abs(rot_computed - rot_traj))
self.score = 1/distance self.score = 1/distance
return 1/distance
def mutation(self, proba = P1): def mutation(self, proba = P1):
table_rotations = self.table.rot_table table_rotations = self.table.rot_table
......
...@@ -47,7 +47,6 @@ class Population: ...@@ -47,7 +47,6 @@ class Population:
if meilleur.score < individu.score: if meilleur.score < individu.score:
meilleur = individu meilleur = individu
newself = [meilleur] newself = [meilleur]
print("\n \n \nmeilleur", meilleur.table.rot_table, "\n \nscore", meilleur.score)
vu=set() vu=set()
t=randrange(0,self.n) t=randrange(0,self.n)
m=randrange(0,self.n) m=randrange(0,self.n)
...@@ -134,7 +133,7 @@ class Population: ...@@ -134,7 +133,7 @@ class Population:
p = (self.n)//2 p = (self.n)//2
vieille_taille = self.n vieille_taille = self.n
selection(p) selection(p)
newself = list(self.indiv) newself = [element for element in self.indiv]
while len(newself)<vieille_taille: while len(newself)<vieille_taille:
m=randrange(0,self.n) m=randrange(0,self.n)
t=randrange(0,self.n) t=randrange(0,self.n)
...@@ -143,10 +142,12 @@ class Population: ...@@ -143,10 +142,12 @@ class Population:
couple_enfant = enfant(x,y) couple_enfant = enfant(x,y)
for child in couple_enfant : for child in couple_enfant :
child.mutation(proba_mutation) child.mutation(proba_mutation)
child.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
newself.append(couple_enfant[0]) newself.append(couple_enfant[0])
newself.append(couple_enfant[1]) newself.append(couple_enfant[1])
self = self.modifier_population(newself) self = self.modifier_population(newself)
def afficher(popu): def afficher(popu):
for individu in popu.indiv : for individu in popu.indiv :
print("\n individu \n") print("\n individu \n")
...@@ -165,8 +166,6 @@ def test(): ...@@ -165,8 +166,6 @@ def test():
#test() #test()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment