Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EI Jeux Evolutionnaires
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Santos Garcia Carlos
EI Jeux Evolutionnaires
Commits
75a31e9c
Commit
75a31e9c
authored
5 years ago
by
Santos Garcia Carlos
Browse files
Options
Downloads
Patches
Plain Diff
maximiser distance, plot des scores debut et fin
parent
da5163c0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
algogenetique.py
+41
-12
41 additions, 12 deletions
algogenetique.py
individu.py
+3
-3
3 additions, 3 deletions
individu.py
population.py
+6
-7
6 additions, 7 deletions
population.py
with
50 additions
and
22 deletions
algogenetique.py
+
41
−
12
View file @
75a31e9c
...
...
@@ -8,32 +8,61 @@ 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
))
print
(
S1
)
maximo
=
int
(
max
(
S1
))
print
(
maximo
)
for
i
in
range
(
tmax
):
print
(
i
)
m
ax
=
0
best
=
None
m
ini
=
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
)
#print(L)
plt
.
subplot
(
221
)
plt
.
plot
([
i
for
i
in
range
(
tmax
)],
L
)
plt
.
subplot
(
223
)
plt
.
hist
(
S1
,
range
=
(
0
,
maximo
+
10
),
bins
=
20
,
color
=
'
red
'
)
S2
=
[
individu
.
score
for
individu
in
People
.
indiv
]
print
(
S2
)
print
(
"
Score final:
"
,
best
.
score
)
plt
.
subplot
(
224
)
plt
.
hist
(
S2
,
range
=
(
0
,
maximo
+
10
),
bins
=
20
,
color
=
'
blue
'
)
plt
.
show
()
return
(
best
)
#
main(1
00
,10
0
,0.0
1
,5
0
)
main
(
1
5
,
10
,
0.0
05
,
5
)
'''
lineList = [line.rstrip(
'
\n
'
) for line in open(
"
plasmid_8k.fasta
"
)]
brin =
''
.join(lineList[1:])
print
(
brin
)
\ No newline at end of file
print(brin)
'''
# Affichage du temps d execution
print
(
"
Temps d
'
execution : %s secondes
"
%
(
time
.
time
()
-
start_time
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
individu.py
+
3
−
3
View file @
75a31e9c
...
...
@@ -12,7 +12,7 @@ class Individu():
lineList
=
[
line
.
rstrip
(
'
\n
'
)
for
line
in
open
(
"
plasmid_8k.fasta
"
)]
brin
=
''
.
join
(
lineList
[
1
:])
self
.
table
=
table
self
.
score
=
self
.
evaluate
(
br
in
)
self
.
score
=
in
f
def
evaluate
(
self
,
brin
):
traj
=
Traj3D
()
...
...
@@ -39,9 +39,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
):
...
...
This diff is collapsed.
Click to expand it.
population.py
+
6
−
7
View file @
75a31e9c
...
...
@@ -3,6 +3,7 @@ from random import *
from
individu
import
Individu
from
RotTable
import
RotTable
from
croisement
import
croisement_un_point
,
croisement_deux_points
import
copy
class
Population
:
def
__init__
(
self
,
n
):
...
...
@@ -63,8 +64,8 @@ class Population:
p
=
(
self
.
n
)
//
2
meilleur
=
self
.
indiv
[
0
]
for
individu
in
self
.
indiv
:
if
meilleur
.
score
<
individu
.
score
:
print
(
"
meilleur, individu:
"
,
meilleur
.
score
,
individu
.
score
)
if
meilleur
.
score
>
individu
.
score
:
#
print("meilleur, individu: ", meilleur.score, individu.score)
meilleur
=
individu
newself
=
[
meilleur
]
vu
=
set
()
...
...
@@ -79,12 +80,10 @@ 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
)
for
i
in
range
(
0
,
len
(
newself
)):
print
(
newself
[
i
].
score
)
self
=
self
.
modifier_population
(
newself
)
...
...
@@ -161,8 +160,8 @@ class Population:
while
len
(
newself
)
<
vieille_taille
:
m
=
randrange
(
0
,
self
.
n
)
t
=
randrange
(
0
,
self
.
n
)
x
=
newself
[
m
]
y
=
newself
[
t
]
x
=
copy
.
deepcopy
(
newself
[
m
]
)
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
"
)]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment