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_Demo
Commits
ce391700
Commit
ce391700
authored
May 02, 2018
by
David A.. Werner
Browse files
Added example script that uses multithreading to speed up simulation
parent
215b1653
Changes
1
Hide whitespace changes
Inline
Side-by-side
simulation_with_pool.py
0 → 100644
View file @
ce391700
""" This is a script that generates the basic functionality of the
EE194_Manduca_Simulator package with multithreading support"""
import
multiprocessing
from
manduca
import
SimpleManduca
,
EvolutionSimulator
try
:
pool
=
multiprocessing
.
Pool
(
int
(
0.9
*
multiprocessing
.
cpu_count
()))
POPULATION_SIZE
,
NUM_GENERATIONS
=
10
,
25
num_legs
,
time_segments
,
time_step
=
2
,
4
,
10
def
random_manduca
():
return
SimpleManduca
.
random_individual
(
num_legs
,
time_segments
,
time_step
)
simulator
=
EvolutionSimulator
((
random_manduca
,
POPULATION_SIZE
),
pool
=
pool
)
simulator
.
run_simulation
(
NUM_GENERATIONS
)
print
simulator
.
history
[
-
1
]
finally
:
pool
.
close
()
pool
.
join
()
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