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

Changements sur individu.py

parent 132ac6d8
No related branches found
No related tags found
No related merge requests found
File added
No preview for this file type
File added
...@@ -29,26 +29,6 @@ class Individu(): ...@@ -29,26 +29,6 @@ class Individu():
diff_angle = sum(abs(rot_computed - rot_traj)) diff_angle = sum(abs(rot_computed - rot_traj))
self.score = 1/(distance + diff_angle) self.score = 1/(distance + diff_angle)
__ORIGINAL_ROT_TABLE = {\
"AA": [35.62, 7.2, -154, 0.06, 0.6, 0],\
"AC": [34.4, 1.1, 143, 1.3, 5, 0],\
"AG": [27.7, 8.4, 2, 1.5, 3, 0],\
"AT": [31.5, 2.6, 0, 1.1, 2, 0],\
"CA": [34.5, 3.5, -64, 0.9, 34, 0],\
"CC": [33.67, 2.1, -57, 0.07, 2.1, 0],\
"CG": [29.8, 6.7, 0, 1.1, 1.5, 0],\
"CT": [27.7, 8.4, -2, 1.5, 3, 0],\
"GA": [36.9, 5.3, 120, 0.9, 6, 0],\
"GC": [40, 5, 180, 1.2, 1.275, 0],\
"GG": [33.67, 2.1, 57, 0.07, 2.1, 0],\
"GT": [34.4, 1.1, -143, 1.3, 5, 0],\
"TA": [36, 0.9, 0, 1.1, 2, 0],\
"TC": [36.9, 5.3, -120, 0.9, 6, 0],\
"TG": [34.5, 3.5, 64, 0.9, 34, 0],\
"TT": [35.62, 7.2, -154, 0.06, 0.6, 0]\
}
def mutation(self, proba = P1): def mutation(self, proba = P1):
...@@ -59,7 +39,7 @@ class Individu(): ...@@ -59,7 +39,7 @@ class Individu():
if tir < proba : if tir < proba :
print("mutation", doublet, coord) print("mutation", doublet, coord)
print("table", table_rotations[doublet][coord]) print("table", table_rotations[doublet][coord])
table_rotations[doublet][coord] =np.random.uniform(low = Individu.__ORIGINAL_ROT_TABLE[doublet][coord] - Individu.__ORIGINAL_ROT_TABLE[doublet][coord + 3], high = Individu.__ORIGINAL_ROT_TABLE[doublet][coord] + Individu.__ORIGINAL_ROT_TABLE[doublet][coord + 3]) table_rotations[doublet][coord] =np.random.uniform(low = self.table.orta()[doublet][coord] - self.table.orta()[doublet][coord + 3], high = self.table.orta()[doublet][coord] + self.table.orta()[doublet][coord + 3])
print("table", table_rotations[doublet][coord]) print("table", table_rotations[doublet][coord])
individu1 = Individu(RotTable()) individu1 = Individu(RotTable())
......
from random import random
def creer_population(self, liste_individus):
self.n = len(liste_individus)
self.indiv = set(liste_individus)
return self
def selection_par_rang(self, p = n//2):
set_individus = self.indiv
n = self.n
def partitionner(tableau,debut,fin):
echanger(tableau,debut,random.randint(debut,fin-1))
partition=debut
for i in range(debut+1,fin):
if tableau[i].score<tableau[debut].score:
partition+=1
echanger(tableau,i,partition)
echanger(tableau,debut,partition)
return partition
def tri_rapide_aux(tableau,debut,fin):
if debut < fin-1:
positionPivot=partitionner(tableau,debut,fin)
tri_rapide_aux(tableau,debut,positionPivot)
tri_rapide_aux(tableau,positionPivot+1,fin)
def tri_rapide(tableau):
tri_rapide_aux(tableau,0,len(tableau))
liste = list(set_individus)
tri_rapide(liste)
individus_selectionnes = []
for _ in range(p):
curseur = random()*n*(n+1)/2
j = 1
while j*(j+1)/2 < curseur :
j+=1
#on doit prendre l'individu avec le jème score
individus_selectionnes.append(liste[j])
self = creer_population(self, liste_individus)
\ No newline at end of file
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