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

Added new sims with various num-legs as well as using Manduca instead of SimpleManduca!

parent 92c85a13
......@@ -4,7 +4,7 @@ import numpy as np
import pickle
import multiprocessing
import tqdm
from manduca import SimpleManduca, EvolutionSimulator, EvolutionParameters
from manduca import Manduca, SimpleManduca, EvolutionSimulator, EvolutionParameters
POPULATION_SIZE, NUM_GENERATIONS= 100, 200
evolution_parameters = EvolutionParameters(POPULATION_SIZE, 50, 50, 10)
......@@ -12,21 +12,39 @@ num_legs, time_segments, time_step = 5, 10, 10
rng = np.random.RandomState()
rng.seed(0xBAAA)
def random_manduca():
def random_simple_manduca():
return SimpleManduca.random_individual(num_legs, time_segments, time_step, rng=rng)
def random_manduca():
return Manduca.random_individual(num_legs, time_segments, time_step, rng=rng)
histories = []
try:
pool = multiprocessing.Pool(int(multiprocessing.cpu_count()))
for idx,RND_SEED in enumerate(tqdm.tqdm([0xBADC0DE, 0xDEADBEEF, 0xFACEB00C],
desc='70 year simulations', unit='sims')):
simulator = EvolutionSimulator(random_manduca, pool=pool,
simulator = EvolutionSimulator(random_simple_manduca, pool=pool,
evolution_parameters = evolution_parameters,
random_number_generator=rng, random_seed=RND_SEED)
simulator.run_simulation(NUM_GENERATIONS)
histories.append(simulator.history)
simulator.update_fitness()
simulator.population[0].save('fittest_manduca_{}.npz'.format(idx))
# Run a simulation with other number of legs
for num_legs in [2,3,7]:
simulator = EvolutionSimulator(random_simple_manduca, pool=pool,
evolution_parameters = evolution_parameters,
random_number_generator=rng, random_seed=num_legs)
simulator.run_simulation(NUM_GENERATIONS)
simulator.update_fitness()
simulator.population[0].save('fittest_manduca_legs_{}.npz'.format(num_legs))
simulator = EvolutionSimulator(random_manduca, pool=pool,
evolution_parameters = evolution_parameters,
random_number_generator=rng, random_seed=0xBAD)
simulator.run_simulation(NUM_GENERATIONS)
simulator.update_fitness()
simulator.population[0].save('fittest_manduca_complex.npz')
finally:
pool.close()
pool.join()
......
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