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

Merge branch 'master' of...

parents d25ea795 c1b3f780
No related branches found
No related tags found
No related merge requests found
......@@ -11,25 +11,6 @@ import matplotlib.pyplot as plt
import time
from copy import deepcopy
# def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
# '''lineList = [line.rstrip('\n') for line in open(brin)]
# brin = ''.join(lineList[1:])'''
# L=[]
# People=Population(N)
# for i in range(tmax):
# print(i)
# max=0
# best=None
# People.reproduction(p = proportion, proba_mutation= pmutation)
# for individu in People.indiv:
# if individu.score>max:
# best=individu
# max=individu.score
# L.append(max)
# plt.plot([i for i in range(tmax)], L, label = str(pmutation))
# return(best)
def main(N,tmax,pmutation, proportion, indice_selection, population_initiale, enfant = croisement_un_point):
......@@ -68,8 +49,10 @@ def main(N,tmax,pmutation, proportion, indice_selection, population_initiale, en
# plt.subplot(223)
# plt.hist(S1, range = (0, maximum+10), bins = 20, color = 'red')
# S2=[individu.score for individu in People.indiv]
# print("Score final: ",best.score)
S2=[individu.score for individu in People.indiv]
print("Score final: ",best.score)
print("Avg:", sum(S2)/len(S2))
print("Distance final: ",best.distance)
# plt.subplot(224)
......@@ -79,62 +62,12 @@ def main(N,tmax,pmutation, proportion, indice_selection, population_initiale, en
return(best,People)
# lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
# brin = ''.join(lineList[1:])
# best,People = main(10,10,0.01,5)
# test = Traj3D()
# test.compute(brin, best.table)
# test.draw("first_plot")
def compare_mutation():
start_time = time.time()
plt.figure()
for i in range(1,5):
print("\n \n", i)
main(100,40,10**(-i),50)
plt.legend()
plt.xlabel("Nombre de générations")
plt.ylabel("Score du meilleur individu")
plt.title("Comparaison en fonction du taux de mutation")
print("Temps d'execution : %s secondes " % (time.time() - start_time))
plt.show()
def comparaison_selections():
liste_selections = ["selection_p_best", "selection_duel_pondere", "selection_duel", "selection_par_rang", "selection_proportionnelle"]
liste_time = []
# plt.figure()
People = Population(100)
# S2=[individu.score for individu in People.indiv]
# plt.hist(S2, range = (0,int(max(S2)+10)), bins = 20, color = 'blue')
# plt.show()
# plt.figure()
for i in range(5):
print("\n", liste_selections[i], "\n")
start_time = time.time()
best = main(100, 35, 0.001, 50, i, deepcopy(People), enfant = croisement_deux_points)[0]
liste_time.append((liste_selections[i], time.time() - start_time, best.score))
# plt.legend()
# plt.xlabel("Nombre de générations")
# plt.ylabel("Score du meilleur individu")
# plt.title("Comparaison en fonction de la méthode de sélection")
return numpy.array(liste_time)
# plt.show()
# def comparaisons_croisements():
# liste_croisements = ["croisement_un_point", "croisement_deux_points"]
# compare_mutation()
liste = []
for i in range(5):
liste.append(comparaison_selections())
print(liste)
print(liste)
lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
brin = ''.join(lineList[1:])
best,People = main(100,10,0.05,10)
test = Traj3D()
test.compute(brin, best.table)
test.draw("first_plot")
# [['selection_p_best' '22.637820959091187' '116.30569654472626']
# ['selection_duel_pondere' '22.636890172958374' '46.6242321955727']
......
......@@ -16,6 +16,7 @@ class Individu():
self.brin = ''.join(lineList[1:])
#self.brin = "AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA"
self.score = None
self.distance = None
def evaluate(self):
''' Evalue le score d'un individu sur un nombre numb_ajout de points'''
......@@ -42,10 +43,10 @@ class Individu():
nuc_coordonate_end = end[i]
distance_nuc = np.linalg.norm(nuc_coordonate_beg - nuc_coordonate_end, ord=2)
list_distance += [distance_nuc]
self.score = max(list_distance)
self.distance = np.linalg.norm(traj_array[numb_ajout] - traj_array[-(numb_ajout+1)], ord=2)
#return max(list_distance)
......
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