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
9b0ee3ab
Commit
9b0ee3ab
authored
5 years ago
by
Muller Sacha
Browse files
Options
Downloads
Patches
Plain Diff
Correction des fonctions de selection en cours
parent
b16a5f59
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
population.py
+34
-28
34 additions, 28 deletions
population.py
with
34 additions
and
28 deletions
population.py
+
34
−
28
View file @
9b0ee3ab
...
...
@@ -24,9 +24,9 @@ class Population:
t
=
None
#méthode des duels pondérée: si x=10 et y=1, y a une chance sur 11 de passer
while
len
(
newself
)
<
p
:
while
m
in
vu
:
m
=
randrange
(
0
,
len
(
self
)
)
m
=
randrange
(
0
,
self
.
n
)
while
t
in
vu
:
t
=
randrange
(
0
,
len
(
self
)
)
t
=
randrange
(
0
,
self
.
n
)
x
=
self
.
indiv
[
m
]
y
=
self
.
indiv
[
t
]
vu
.
add
(
t
)
...
...
@@ -48,9 +48,11 @@ class Population:
m
=
None
while
len
(
newself
)
<
p
:
while
m
in
vu
:
m
=
randrange
(
0
,
len
(
self
))
print
(
"
self.n
"
,
self
.
n
)
m
=
randrange
(
0
,
self
.
n
)
while
t
in
vu
:
t
=
randrange
(
0
,
len
(
self
))
print
(
"
self.n
"
,
self
.
n
)
t
=
randrange
(
0
,
self
.
n
)
x
=
self
.
indiv
[
m
]
y
=
self
.
indiv
[
t
]
vu
.
add
(
t
)
...
...
@@ -113,44 +115,48 @@ class Population:
for
indiv
in
self
.
indiv
:
somme
=
somme
+
indiv
.
score
while
len
(
newself
)
<
p
:
m
=
m
=
randrange
(
0
,
len
(
self
)
)
m
=
m
=
randrange
(
0
,
self
.
n
)
x
=
self
.
indiv
[
m
]
p
=
random
(
0
,
1
)
if
p
<=
x
.
score
/
somme
:
newself
.
append
(
x
)
self
=
self
.
modifier_population
(
newself
)
def
reproduction
(
self
,
selection
=
selection_duel
,
enfant
=
croisement_un_point
,
p
=
None
):
def
reproduction
(
self
,
selection
=
None
,
enfant
=
croisement_un_point
,
p
=
None
):
if
selection
==
None
:
selection
=
self
.
selection_duel
if
p
==
None
:
p
=
(
self
.
n
)
//
2
newself
=
selection
(
self
,
p
)
while
len
(
newself
)
<
self
.
n
:
m
=
randrange
(
0
,
len
(
newself
))
t
=
randrange
(
0
,
len
(
newself
))
vieille_taille
=
self
.
n
selection
(
p
)
newself
=
list
(
self
.
indiv
)
while
len
(
newself
)
<
vieille_taille
:
m
=
randrange
(
0
,
self
.
n
)
t
=
randrange
(
0
,
self
.
n
)
x
=
newself
[
m
]
y
=
newself
[
t
]
newself
.
append
(
enfant
(
x
,
y
))
self
=
self
.
modifier_population
(
newself
)
#
def afficher(popu):
#
for individu in popu.indiv :
#
print("\n individu \n")
#
print(individu.table.rot_table)
def
afficher
(
popu
):
for
individu
in
popu
.
indiv
:
print
(
"
\n
individu
\n
"
)
print
(
individu
.
table
.
rot_table
)
#
def test():
#
popu = Population(4)
#
print("\n POPULATION INITIALE \n")
#
for individu in popu.indiv :
#
individu.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
#
afficher(popu)
#
popu.selection_par_rang()
#
print("\n SELECTION PAR RANG \n")
#
afficher(popu)
#
popu.indiv =
popu.reproduction()
#
print("\n REPRODUCTION \n")
#
afficher(popu)
#
test()
def
test
():
popu
=
Population
(
4
)
print
(
"
\n
POPULATION INITIALE
\n
"
)
for
individu
in
popu
.
indiv
:
individu
.
evaluate
(
"
AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA
"
)
afficher
(
popu
)
#
popu.selection_par_rang()
#
print("\n SELECTION PAR RANG \n")
#
afficher(popu)
popu
.
reproduction
()
print
(
"
\n
REPRODUCTION
\n
"
)
afficher
(
popu
)
test
()
...
...
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