Commit f47a387a authored by David A.. Werner's avatar David A.. Werner
Browse files

Removed single threaded code from try/finally

parent ce391700
......@@ -3,18 +3,17 @@ EE194_Manduca_Simulator package with multithreading support"""
import multiprocessing
from manduca import SimpleManduca, EvolutionSimulator
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)
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()
print simulator.history[-1]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment