Skip to content
Snippets Groups Projects
Commit 7e47e04b authored by Kappes Marques Rodrigo's avatar Kappes Marques Rodrigo
Browse files

Resolved the problem of losing the best players

parent 2de42490
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
...@@ -32,7 +32,7 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"): ...@@ -32,7 +32,7 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
return(best) return(best)
main(100,100,0.1,50) main(100,100,0,50)
...@@ -3,6 +3,7 @@ from random import * ...@@ -3,6 +3,7 @@ from random import *
from individu import Individu from individu import Individu
from RotTable import RotTable from RotTable import RotTable
from croisement import croisement_un_point, croisement_deux_points from croisement import croisement_un_point, croisement_deux_points
import copy
class Population: class Population:
def __init__(self,n): def __init__(self,n):
...@@ -13,6 +14,9 @@ class Population: ...@@ -13,6 +14,9 @@ class Population:
"""Fonction qui renvoie une nouvelle instance de population a partir d'une liste d'individus""" """Fonction qui renvoie une nouvelle instance de population a partir d'une liste d'individus"""
self.n = len(liste_individus) self.n = len(liste_individus)
self.indiv = liste_individus self.indiv = liste_individus
for i in range(0,self.n):
self.indiv[i].evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
return self return self
def selection_p_best(self,p=None): def selection_p_best(self,p=None):
...@@ -83,8 +87,6 @@ class Population: ...@@ -83,8 +87,6 @@ class Population:
newself.append(x) newself.append(x)
else: else:
newself.append(y) newself.append(y)
for i in range(0, len(newself)):
print(newself[i].score)
self = self.modifier_population(newself) self = self.modifier_population(newself)
...@@ -161,8 +163,8 @@ class Population: ...@@ -161,8 +163,8 @@ class Population:
while len(newself)<vieille_taille: while len(newself)<vieille_taille:
m=randrange(0,self.n) m=randrange(0,self.n)
t=randrange(0,self.n) t=randrange(0,self.n)
x=newself[m] x=copy.deepcopy(newself[m])
y=newself[t] y=copy.deepcopy(newself[t])
couple_enfant = enfant(x,y) couple_enfant = enfant(x,y)
for child in couple_enfant : for child in couple_enfant :
child.mutation(proba_mutation) child.mutation(proba_mutation)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment