diff --git a/__pycache__/RotTable.cpython-37.pyc b/__pycache__/RotTable.cpython-37.pyc index 64b41c9070f8c3bcccf58f1c80d64aa9e723cf13..0665bddc8d3fe8aeea7fabbae0d2c01f9aaae884 100644 Binary files a/__pycache__/RotTable.cpython-37.pyc and b/__pycache__/RotTable.cpython-37.pyc differ diff --git a/__pycache__/Traj3D.cpython-37.pyc b/__pycache__/Traj3D.cpython-37.pyc index 5bcb4d8418f4525b71a8bb56bf694fb3e384bafb..a2a274a976ce1c2947d34c190976cd65879f2491 100644 Binary files a/__pycache__/Traj3D.cpython-37.pyc and b/__pycache__/Traj3D.cpython-37.pyc differ diff --git a/algogenetique.py b/algogenetique.py index 2dab902ae6d3fb5d5936b82b2d06d8621ccb46ff..81da80b77b9edfbb0a7e5a89350883ae4085f9c9 100644 --- a/algogenetique.py +++ b/algogenetique.py @@ -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) diff --git a/individu.py b/individu.py index e9fdceca287cbc231c4a535f03f8967c514fdf20..f243bfaba7e6bb7c22cc5c5eb3949ffbf0302d8f 100644 --- a/individu.py +++ b/individu.py @@ -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 diff --git a/population.py b/population.py index 25f612d53f3e06512efb23ac15e5ed3426e9fbc7..28e1c231d035b0ab3c9133281b73855e0ee3a93b 100644 --- a/population.py +++ b/population.py @@ -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() - -