diff --git a/__pycache__/Initialisation.cpython-37.pyc b/__pycache__/Initialisation.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e986e03a10e3574402c013796cf8296d4a58eb32 Binary files /dev/null and b/__pycache__/Initialisation.cpython-37.pyc differ diff --git a/__pycache__/RotTable.cpython-37.pyc b/__pycache__/RotTable.cpython-37.pyc index eace4b1c9a198d349c22181322d81371595ca2d7..306bef3707a8dfe8d997aa52208ffe660f6a4161 100644 Binary files a/__pycache__/RotTable.cpython-37.pyc and b/__pycache__/RotTable.cpython-37.pyc differ diff --git a/__pycache__/Traj3D.cpython-37.pyc b/__pycache__/Traj3D.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9089d353fd2661eb0e1c444fe75a6b707a6ecd10 Binary files /dev/null and b/__pycache__/Traj3D.cpython-37.pyc differ diff --git a/individu.py b/individu.py index 57da3ffcd7d82d5adb5b8edafb47facd09c0aff0..9d8cc4427ec0f2b68729d24f56e0021e7b4345d9 100644 --- a/individu.py +++ b/individu.py @@ -29,26 +29,6 @@ class Individu(): diff_angle = sum(abs(rot_computed - rot_traj)) 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): @@ -59,7 +39,7 @@ class Individu(): if tir < proba : print("mutation", 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]) individu1 = Individu(RotTable()) diff --git a/selection_par_rang.py b/selection_par_rang.py new file mode 100644 index 0000000000000000000000000000000000000000..ded5567fe7094249e4e3f1e0222031f0010a0164 --- /dev/null +++ b/selection_par_rang.py @@ -0,0 +1,45 @@ +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