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
6e66e365
Commit
6e66e365
authored
5 years ago
by
Kappes Marques Rodrigo
Browse files
Options
Downloads
Patches
Plain Diff
cleaned a bit the main code
parent
6f6a45c8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
algogenetique.py
+16
-5
16 additions, 5 deletions
algogenetique.py
with
16 additions
and
5 deletions
algogenetique.py
+
16
−
5
View file @
6e66e365
...
...
@@ -10,38 +10,50 @@ from random import random
import
matplotlib.pyplot
as
plt
import
time
#
Debut du decompte du temps
#
Start of the time counting
start_time
=
time
.
time
()
def
main
(
N
,
tmax
,
pmutation
,
proportion
):
#Setting up initial variables
L
=
[]
lineList
=
[
line
.
rstrip
(
'
\n
'
)
for
line
in
open
(
"
plasmid_8k.fasta
"
)]
brin
=
''
.
join
(
lineList
[
1
:])
#Creation of the initial population
People
=
Population
(
N
)
#Avaliating the initial population
S1
=
[]
for
individu
in
People
.
indiv
:
individu
.
evaluate
()
S1
.
append
(
int
(
individu
.
score
))
maximum
=
int
(
max
(
S1
))
#The main loop of new generations
for
i
in
range
(
tmax
):
mini
=
People
.
indiv
[
0
].
score
best
=
People
.
indiv
[
0
]
People
.
reproduction
(
p
=
proportion
,
proba_mutation
=
pmutation
)
#Searching for the best individual in each generation
for
individu
in
People
.
indiv
:
if
individu
.
score
<
mini
:
best
=
individu
mini
=
individu
.
score
#Printing usefull data (generation average and their best score)
S2
=
[
individu
.
score
for
individu
in
People
.
indiv
]
avg
=
sum
(
S2
)
/
len
(
S2
)
L
.
append
(
mini
)
print
(
i
,
"
avg:
"
,
avg
,
"
best score:
"
,
mini
)
#Plotting all the graphs
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
'
)
...
...
@@ -58,13 +70,12 @@ def main(N,tmax,pmutation, proportion):
return
(
best
,
People
)
#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
(
60
,
60
,
0.05
,
30
)
test
=
Traj3D
()
test
.
compute
(
brin
,
best
.
table
)
test
.
draw
(
"
first_plot
"
)
# Affichage du temps d execution
print
(
"
Temps d
'
execution : %s secondes
"
%
(
time
.
time
()
-
start_time
))
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