Skip to content
Snippets Groups Projects
Commit 5241d085 authored by Gauthier Roy's avatar Gauthier Roy
Browse files

more dynamique version of putting the ribbon

parent 3cb049b3
Branches
No related tags found
No related merge requests found
No preview for this file type
......@@ -14,10 +14,10 @@ import time
start_time = time.time()
def main(N,tmax,pmutation, proportion):
def main(N,tmax,pmutation, proportion, filename):
#Creation of the initial population
People=Population(N)
People=Population(N, filename)
L=[]
#Evaluating the initial population for the histogram
......@@ -72,7 +72,7 @@ def main(N,tmax,pmutation, proportion):
#Testing our solution and printing the result in 3D
lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
brin = ''.join(lineList[1:])
best,People = main(10,1000,0.05,5)
best,People = main(100,10,0.1,5, "plasmid_8k.fasta")
test = Traj3D()
test.compute(brin, best.table)
test.draw("first_plot")
......
......@@ -2,12 +2,12 @@ import numpy
from RotTable import RotTable
from individu import Individu
def croisement_un_point(parent1, parent2):
def croisement_un_point(parent1, parent2, filename):
'''Croise les tables de rotation des parents pour former deux enfants en respectant les symétries du problème'''
''' Retourne deux enfants'''
enfant1 = Individu(RotTable())
enfant2 = Individu(RotTable())
enfant1 = Individu(RotTable(), filename)
enfant2 = Individu(RotTable(), filename)
comp = 0
point_crois= numpy.random.random_integers(0,8)
list_dinucleotides = sorted(RotTable().orta())
......@@ -45,12 +45,12 @@ def croisement_un_point(parent1, parent2):
return enfant1, enfant2
def croisement_deux_points(parent1, parent2):
def croisement_deux_points(parent1, parent2, filename):
''' Croise les tables de rotationd des deux parents en croisant à deux points et respectant les symétries du problème'''
''' Retourne deux enfants'''
enfant1 = Individu(RotTable())
enfant2 = Individu(RotTable())
enfant1 = Individu(RotTable(), filename)
enfant2 = Individu(RotTable(), filename)
comp = 0
point_crois1= numpy.random.random_integers(0,8)
point_crois2= numpy.random.random_integers(0,8)
......
first_plot.png

2.35 KiB | W: | H:

first_plot.png

2.36 KiB | W: | H:

first_plot.png
first_plot.png
first_plot.png
first_plot.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -9,12 +9,10 @@ P1 = 0.015
class Individu():
''' Un individu est caractérisé par sa table de rotations (individu.table)'''
def __init__(self, table):
def __init__(self, table, filename):
self.table = table
lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
lineList = [line.rstrip('\n') for line in open(filename)]
self.brin = ''.join(lineList[1:])
#self.brin = "AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA"
# (sequence used for test)
self.score = None
self.distance = None
......
......@@ -10,8 +10,9 @@ class Population:
#Class initialization
def __init__(self,n):
self.indiv=[Individu(RotTable()) for k in range (n)]
def __init__(self,n,filename):
self.filename = filename
self.indiv=[Individu(RotTable(), self.filename) for k in range (n)]
self.n = n
#Updates the current individuals in the population
......@@ -132,7 +133,7 @@ class Population:
if proba_mutation == None :
proba_mutation = 0.001
if selection == None :
selection = self.selection_duel
selection = self.selection_par_rang
else :
selection = liste_selections[selection]
if p == None :
......@@ -150,7 +151,7 @@ class Population:
y=copy.deepcopy(newself[t])
#Creation of the childs
couple_enfant = enfant(x,y)
couple_enfant = enfant(x,y, self.filename)
for child in couple_enfant :
child.mutation_close_values(proba_mutation, number_of_mutations = 2)
child.evaluate()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment