diff --git a/__pycache__/RotTable.cpython-36.pyc b/__pycache__/RotTable.cpython-36.pyc index 459e4374c306aebaf525b830c17f00a8820843ca..1f5e29dc3b0df2b0334882e4c8d69ed8515fe145 100644 Binary files a/__pycache__/RotTable.cpython-36.pyc and b/__pycache__/RotTable.cpython-36.pyc differ diff --git a/algogenetique.py b/algogenetique.py index 9db84ff75a810c25f7869ffbfeb142dff48cf47a..8fe1a6250fd64a61d5ba50022f9629f1d2ca0371 100644 --- a/algogenetique.py +++ b/algogenetique.py @@ -14,10 +14,10 @@ import time start_time = time.time() -def main(N,tmax,pmutation, proportion): +def main(N,tmax,pmutation, proportion, filename): #Creation of the initial population - People=Population(N) + People=Population(N, filename) L=[] #Evaluating the initial population for the histogram @@ -72,7 +72,7 @@ def main(N,tmax,pmutation, proportion): #Testing our solution and printing the result in 3D lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")] brin = ''.join(lineList[1:]) -best,People = main(10,1000,0.05,5) +best,People = main(100,10,0.1,5, "plasmid_8k.fasta") test = Traj3D() test.compute(brin, best.table) test.draw("first_plot") diff --git a/croisement.py b/croisement.py index e9942ef5b4d0c7e628dfbd1515587c22b1486c1f..8e160e4b3a8e499109ce231add4c6b570e53cefd 100644 --- a/croisement.py +++ b/croisement.py @@ -2,12 +2,12 @@ import numpy from RotTable import RotTable from individu import Individu -def croisement_un_point(parent1, parent2): +def croisement_un_point(parent1, parent2, filename): '''Croise les tables de rotation des parents pour former deux enfants en respectant les symétries du problème''' ''' Retourne deux enfants''' - enfant1 = Individu(RotTable()) - enfant2 = Individu(RotTable()) + enfant1 = Individu(RotTable(), filename) + enfant2 = Individu(RotTable(), filename) comp = 0 point_crois= numpy.random.random_integers(0,8) list_dinucleotides = sorted(RotTable().orta()) @@ -45,12 +45,12 @@ def croisement_un_point(parent1, parent2): return enfant1, enfant2 -def croisement_deux_points(parent1, parent2): +def croisement_deux_points(parent1, parent2, filename): ''' Croise les tables de rotationd des deux parents en croisant à deux points et respectant les symétries du problème''' ''' Retourne deux enfants''' - enfant1 = Individu(RotTable()) - enfant2 = Individu(RotTable()) + enfant1 = Individu(RotTable(), filename) + enfant2 = Individu(RotTable(), filename) comp = 0 point_crois1= numpy.random.random_integers(0,8) point_crois2= numpy.random.random_integers(0,8) diff --git a/first_plot.png b/first_plot.png index f9294f16e9e6dc29674f763436bc6927a5b6bbb7..0e536fb530ea40bc82a9395940755ad27a030609 100644 Binary files a/first_plot.png and b/first_plot.png differ diff --git a/individu.py b/individu.py index c75d14545841b5091e248ef2b58c265fd5234ea4..6e06018e45c2069ff628c8cc7bfe5122a7fd966c 100644 --- a/individu.py +++ b/individu.py @@ -9,12 +9,10 @@ P1 = 0.015 class Individu(): ''' Un individu est caractérisé par sa table de rotations (individu.table)''' - def __init__(self, table): + def __init__(self, table, filename): self.table = table - lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")] + lineList = [line.rstrip('\n') for line in open(filename)] self.brin = ''.join(lineList[1:]) - #self.brin = "AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA" - # (sequence used for test) self.score = None self.distance = None diff --git a/population.py b/population.py index 2c89349ff371c58b15e405c5afa37c50eda00dc7..036717f780fbbd8c5f9c231420c228d5faaf59d6 100644 --- a/population.py +++ b/population.py @@ -10,8 +10,9 @@ class Population: #Class initialization - def __init__(self,n): - self.indiv=[Individu(RotTable()) for k in range (n)] + def __init__(self,n,filename): + self.filename = filename + self.indiv=[Individu(RotTable(), self.filename) for k in range (n)] self.n = n #Updates the current individuals in the population @@ -132,7 +133,7 @@ class Population: if proba_mutation == None : proba_mutation = 0.001 if selection == None : - selection = self.selection_duel + selection = self.selection_par_rang else : selection = liste_selections[selection] if p == None : @@ -150,7 +151,7 @@ class Population: y=copy.deepcopy(newself[t]) #Creation of the childs - couple_enfant = enfant(x,y) + couple_enfant = enfant(x,y, self.filename) for child in couple_enfant : child.mutation_close_values(proba_mutation, number_of_mutations = 2) child.evaluate()