diff --git a/__pycache__/RotTable.cpython-37.pyc b/__pycache__/RotTable.cpython-37.pyc index e6bef50c3581cf2f06a53777c7291030d276cecd..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 865cc612f429be0814ee850289aa455b69755f50..a2a274a976ce1c2947d34c190976cd65879f2491 100644 Binary files a/__pycache__/Traj3D.cpython-37.pyc and b/__pycache__/Traj3D.cpython-37.pyc differ diff --git a/__pycache__/individu.cpython-37.pyc b/__pycache__/individu.cpython-37.pyc index af04e82760def202853d9a3c799aeaa8eb2c20f9..8d2c7962bd3231fbc5508be8d5f91432b01d2846 100644 Binary files a/__pycache__/individu.cpython-37.pyc and b/__pycache__/individu.cpython-37.pyc differ diff --git a/algogenetique.py b/algogenetique.py index cbcde6366a75846200845f298aabc3b3588fda1c..935461c570649a95af7dee1980c90e0d07436041 100644 --- a/algogenetique.py +++ b/algogenetique.py @@ -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) diff --git a/individu.py b/individu.py index 3ef8ae652a28fe19037ae25fad68465ad44a22bb..c367c48b882a0c79d636a76c9956bce3765ae5e9 100644 --- a/individu.py +++ b/individu.py @@ -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 diff --git a/population.py b/population.py index dc51f8c876c286ad1822991da190f5dcf3804b40..2d429812890b2e9302768782ecea6966c4f53f33 100644 --- a/population.py +++ b/population.py @@ -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() - -