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
a7eeb77d
Commit
a7eeb77d
authored
5 years ago
by
Muller Sacha
Browse files
Options
Downloads
Patches
Plain Diff
creation de la fonction mutation et correction de RotTable et individu.py
parent
e65fba6d
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
RotTable.py
+5
-5
5 additions, 5 deletions
RotTable.py
individu.py
+22
-11
22 additions, 11 deletions
individu.py
with
27 additions
and
16 deletions
RotTable.py
+
5
−
5
View file @
a7eeb77d
...
...
@@ -25,23 +25,23 @@ class RotTable:
}
def
__init__
(
self
):
self
.
R
ot_
T
able
=
{}
self
.
r
ot_
t
able
=
{}
for
dinucleotide
in
RotTable
.
__ORIGINAL_ROT_TABLE
:
self
.
R
ot_
T
able
[
dinucleotide
]
=
RotTable
.
__ORIGINAL_ROT_TABLE
[
dinucleotide
][:
3
]
self
.
r
ot_
t
able
[
dinucleotide
]
=
RotTable
.
__ORIGINAL_ROT_TABLE
[
dinucleotide
][:
3
]
self
.
alea
()
def
alea
(
self
):
for
dinucleotide
in
RotTable
.
__ORIGINAL_ROT_TABLE
:
for
i
in
range
(
2
):
self
.
R
ot_
T
able
[
dinucleotide
][
i
]
+=
numpy
.
random
.
uniform
(
low
=
-
RotTable
.
__ORIGINAL_ROT_TABLE
[
dinucleotide
][
i
+
3
],
high
=
RotTable
.
__ORIGINAL_ROT_TABLE
[
dinucleotide
][
i
+
3
])
self
.
r
ot_
t
able
[
dinucleotide
][
i
]
+=
numpy
.
random
.
uniform
(
low
=
-
RotTable
.
__ORIGINAL_ROT_TABLE
[
dinucleotide
][
i
+
3
],
high
=
RotTable
.
__ORIGINAL_ROT_TABLE
[
dinucleotide
][
i
+
3
])
###################
# WRITING METHODS #
###################
#table = RotTable()
#table.
__R
ot_
T
able["AA"] --> [35.62, 7.2, -154]
#table.
r
ot_
t
able["AA"] --> [35.62, 7.2, -154]
###################
# READING METHODS #
...
...
@@ -59,4 +59,4 @@ class RotTable:
###################
table1
=
RotTable
()
print
(
table1
.
R
ot_
T
able
[
"
AA
"
])
print
(
table1
.
r
ot_
t
able
[
"
AA
"
])
This diff is collapsed.
Click to expand it.
individu.py
+
22
−
11
View file @
a7eeb77d
from
Initialisation
import
table_rotation
from
RotTable
import
RotTable
from
Traj3D
import
*
import
numpy
as
np
from
math
import
sqrt
from
random
import
random
P1
=
0.015
class
Individu
():
def
__init__
(
self
,
rot_
table
):
self
.
rot_
table
=
rot_
table
def
__init__
(
self
,
table
):
self
.
table
=
table
self
.
score
=
None
def
evaluate
(
self
,
brin
):
traj
=
Traj3D
()
traj
.
compute
(
brin
,
self
.
rot_
table
)
traj
.
compute
(
brin
,
self
.
table
)
traj_array
=
np
.
array
(
traj
.
getTraj
())
first_nucleotide
=
traj_array
[
0
,
:]
...
...
@@ -21,16 +24,24 @@ class Individu():
first_name
=
brin
[
0
]
last_name
=
brin
[
-
1
]
rot_computed
=
self
.
rot_
table
[
last_name
+
first_name
]
rot_computed
=
self
.
table
[
last_name
+
first_name
]
rot_traj
=
first_name
-
last_name
diff_angle
=
sum
(
abs
(
rot_computed
-
rot_traj
))
self
.
score
=
1
/
(
distance
+
diff_angle
)
# def mutation(self):
# return mutation
individu1
=
Individu
(
table_rotation
())
print
(
individu1
.
rot_table
.
dict
[
"
AA
"
].
x
)
\ No newline at end of file
def
mutation
(
self
,
proba
=
P1
):
table_rotations
=
self
.
table
.
rot_table
for
doublet
in
table_rotations
:
for
coord
in
range
(
3
):
tir
=
random
()
if
tir
<
proba
:
print
(
"
mutation
"
,
doublet
,
coord
)
print
(
"
table
"
,
table_rotations
[
doublet
][
coord
])
table_rotations
[
doublet
][
coord
]
=
np
.
random
.
uniform
(
low
=
self
.
table
.
__ORIGINAL_ROT_TABLE
[
doublet
][
coord
]
-
self
.
table
.
__ORIGINAL_ROT_TABLE
[
doublet
][
coord
+
3
],
high
=
self
.
table
.
__ORIGINAL_ROT_TABLE
[
doublet
][
coord
]
+
self
.
table
.
__ORIGINAL_ROT_TABLE
[
doublet
][
coord
+
3
])
print
(
"
table
"
,
table_rotations
[
doublet
][
coord
])
individu1
=
Individu
(
RotTable
())
print
(
individu1
.
table
.
rot_table
)
individu1
.
mutation
()
\ No newline at end of file
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