ALRhub / deep_rl_for_swarms

86 stars 29 forks source link

How to train a model that Pursuit Evasion with Multiple Evaders ? #3

Open Aaricis opened 5 years ago

Aaricis commented 5 years ago

I try to train the Pursuit Evasion with Multiple Evaders model, and have changed the code like this, but it cannot work. How should train this model correctly? `def train(num_timesteps, log_dir): import deep_rl_for_swarms.common.tf_util as U sess = U.single_threaded_session() sess.enter()

rank = MPI.COMM_WORLD.Get_rank()
if rank == 0:
    logger.configure(format_strs=['csv'], dir=log_dir)
else:
    logger.configure(format_strs=[])
    logger.set_level(logger.DISABLED)

def policy_fn(name, ob_space, ac_space):
    return mlp_multi_mean_embedding_policy.MlpPolicy(name=name, ob_space=ob_space, ac_space=ac_space,
                                               hid_size=[64], feat_size=[64])

env =pursuit_evasion_multi.PursuitEvasionMultiEnv(nr_pursuers=5,
                             nr_evaders=2,
                             obs_mode='sum_obs_no_ori',
                            comm_radius=200 * np.sqrt(2),
                              world_size=100,
                              distance_bins=8,
                              bearing_bins=8,
                              dynamics='unicycle',
                              torus=True)

trpo_mpi.learn(env, policy_fn, timesteps_per_batch=2048, max_kl=0.01, cg_iters=10, cg_damping=0.1,
    max_timesteps=num_timesteps, gamma=0.99, lam=0.98, vf_iters=5, vf_stepsize=1e-3)
env.close()`
iMrzhao commented 2 years ago

Have you solved this problem? @Aaricis