Skip to content
Snippets Groups Projects
Commit 246bb57c authored by Muller Sacha's avatar Muller Sacha
Browse files

mutations seulement sur les enfants

parent 42387077
Branches
No related tags found
No related merge requests found
......@@ -16,21 +16,22 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
brin = ''.join(lineList[1:])'''
L=[]
People=Population(N)
afficher(People)
# afficher(People)
for i in range(tmax):
print("\n \n NOUVELLE GENERATION \n \n")
max=0
best=None
for individu in People.indiv:
individu.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
People.reproduction(p = proportion)
for individu in People.indiv:
individu.mutation(pmutation)
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)
......@@ -38,7 +39,7 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
return(best)
main(100,50,0.015,50)
main(10,50,0,5)
......@@ -42,7 +42,12 @@ class Population:
def selection_duel(self,p=None):
if p == None :
p = (self.n)//2
newself=[]
meilleur = self.indiv[0]
for individu in self.indiv :
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)
......@@ -120,7 +125,9 @@ class Population:
newself.append(x)
self = self.modifier_population(newself)
def reproduction(self,selection=None,enfant=croisement_un_point, p = None):
def reproduction(self,proba_mutation = None, selection=None,enfant=croisement_un_point, p = None):
if proba_mutation == None :
proba_mutation = 0.001
if selection == None :
selection = self.selection_duel
if p == None :
......@@ -134,6 +141,8 @@ class Population:
x=newself[m]
y=newself[t]
couple_enfant = enfant(x,y)
for child in couple_enfant :
child.mutation(proba_mutation)
newself.append(couple_enfant[0])
newself.append(couple_enfant[1])
self = self.modifier_population(newself)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment