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
9fbfb29c
Commit
9fbfb29c
authored
2 years ago
by
Boucaut Marius
Browse files
Options
Downloads
Patches
Plain Diff
envie de nage
parent
d05caf90
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
3dna/Population.py
+12
-10
12 additions, 10 deletions
3dna/Population.py
3dna/RotTable.py
+16
-15
16 additions, 15 deletions
3dna/RotTable.py
with
28 additions
and
25 deletions
3dna/Population.py
+
12
−
10
View file @
9fbfb29c
...
...
@@ -20,7 +20,9 @@ class Population:
def
croisement
(
self
,
nom_croisement
):
n
=
self
.
size
rd
.
shuffle
(
self
.
troupeau
[
1
:])
nuls
=
self
.
troupeau
[
1
:]
rd
.
shuffle
(
nuls
)
self
.
troupeau
[
0
]
+
nuls
# le meilleur reste à la première place pour éviter de le faire muter ensuite
for
k
in
range
(
n
//
2
):
self
.
troupeau
=
self
.
troupeau
+
\
...
...
@@ -46,16 +48,16 @@ class Population:
score
=
scoreprovisoire
m
=
x
return
m
,
score
def
meilleur_distance
(
self
,
molecule
):
score
=
inf
for
x
in
self
.
troupeau
:
scoreprovisoire
=
x
.
distance
(
molecule
)
if
scoreprovisoire
<
score
:
score
=
scoreprovisoire
m
=
x
return
m
,
score
score
=
inf
for
x
in
self
.
troupeau
:
scoreprovisoire
=
x
.
distance
(
molecule
)
if
scoreprovisoire
<
score
:
score
=
scoreprovisoire
m
=
x
return
m
,
score
def
evaluate_moyenne
(
self
,
molecule
):
score
=
0
for
x
in
self
.
troupeau
:
...
...
This diff is collapsed.
Click to expand it.
3dna/RotTable.py
+
16
−
15
View file @
9fbfb29c
...
...
@@ -8,6 +8,7 @@ from .Constantes import *
import
math
here
=
os_path
.
abspath
(
os_path
.
dirname
(
__file__
))
class
RotTable
:
"""
Represents a rotation table
"""
...
...
@@ -95,8 +96,8 @@ class RotTable:
xf
=
traj
.
getTraj
()[
n
-
AGRANDISSEMENT
+
i
][
0
]
yf
=
traj
.
getTraj
()[
n
-
AGRANDISSEMENT
+
i
][
1
]
zf
=
traj
.
getTraj
()[
n
-
AGRANDISSEMENT
+
i
][
2
]
res
=
res
+
(
xf
-
x0
)
**
2
+
(
yf
-
y0
)
**
2
+
(
zf
-
z0
)
**
2
return
res
res
=
res
+
(
(
xf
-
x0
)
**
2
+
(
yf
-
y0
)
**
2
+
(
zf
-
z0
)
**
2
)
**
(
1
/
2
)
return
res
/
AGRANDISSEMENT
def
evaluate2
(
self
,
molecule
):
n
=
len
(
molecule
)
...
...
@@ -105,7 +106,7 @@ class RotTable:
i
=
rd
.
randint
(
1
,
n
)
newmol
=
molecule
[
i
:]
+
molecule
[:
i
]
summ
=
summ
+
self
.
evaluate
(
newmol
)
return
summ
return
summ
/
ALPHA
def
evaluate_partout
(
self
,
molecule
):
traj
=
Traj3D
(
False
)
...
...
@@ -212,26 +213,26 @@ class RotTable:
with
open
(
"
meilleur_table.json
"
,
"
w
"
)
as
outfile
:
json
.
dump
(
self
.
getTable
(),
outfile
)
def
is_good_table
(
self
)
:
for
dinuc
in
List_of_genes
:
if
self
.
getTwist
(
dinuc
)
>
RotTable
.
base_rot_table
[
dinuc
][
0
]
+
RotTable
.
base_rot_table
[
dinuc
][
3
]
:
def
is_good_table
(
self
):
for
dinuc
in
List_of_genes
:
if
self
.
getTwist
(
dinuc
)
>
RotTable
.
base_rot_table
[
dinuc
][
0
]
+
RotTable
.
base_rot_table
[
dinuc
][
3
]:
return
False
if
self
.
getTwist
(
dinuc
)
<
RotTable
.
base_rot_table
[
dinuc
][
0
]
-
RotTable
.
base_rot_table
[
dinuc
][
3
]
:
if
self
.
getTwist
(
dinuc
)
<
RotTable
.
base_rot_table
[
dinuc
][
0
]
-
RotTable
.
base_rot_table
[
dinuc
][
3
]:
return
False
if
self
.
getWedge
(
dinuc
)
>
RotTable
.
base_rot_table
[
dinuc
][
1
]
+
RotTable
.
base_rot_table
[
dinuc
][
4
]
:
if
self
.
getWedge
(
dinuc
)
>
RotTable
.
base_rot_table
[
dinuc
][
1
]
+
RotTable
.
base_rot_table
[
dinuc
][
4
]:
return
False
if
self
.
getWedge
(
dinuc
)
<
RotTable
.
base_rot_table
[
dinuc
][
1
]
-
RotTable
.
base_rot_table
[
dinuc
][
4
]
:
if
self
.
getWedge
(
dinuc
)
<
RotTable
.
base_rot_table
[
dinuc
][
1
]
-
RotTable
.
base_rot_table
[
dinuc
][
4
]:
return
False
if
self
.
getDirection
(
dinuc
)
>
RotTable
.
base_rot_table
[
dinuc
][
2
]
+
RotTable
.
base_rot_table
[
dinuc
][
5
]
:
if
self
.
getDirection
(
dinuc
)
>
RotTable
.
base_rot_table
[
dinuc
][
2
]
+
RotTable
.
base_rot_table
[
dinuc
][
5
]:
return
False
if
self
.
getDirection
(
dinuc
)
<
RotTable
.
base_rot_table
[
dinuc
][
2
]
-
RotTable
.
base_rot_table
[
dinuc
][
5
]
:
if
self
.
getDirection
(
dinuc
)
<
RotTable
.
base_rot_table
[
dinuc
][
2
]
-
RotTable
.
base_rot_table
[
dinuc
][
5
]:
return
False
if
Symetrique
[
dinuc
]
is
not
None
:
if
self
.
getTwist
(
dinuc
)
!=
self
.
getTwist
(
Symetrique
[
dinuc
])
:
if
Symetrique
[
dinuc
]
is
not
None
:
if
self
.
getTwist
(
dinuc
)
!=
self
.
getTwist
(
Symetrique
[
dinuc
]):
return
False
if
self
.
getWedge
(
dinuc
)
!=
self
.
getWedge
(
Symetrique
[
dinuc
])
:
if
self
.
getWedge
(
dinuc
)
!=
self
.
getWedge
(
Symetrique
[
dinuc
]):
return
False
if
self
.
getDirection
(
dinuc
)
!=
self
.
getDirection
(
Symetrique
[
dinuc
])
:
if
self
.
getDirection
(
dinuc
)
!=
self
.
getDirection
(
Symetrique
[
dinuc
]):
return
False
return
True
...
...
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