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

croissance (peut etre)

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