diff --git a/algogenetique.py b/algogenetique.py index 1be4716b802797a9f4b70810ff38d739cd422c8c..aa2f9529ecf076f3c0d25da107047f1ca978a2e1 100644 --- a/algogenetique.py +++ b/algogenetique.py @@ -23,15 +23,15 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"): if individu.score>max: best=individu max=individu.score - L.append(max) - print(i,":",max) + L.append(1/max) + print(i,":",1/max) plt.plot([i for i in range(tmax)], L) plt.show() return(best, People) -best, People = main(60,100,0.01,20) +best, People = main(60,5,0.1,30) traj = Traj3D() traj.compute(best.brin,best.table) traj.draw("plot") diff --git a/individu.py b/individu.py index 6457428c303ba4241b9d4d99513ef6a21ef4f89a..a913a0f63b7fd4529115441cd12af0e5260dd36d 100644 --- a/individu.py +++ b/individu.py @@ -45,7 +45,7 @@ class Individu(): return 1/max(list_distance) - def mutation(self, proba = P1): + def mutation_with_numbers(self, proba = P1): table_rotations = self.table.rot_table number_of_mutations = 5 for i in range(0,number_of_mutations): @@ -66,7 +66,19 @@ class Individu(): #sur l'axe z il y a un moins table_rotations[doublet2][coord] = - table_rotations[doublet][coord] - + def mutation(self, proba = P1): + table_rotations = self.table.rot_table + for doublet in table_rotations : + for coord in range(3): + tir = random() + if tir < proba : + 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]) + doublet2 = self.table.corr()[doublet] + if coord == 0 or coord == 1 : + table_rotations[doublet2][coord] = table_rotations[doublet][coord] + else : + #sur l'axe z il y a un moins + table_rotations[doublet2][coord] = - table_rotations[doublet][coord] # individu1 = Individu(RotTable()) # print(individu1.table.rot_table) # individu1.mutation()