Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EI - Jeux Evolu
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Nadin Thibault
EI - Jeux Evolu
Commits
177521ec
Commit
177521ec
authored
2 years ago
by
Boucaut Marius
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of gitlab-student.centralesupelec.fr:yi.zhong/ei
parents
9fbfb29c
1e4de6fb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
3dna/Constantes.py
+8
-3
8 additions, 3 deletions
3dna/Constantes.py
3dna/__main__.py
+65
-27
65 additions, 27 deletions
3dna/__main__.py
with
73 additions
and
30 deletions
3dna/Constantes.py
+
8
−
3
View file @
177521ec
ALPHA
=
3
p
=
0.2
Pm
=
0.3
size
=
64
size
=
32
nb_iter
=
30
AGRANDISSEMENT
=
5
nom_selection
=
"
selection_roulette
"
nom_croisement
=
"
croisement_milieu
"
Symetrique
=
{
"
AA
"
:
"
TT
"
,
"
AC
"
:
"
TG
"
,
"
AG
"
:
"
TC
"
,
"
AT
"
:
None
,
"
TA
"
:
None
,
"
CA
"
:
"
GT
"
,
"
CC
"
:
"
GG
"
,
"
CG
"
:
None
,
"
GC
"
:
None
,
"
CT
"
:
"
GA
"
}
List_of_genes
=
[
"
AA
"
,
"
AC
"
,
"
AG
"
,
"
AT
"
,
<<<<<<<
HEAD
"
TA
"
,
"
CA
"
,
"
CC
"
,
"
CG
"
,
"
GC
"
,
"
CT
"
]
#les gènes à modifier
Symetrique
=
{
"
AA
"
:
"
TT
"
,
"
AC
"
:
"
TG
"
,
"
AG
"
:
"
TC
"
,
"
AT
"
:
None
,
"
TA
"
:
None
,
"
CA
"
:
"
GT
"
,
"
CC
"
:
"
GG
"
,
"
CG
"
:
None
,
"
GC
"
:
None
,
"
CT
"
:
"
GA
"
}
#les symétriques de ces gènes
=======
"
TA
"
,
"
CA
"
,
"
CC
"
,
"
CG
"
,
"
GC
"
,
"
CT
"
]
pas
=
10
>>>>>>>
226
c2ce36132e35dbdd4a7ab4930dc5268002c36
This diff is collapsed.
Click to expand it.
3dna/__main__.py
+
65
−
27
View file @
177521ec
...
...
@@ -29,21 +29,21 @@ def tests_croisements():
popu2
=
Population
(
size
)
popu2
.
troupeau
=
popu1
.
troupeau
.
copy
()
popu3
=
Population
(
size
)
popu3
.
troupeau
=
popu
2
.
troupeau
.
copy
()
popu3
.
troupeau
=
popu
1
.
troupeau
.
copy
()
for
i
in
range
(
nb_iter
):
print
(
i
)
_
,
value
=
popu1
.
meilleur
_distance
(
seq
)
D_un
.
append
(
value
)
_
,
value
=
popu1
.
meilleur
(
seq
)
D_un
.
append
(
math
.
sqrt
(
value
)
)
popu1
.
iteration
(
seq
,
nom_selection
,
"
croisement_en_un_point
"
)
for
i
in
range
(
nb_iter
):
print
(
i
)
_
,
value
=
popu2
.
meilleur
_distance
(
seq
)
D_deux
.
append
(
value
)
_
,
value
=
popu2
.
meilleur
(
seq
)
D_deux
.
append
(
math
.
sqrt
(
value
)
)
popu2
.
iteration
(
seq
,
nom_selection
,
"
croisement_en_deux_points
"
)
for
i
in
range
(
nb_iter
):
print
(
i
)
_
,
value
=
popu3
.
meilleur
_distance
(
seq
)
D_milieu
.
append
(
value
)
_
,
value
=
popu3
.
meilleur
(
seq
)
D_milieu
.
append
(
math
.
sqrt
(
value
)
)
popu3
.
iteration
(
seq
,
nom_selection
,
"
croisement_milieu
"
)
plt
.
clf
()
plt
.
plot
(
N
,
D_un
,
label
=
'
un
'
)
...
...
@@ -56,7 +56,6 @@ def tests_croisements():
plt
.
legend
()
plt
.
show
()
plt
.
savefig
(
"
tests_croisements.png
"
)
# plt.close()
def
tests_selection
():
...
...
@@ -75,21 +74,21 @@ def tests_selection():
popu2
=
Population
(
size
)
popu2
.
troupeau
=
popu1
.
troupeau
.
copy
()
popu3
=
Population
(
size
)
popu3
.
troupeau
=
popu
2
.
troupeau
.
copy
()
popu3
.
troupeau
=
popu
1
.
troupeau
.
copy
()
for
i
in
range
(
nb_iter
):
print
(
i
)
_
,
value
=
popu1
.
meilleur
_distance
(
seq
)
D_un
.
append
(
value
)
_
,
value
=
popu1
.
meilleur
(
seq
)
D_un
.
append
(
math
.
sqrt
(
value
)
)
popu1
.
iteration
(
seq
,
"
selection_roulette
"
,
nom_croisement
)
for
i
in
range
(
nb_iter
):
print
(
i
)
_
,
value
=
popu2
.
meilleur
_distance
(
seq
)
D_deux
.
append
(
value
)
_
,
value
=
popu2
.
meilleur
(
seq
)
D_deux
.
append
(
math
.
sqrt
(
value
)
)
popu2
.
iteration
(
seq
,
"
selection_elitisme
"
,
nom_croisement
)
for
i
in
range
(
nb_iter
):
print
(
i
)
_
,
value
=
popu3
.
meilleur
_distance
(
seq
)
D_milieu
.
append
(
value
)
_
,
value
=
popu3
.
meilleur
(
seq
)
D_milieu
.
append
(
math
.
sqrt
(
value
)
)
popu3
.
iteration
(
seq
,
"
selection_tournoi
"
,
nom_croisement
)
plt
.
clf
()
plt
.
plot
(
N
,
D_un
,
label
=
'
selection_roulette
'
)
...
...
@@ -102,7 +101,6 @@ def tests_selection():
plt
.
legend
()
plt
.
show
()
plt
.
savefig
(
"
selection_methodes.png
"
)
# plt.close()
def
test_opt
():
...
...
@@ -118,9 +116,9 @@ def test_opt():
popu
=
Population
(
size
)
popu
.
make_evolution_opt
(
seq
,
nom_selection
,
nom_croisement
,
eps
=
1
)
final_tab
,
value
=
popu
.
meilleur
_distance
(
seq
)
final_tab
,
value
=
popu
.
meilleur
(
seq
)
final_tab
.
exportation
()
print
(
value
,
"
(distance optimisée)
"
)
print
(
math
.
sqrt
(
value
)
,
"
(distance optimisée)
"
)
rot_init
=
RotTable
(
randomize
=
False
)
print
(
math
.
sqrt
(
rot_init
.
evaluate
(
seq
)),
"
(distance de base)
"
)
...
...
@@ -135,6 +133,46 @@ def test_opt():
print
(
"
time :
"
,
time
.
time
()
-
time0
)
def
generation
():
time0
=
time
.
time
()
gen
=
[
i
for
i
in
range
(
1
,
nb_iter
+
1
)]
moy
=
[]
meilleur
=
[]
rot_table
=
RotTable
()
traj_final
=
Traj3D
()
# Read file
lineList
=
[
line
.
rstrip
(
'
\n
'
)
for
line
in
open
(
args
.
filename
)]
# Formatting
seq
=
''
.
join
(
lineList
[
1
:])
popu
=
Population
(
size
)
for
j
in
range
(
nb_iter
):
popu
.
iteration
(
seq
,
nom_selection
,
nom_croisement
)
final_tab
,
value
=
popu
.
meilleur
(
seq
)
moy
.
append
(
popu
.
evaluate_moyenne
(
seq
))
meilleur
.
append
(
value
)
print
(
final_tab
.
distance
(
seq
),
"
(distance optimisée)
"
)
print
(
rot_table
.
distance
(
seq
),
"
(distance de base)
"
)
traj_final
.
compute
(
seq
,
final_tab
)
traj_final
.
draw
(
str
(
int
(
final_tab
.
distance
(
seq
))))
traj_final
.
write
(
"
data/traj_final.png
"
)
print
(
"
time :
"
,
time
.
time
()
-
time0
)
plt
.
figure
(
5
)
plt
.
plot
(
gen
,
moy
,
label
=
'
moyenne
'
)
plt
.
plot
(
gen
,
meilleur
,
label
=
"
meilleur
"
)
plt
.
xlabel
(
'
génration
'
)
plt
.
ylabel
(
'
distance (log)
'
)
plt
.
yscale
(
'
log
'
)
plt
.
legend
()
plt
.
savefig
(
'
data/evo.png
'
)
def
main
():
time0
=
time
.
time
()
...
...
@@ -150,8 +188,9 @@ def main():
popu
=
Population
(
size
)
popu
.
make_evolution_iter
(
seq
,
nom_selection
,
nom_croisement
,
nb_iter
)
final_tab
,
value
=
popu
.
meilleur_distance
(
seq
)
final_tab
.
exportation
()
final_tab
,
value
=
popu
.
meilleur
(
seq
)
print
(
final_tab
.
distance
(
seq
),
"
(distance optimisée)
"
)
rot_init
=
RotTable
(
randomize
=
False
)
print
(
rot_init
.
distance
(
seq
),
"
(distance de base)
"
)
...
...
@@ -167,10 +206,8 @@ def main():
traj
.
write
(
args
.
filename
+
"
.png
"
)
traj_final
.
draw
(
str
(
int
(
final_tab
.
distance
(
seq
))))
traj_final
.
write
(
"
data/traj_final.png
"
)
traj_final2
.
draw
(
str
(
int
(
math
.
sqrt
(
final_tab
.
evaluate
(
seq2
)))))
traj_final2
.
draw
(
str
(
int
(
math
.
sqrt
(
final_tab
.
distance
(
seq2
)))))
traj_final2
.
write
(
"
data/traj_final2.png
"
)
print
(
"
time :
"
,
time
.
time
()
-
time0
)
def
evolution_fitness
():
#evolution de la fitness au cours de l'évaluation
...
...
@@ -200,7 +237,7 @@ def evolution_fitness():#evolution de la fitness au cours de l'évaluation
plt
.
savefig
(
"
fitness au cours de l
'
evo.png
"
)
#plt.close()
def
evolution_
fitness
():
#evolution de la fitness au cours de l'évaluation
def
fitness
_size
():
#evolution de la fitness au cours de l'évaluation
D
=
[]
S
=
[
int
(
1.5
**
i
+
10
)
for
i
in
range
(
10
)]
...
...
@@ -230,14 +267,15 @@ def evolution_fitness():#evolution de la fitness au cours de l'évaluation
plt
.
grid
()
plt
.
legend
()
plt
.
show
()
plt
.
savefig
(
"
fitness au cours de l
'
evo
.png
"
)
plt
.
savefig
(
"
distance et size
.png
"
)
#plt.close()
if
__name__
==
"
__main__
"
:
main
()
evolution_fitness
()
'''
fitness_size()
main()
test_opt()
evolution_fitness()
tests_croisements()
tests_selection()
'''
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