diff --git a/algogenetique.py b/algogenetique.py index 81da80b77b9edfbb0a7e5a89350883ae4085f9c9..8a1874e03d214a4c3f2f9804b275af26d35d8f5e 100644 --- a/algogenetique.py +++ b/algogenetique.py @@ -32,7 +32,7 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"): return(best) -main(100,100,0.1,50) +main(100,100,0,50) diff --git a/individu.py b/individu.py index f243bfaba7e6bb7c22cc5c5eb3949ffbf0302d8f..24193810b0c780eb4bc09bdd034a82094d59f376 100644 --- a/individu.py +++ b/individu.py @@ -39,7 +39,7 @@ class Individu(): self.score = 1/max(list_distance) - return 1/distance + return 1/max(list_distance) def mutation(self, proba = P1): diff --git a/population.py b/population.py index 559bebbe83e60dab6a55747e9a11f189d99dae0d..828caac54389b4296f47305d41e41a990b3b09dd 100644 --- a/population.py +++ b/population.py @@ -3,6 +3,7 @@ from random import * from individu import Individu from RotTable import RotTable from croisement import croisement_un_point, croisement_deux_points +import copy class Population: def __init__(self,n): @@ -13,9 +14,15 @@ class Population: """Fonction qui renvoie une nouvelle instance de population a partir d'une liste d'individus""" self.n = len(liste_individus) self.indiv = liste_individus + for i in range(0,self.n): + self.indiv[i].evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA") + return self - def selection_p_best(self,p=self.n//2): + def selection_p_best(self,p=None): + if p==None: + p=(self.n)//2 + def tri_rapide_aux(tableau,debut,fin): if debut < fin-1: positionPivot=partitionner(tableau,debut,fin) @@ -80,8 +87,6 @@ class Population: newself.append(x) else: newself.append(y) - for i in range(0, len(newself)): - print(newself[i].score) self = self.modifier_population(newself) @@ -158,8 +163,8 @@ class Population: while len(newself)<vieille_taille: m=randrange(0,self.n) t=randrange(0,self.n) - x=newself[m] - y=newself[t] + x=copy.deepcopy(newself[m]) + y=copy.deepcopy(newself[t]) couple_enfant = enfant(x,y) for child in couple_enfant : child.mutation(proba_mutation)