Skip to content
Snippets Groups Projects
Commit ae56b931 authored by Kappes Marques Rodrigo's avatar Kappes Marques Rodrigo
Browse files

added mutation method

parent 59c403af
No related branches found
No related tags found
No related merge requests found
......@@ -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")
......
......@@ -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()
......
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