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
379da9f1
Commit
379da9f1
authored
2 years ago
by
Nadin Thibault
Browse files
Options
Downloads
Patches
Plain Diff
modif
parent
e044eb81
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
3dna/Population.py
+4
-0
4 additions, 0 deletions
3dna/Population.py
3dna/RotTable.py
+15
-4
15 additions, 4 deletions
3dna/RotTable.py
3dna/__main__.py
+10
-10
10 additions, 10 deletions
3dna/__main__.py
with
29 additions
and
14 deletions
3dna/Population.py
+
4
−
0
View file @
379da9f1
...
...
@@ -56,6 +56,10 @@ class Population:
score
=
scoreprovisoire
m
=
x
return
m
,
score
def
meilleur_distance_angle
(
self
,
molecule
):
m
,
_
=
self
.
meilleur
(
self
,
molecule
)
return
m
,
m
.
distance
(
molecule
),
m
.
angle
(
molecule
)
def
evaluate_moyenne
(
self
,
molecule
):
score
=
0
...
...
This diff is collapsed.
Click to expand it.
3dna/RotTable.py
+
15
−
4
View file @
379da9f1
...
...
@@ -83,20 +83,31 @@ class RotTable:
self
.
dist_carre
=
(
xf
-
x0
)
**
2
+
(
yf
-
y0
)
**
2
+
(
zf
-
z0
)
**
2
return
math
.
sqrt
(
self
.
dist_carre
)
def
evaluate
(
self
,
molecule
):
# renvoie la distance au carrée séparant les deux extrémités de la molecule telle que générée par la table self
def
angle
(
self
,
molecule
):
traj
=
Traj3D
(
False
)
traj
.
compute
(
molecule
+
molecule
[:
AGRANDISSEMENT
],
self
)
X
=
traj
.
getTraj
()[
0
]
Y
=
traj
.
getTraj
()[
1
]
Z
=
traj
.
getTraj
()[
-
2
]
T
=
traj
.
getTraj
()[
-
1
]
def
prod_scalaire
(
X
,
Y
,
Z
,
T
):
s
=
0
for
i
in
range
(
3
):
s
+=
(
Y
[
i
]
-
X
[
i
])
*
(
T
[
i
]
-
Z
[
i
])
return
s
def
evaluate
(
self
,
molecule
):
def
norme
(
X
,
Y
):
s
=
0
for
i
in
range
(
3
):
s
+=
(
Y
[
i
]
-
X
[
i
])
**
2
return
s
return
math
.
acos
(
prod_scalaire
(
X
,
Y
,
Z
,
T
)
/
(
norme
(
X
,
Y
)
*
norme
(
Z
,
T
)))
def
evaluate
(
self
,
molecule
):
# renvoie la distance au carrée séparant les deux extrémités de la molecule telle que générée par la table self
def
prod_scalaire
(
X
,
Y
,
Z
,
T
):
s
=
0
for
i
in
range
(
3
):
s
+=
(
Y
[
i
]
-
X
[
i
])
*
(
T
[
i
]
-
Z
[
i
])
return
s
traj
=
Traj3D
(
False
)
traj
.
compute
(
molecule
+
molecule
[:
AGRANDISSEMENT
],
self
)
...
...
This diff is collapsed.
Click to expand it.
3dna/__main__.py
+
10
−
10
View file @
379da9f1
...
...
@@ -134,7 +134,7 @@ def tests_selection_size():
plt
.
plot
(
N
,
D_deux
,
label
=
'
selection_elitisme
'
)
plt
.
plot
(
N
,
D_milieu
,
label
=
'
selection_tournoi
'
)
plt
.
yscale
(
'
log
'
)
plt
.
xlabel
(
"
Iteration
"
)
plt
.
xlabel
(
"
Size
"
)
plt
.
ylabel
(
"
Distance
"
)
plt
.
grid
()
plt
.
legend
()
...
...
@@ -169,16 +169,16 @@ def tests_croisements_size():
D_deux
.
append
(
value2
)
D_milieu
.
append
(
value3
)
plt
.
clf
()
plt
.
plot
(
N
,
D_un
,
label
=
'
selection_roulette
'
)
plt
.
plot
(
N
,
D_deux
,
label
=
'
selection_elitisme
'
)
plt
.
plot
(
N
,
D_milieu
,
label
=
'
selection_tournoi
'
)
plt
.
plot
(
N
,
D_un
,
label
=
'
croisement_en_un_point
'
)
plt
.
plot
(
N
,
D_deux
,
label
=
'
croisement_en_deux_points
'
)
plt
.
plot
(
N
,
D_milieu
,
label
=
'
croisement_milieu
'
)
plt
.
yscale
(
'
log
'
)
plt
.
xlabel
(
"
Iteration
"
)
plt
.
xlabel
(
"
Size
"
)
plt
.
ylabel
(
"
Distance
"
)
plt
.
grid
()
plt
.
legend
()
plt
.
show
()
plt
.
savefig
(
"
selection
_methodes_size.png
"
)
plt
.
savefig
(
"
croisement
_methodes_size.png
"
)
def
test_opt
():
time0
=
time
.
time
()
...
...
@@ -271,8 +271,8 @@ def main():
popu
.
make_evolution_iter
(
seq
,
nom_selection
,
nom_croisement
,
nb_iter
)
final_tab
,
value
=
popu
.
meilleur
(
seq
)
print
(
final_tab
.
distance
(
seq
),
"
(distance optimisée)
"
)
print
(
final_tab
.
angle
(
seq
),
"
(angle optimisée)
"
)
rot_init
=
RotTable
(
randomize
=
False
)
print
(
rot_init
.
distance
(
seq
),
"
(distance de base)
"
)
...
...
@@ -359,10 +359,10 @@ def fitness_size(): # evolution de la fitness au cours de l'évaluation
if
__name__
==
"
__main__
"
:
evolution_fitness
()
tests_selection_size
()
'''
fitness_size()
main()
test_opt()
tests_croisements()
tests_selection()
...
...
@@ -371,4 +371,4 @@ if __name__ == "__main__":
tests_croisements_size()
'''
# generation()
main
()
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