From 69e8a061d6fd93996d67f8b97e2c0e9d1e93f60a Mon Sep 17 00:00:00 2001
From: Carlos Santos Garcia <carlos.santos@student-cs.fr>
Date: Wed, 29 Jan 2020 09:39:45 +0100
Subject: [PATCH] =?UTF-8?q?minimiser=20distance,=20histogrammes=20et=20bri?=
 =?UTF-8?q?n=20affich=C3=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 __pycache__/RotTable.cpython-37.pyc | Bin 2556 -> 2618 bytes
 __pycache__/Traj3D.cpython-37.pyc   | Bin 1910 -> 1972 bytes
 __pycache__/individu.cpython-37.pyc | Bin 1915 -> 1964 bytes
 algogenetique.py                    |  49 +++++++++++++++++++++-------
 individu.py                         |   4 +--
 population.py                       |   8 +++--
 6 files changed, 45 insertions(+), 16 deletions(-)

diff --git a/__pycache__/RotTable.cpython-37.pyc b/__pycache__/RotTable.cpython-37.pyc
index 488d94e3495eb14f5e5656ee066c85187063795a..20d277d55079d7a6401199aa6d99042a10aacd32 100644
GIT binary patch
delta 128
zcmew(yi0`JiI<m)fq{YHO@qNk?rkh-Uvn847@VzQLW@(2ier)!i*oW~T=J7kb5rw5
ziesFEV}e7BVnQ+wugovXOjSrpEmrVKEv<-g^#s!ju4VZ-r6rm9d3lMMMXALxshPT2
RsihUVsi@+cU$O|Z0ss=dE^Pn+

delta 66
zcmdlb@<*84iI<m)fq{WR)6#Gw_cj)dUq&ugF)sPZrManjCB-0CymN4jt7m+0h*6BO
Ti=U%zZenpsYSCtOR$*2EelQc$

diff --git a/__pycache__/Traj3D.cpython-37.pyc b/__pycache__/Traj3D.cpython-37.pyc
index bb19acf2cb441bd950ad0bafe725b66e924b457a..3051667333c64564621cb2fe405f2b8ac037b6bd 100644
GIT binary patch
delta 128
zcmeyyw}qeEiI<m)fq{YHO@qNk?n=hAuh|R?49-?Dp~b01#WBf=MLGE~F8Rr&xv6<2
z#WBvoF~K25F(Da;SLPRGrYfYQ7AttAmR7{LdV*;M*RuSa(vr;lyu8HBqSWG;)J)y1
R)Y1ywR8;ZJYZy<l0s!moE{p&G

delta 66
zcmdnO|Ba8^iI<m)fq{WR)6#GwcO|37F9R2=7?=Fy(%jU%l41}m-Z?nN)iXXg#3;tt
T#m`YUH?g=RwP^Dz##5{SaJ>}q

diff --git a/__pycache__/individu.cpython-37.pyc b/__pycache__/individu.cpython-37.pyc
index 421ada9911f9aceeb1a109b57518c98bb35bfd74..98e1fc46b75b89e6b1481052c1f6d4bf92a9d04c 100644
GIT binary patch
delta 239
zcmey(w}zkBiI<m)fq{Wxr;}ma{*Am_7}LJyGB7YWTg8MHrxq2*BqtW-<j1(=Czs}?
z=9Lu3I0wfBhZx0#WE@_ZUzC}ukdj)g;FVfh5##C!rWIVv@^eZ{GV}BD5;KcZi(^tV
zb+b}SD|Ay)#V5aH^kMqJFxi~xg?0&N4SO?V4MRK^gcZ!7$?Er#nSp_!h>?MT;UyCT
z1A`{xE#~~9l+EGHDU6I<oA<EjFe<+U$!c;GaWF72+~O?CFNrTnOv*_u5&`LC0}(=-
Px!I%`8HFaRv4;WxEQv@t

delta 172
zcmZ3(|C^83iI<m)fq{WR)6y{R@J8M(j2gd;T&!YT@{>z*Q}arSL9BS^;22lW_}~zu
z7-JVdN8Q}S;*!*&$?8l#Obm>ZOPOBCq_CE7*047-N;A|j#B(8d!3>&glM9)}Szj_T
zFfeTHU`}CV<lFp~MTb$jNC;#rM-c}D1H&!OqWqHhlEkE()FM#^28JRw5FxzThE0l*
KQFwAVdnf=1h%4d%

diff --git a/algogenetique.py b/algogenetique.py
index a2c977b..7726e23 100644
--- a/algogenetique.py
+++ b/algogenetique.py
@@ -8,32 +8,59 @@ import croisement
 from Traj3D import *
 from random import random
 import matplotlib.pyplot as plt
+import time 
 
+# Debut du decompte du temps
+start_time = time.time()
 
 
-def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
-    '''lineList = [line.rstrip('\n') for line in open(brin)]
-	brin = ''.join(lineList[1:])'''
+
+def main(N,tmax,pmutation, proportion):
     L=[]
+    lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
+    brin = ''.join(lineList[1:])
     People=Population(N)
+    S1=[]
+    for individu in People.indiv:
+        individu.evaluate(brin)
+        S1.append(int(individu.score))
+    maximum=int(max(S1))
     for i in range(tmax):
         print(i)
-        max=0
-        best=None
+        mini=People.indiv[0].score
+        best=People.indiv[0]
         People.reproduction(p = proportion, proba_mutation= pmutation)
         for individu in People.indiv:
-            if individu.score>max:
+            if individu.score<mini:
                 best=individu
-                max=individu.score
-        L.append(max)
+                mini=individu.score
+        L.append(mini)
 
+    plt.subplot(221)
     plt.plot([i for i in range(tmax)], L)
+    
+
+    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)
+
+
+    plt.subplot(224)
+    plt.hist(S2, range = (0,maximum+10), bins = 20, color = 'blue')
     plt.show()
-    return(best,People)
+   
 
+    return(best,People)
 
-best,People = main(100,100,0.01,50)
+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("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA", best.table)
+test.compute(brin, best.table)
 test.draw("first_plot")
 
+
+# Affichage du temps d execution
+print("Temps d'execution : %s secondes " % (time.time() - start_time))
diff --git a/individu.py b/individu.py
index 2419381..20958d3 100644
--- a/individu.py
+++ b/individu.py
@@ -37,9 +37,9 @@ class Individu():
                 list_distance += [distance_first_nuc, distance_last_nuc]
 
 
-        self.score = 1/max(list_distance)
+        self.score = max(list_distance)
 
-        return 1/max(list_distance)
+        return max(list_distance)
 
 
     def mutation(self, proba = P1):
diff --git a/population.py b/population.py
index 828caac..104f66b 100644
--- a/population.py
+++ b/population.py
@@ -67,7 +67,7 @@ class Population:
             p = (self.n)//2
         meilleur = self.indiv[0]
         for individu in self.indiv :
-            if meilleur.score < individu.score:
+            if meilleur.score > individu.score:
                 print("meilleur, individu: ", meilleur.score, individu.score)
                 meilleur = individu
         newself = [meilleur]
@@ -83,7 +83,7 @@ class Population:
             
             x=self.indiv[m]
             y=self.indiv[t]
-            if x.score>=y.score:
+            if x.score<y.score:
                 newself.append(x)
             else:
                 newself.append(y)
@@ -167,8 +167,10 @@ class Population:
             y=copy.deepcopy(newself[t])
             couple_enfant = enfant(x,y)
             for child in couple_enfant :
+                lineList = [line.rstrip('\n') for line in open("plasmid_8k.fasta")]
+                brin = ''.join(lineList[1:])
                 child.mutation(proba_mutation)
-                child.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
+                child.evaluate(brin)
             newself.append(couple_enfant[0])
             newself.append(couple_enfant[1])
         self = self.modifier_population(newself)
-- 
GitLab