Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alexander R. Hankin
EE194_Manduca_Simulator
Commits
d152a587
Commit
d152a587
authored
May 02, 2018
by
David A.. Werner
Browse files
Population.update_fitness now uses multithreading.Pool if there is one
parent
fe860006
Changes
1
Hide whitespace changes
Inline
Side-by-side
manduca/Population.py
View file @
d152a587
...
...
@@ -180,4 +180,13 @@ class EvolutionSimulator(object):
def
update_fitness
(
self
):
all_manducas
=
self
.
population
+
self
.
_children
+
self
.
_mutants
[
manduca
.
fitness
for
manduca
in
all_manducas
]
if
self
.
pool
is
not
None
:
# Don't bother sending manducas that already have _fitness saved
all_manducas
=
filter
(
lambda
m
:
m
.
_fitness
is
None
,
all_manducas
)
for
idx
,
fitness
in
enumerate
(
self
.
pool
.
map
(
compute_fitness
,
all_manducas
)):
all_manducas
[
idx
].
_fitness
=
fitness
else
:
[
manduca
.
fitness
for
manduca
in
all_manducas
]
def
compute_fitness
(
manduca
):
return
manduca
.
fitness
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment