def run(self): sim_config = self.record['sim_config'] for i_ep in range(self.n_episodes): # print(i_ep) ep_dict = {} t_list = [] ep_dict.update({'t_list': t_list}) world = balls_sim.World(**sim_config) # save constants for the episode radii = [np.copy(body.r) for body in world.bodies] masses = [np.copy(body.m) for body in world.bodies] ep_dict.update({'radii': radii}) ep_dict.update({'masses': masses}) for t in range(self.ep_length): world.run() t_dict = {} poses = [np.copy(body.pos) for body in world.bodies] vels = [body.vel for body in world.bodies] measures = [np.copy(body.measured_pos) for body in world.bodies] t_dict.update({'poses': poses}) t_dict.update({'vels': vels}) t_dict.update({'measures': measures}) t_list.append(t_dict) self.all_eps.append(ep_dict)
def run(self): total_episodes = EPISODES_TRAIN if 'train' in FILENAME else EPISODES_VALID while self.ep < total_episodes: print('Episode:', self.ep) # self.world = simple_sim.World() self.world = balls_sim.World() self.screen_list = [] for _ in range(EP_LEN): self.world.run() observation = self.world.draw() # observation = self.world.give_numbers() self.screen_list.append(observation) self.t += 1 self.ep += 1 self.ep_list.append(self.screen_list[:])
def __init__(self, sim_config=DEFAULT_SIM_CONFIG, n_particles=1000): self.sim_config = copy.deepcopy(DEFAULT_SIM_CONFIG) self.sim_config.update(sim_config) self.n = n_particles self.parts = [] self.n_targets = sim_config['n_bodies'] self.measurement_noise = sim_config['measurement_noise'] self.dynamics_noise = sim_config['dynamics_noise'] for _ in range(self.n): self.parts.append(balls_sim.World(**self.sim_config)) self.w = np.ones(n_particles) / n_particles space = np.linspace(0.5, WORLD_LEN - 0.5, WORLD_LEN) self.I, self.J = np.meshgrid(space, space)