Skip to content
Snippets Groups Projects
Commit 90976419 authored by Gauthier Roy's avatar Gauthier Roy
Browse files

Merge branch 'master' of...

parents bb698477 1648ed31
Branches
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
......@@ -16,30 +16,23 @@ 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(6,8,0.01,2)
main(100,100,0.1,50)
......@@ -10,7 +10,7 @@ class Individu():
def __init__(self, table):
self.table = table
self.score = None
self.score = self.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
def evaluate(self, brin):
traj = Traj3D()
......@@ -39,6 +39,8 @@ class Individu():
self.score = 1/max(list_distance)
return 1/distance
def mutation(self, proba = P1):
table_rotations = self.table.rot_table
......
......@@ -48,8 +48,7 @@ class Population:
print("meilleur, individu: ", 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)
non_vu = [i for i in range(0, self.n)]
......@@ -137,7 +136,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)
......@@ -146,10 +145,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")
......@@ -168,8 +169,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