Skip to content
Snippets Groups Projects
Commit 5dd13cd9 authored by Nihama Sandra Ayumi's avatar Nihama Sandra Ayumi
Browse files

optimization in selection duel

parent 1e13ae99
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
No preview for this file type
......@@ -31,7 +31,7 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
if individu.score>max:
best=individu
max=individu.score
afficher(People)
# afficher(People)
L.append(max)
#print(L)
plt.plot([i for i in range(tmax)], L)
......@@ -39,7 +39,7 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
return(best)
main(10,50,0,5)
main(6,8,0.01,2)
......@@ -31,7 +31,7 @@ class table_rotation(rotation):
self.dict = {doublet : rotation(doublet) for doublet in ORIGINAL_ROT_TABLE}
table1 = table_rotation()
print(table1.dict["AA"].x)
# print(table1.dict["AA"].x)
#table1.dict --> {'AA': <__main__.rotation object at 0x000001A722E1BAC8>, 'AC': <__main__.rotation object at 0x000001A722E1BB00>, 'AG': <__main__.rotation object at 0x000001A729A66A58>, 'AT': <__main__.rotation object at 0x000001A729A66A20>, 'CA': <__main__.rotation object at 0x000001A729A669E8>, 'CC': <__main__.rotation object at 0x000001A729A66A90>, 'CG': <__main__.rotation object at 0x000001A729A66B00>, 'CT': <__main__.rotation object at 0x000001A729A66B70>, 'GA': <__main__.rotation object at 0x000001A729B88D68>, 'GC': <__main__.rotation object at 0x000001A729B88DA0>, 'GG': <__main__.rotation object at 0x000001A729B88DD8>, 'GT': <__main__.rotation object at 0x000001A729B88E10>, 'TA': <__main__.rotation object at 0x000001A729B88E48>, 'TC': <__main__.rotation object at 0x000001A729B88E80>, 'TG': <__main__.rotation object at 0x000001A729B88EB8>, 'TT': <__main__.rotation object at 0x000001A729B88EF0>}
#table1.dict["AA"] ---> <__main__.rotation object at 0x000001A722E1BAC8> (qui est l'object rotation)
......
import random
from random import random, randint, randrange
from random import *
from individu import Individu
from RotTable import RotTable
from croisement import croisement_un_point, croisement_deux_points
......@@ -45,25 +45,28 @@ class Population:
meilleur = self.indiv[0]
for individu in self.indiv :
if meilleur.score < individu.score:
print("meilleur, individu: ", meilleur.score, individu.score)
meilleur = individu
newself = [meilleur]
print("\n \n \nmeilleur", meilleur.table.rot_table, "\n \nscore", meilleur.score)
vu=set()
# print("\n \n \nmeilleur", meilleur.table.rot_table, "\n \nscore", meilleur.score)
t=randrange(0,self.n)
m=randrange(0,self.n)
m=randrange(0,self.n)
non_vu = [i for i in range(0, self.n)]
while len(newself)<p:
while m in vu:
m=randrange(0,self.n)
while t in vu:
t=randrange(0,self.n)
m = choice(non_vu)
non_vu.remove(m)
t = choice(non_vu)
non_vu.remove(t)
x=self.indiv[m]
y=self.indiv[t]
vu.add(t)
vu.add(m)
if x.score>=y.score:
newself.append(x)
else:
newself.append(y)
for i in range(0, len(newself)):
print(newself[i].score)
self = self.modifier_population(newself)
def selection_par_rang(self,p = None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment