Skip to content

Commit

Permalink
update_new_simulation_method
Browse files Browse the repository at this point in the history
  • Loading branch information
YaolinGe committed Sep 8, 2023
1 parent 6e026ce commit fbbcf00
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Publication/src/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def __init__(self) -> None:
self.__budget_mode = False

""" Default simulation parameter seteup. """
self.__num_steps = 3 # number of steps.
self.__num_replicates = 3 # number of replicates
self.__num_cores = 3 # number of cores to use
self.__num_steps = 120 # number of steps.
self.__num_replicates = 1 # number of replicates
self.__num_cores = 1 # number of cores to use

@staticmethod
def wgs2xy(value: np.ndarray) -> np.ndarray:
Expand Down
16 changes: 11 additions & 5 deletions Publication/src/Simulators/Simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,29 @@ def __init__(self, weight_eibv: float = 1., weight_ivr: float = 1.,
self.__datapath = os.getcwd() + "/npy/temporal/R_{:03d}/".format(replicate_id) + self.__name + "/"
checkfolder(self.__datapath)

def run(self) -> None:
def run_myopic(self) -> None:
""" Run the simulation for all the agents. """
t0 = time()
self.__agent_myopic.run()
print("Myopic simulation takes {:.2f} seconds.".format(time() - t0))
self.__agent_rrtstar.run()
print("RRT* simulation takes {:.2f} seconds.".format(time() - t0))

t0 = time()
(traj_myopic, ibv_myopic, rmse_myopic, vr_myopic,
mu_data_myopic, cov_myopic, sigma_data_myopic, mu_truth_data_myopic) = self.__agent_myopic.get_metrics()

np.savez(self.__datapath + "myopic.npz", traj=traj_myopic, ibv=ibv_myopic, rmse=rmse_myopic, vr=vr_myopic,
mu=mu_data_myopic, cov=cov_myopic, sigma=sigma_data_myopic, truth=mu_truth_data_myopic)
print("Saving data takes {:.2f} seconds.".format(time() - t0))

def run_rrt(self) -> None:
""" Run the simulation for all the agents. """
t0 = time()
self.__agent_rrtstar.run()
print("RRT* simulation takes {:.2f} seconds.".format(time() - t0))

(traj_rrtstar, ibv_rrtstar, rmse_rrtstar, vr_rrtstar,
mu_data_rrtstar, cov_rrtstar, sigma_data_rrtstar, mu_truth_data_rrtstar) = self.__agent_rrtstar.get_metrics()

np.savez(self.__datapath + "myopic.npz", traj=traj_myopic, ibv=ibv_myopic, rmse=rmse_myopic, vr=vr_myopic,
mu=mu_data_myopic, cov=cov_myopic, sigma=sigma_data_myopic, truth=mu_truth_data_myopic)
np.savez(self.__datapath + "rrtstar.npz", traj=traj_rrtstar, ibv=ibv_rrtstar, rmse=rmse_rrtstar, vr=vr_rrtstar,
mu=mu_data_rrtstar, cov=cov_rrtstar, sigma=sigma_data_rrtstar, truth=mu_truth_data_rrtstar)
print("Saving data takes {:.2f} seconds.".format(time() - t0))
Expand Down
3 changes: 2 additions & 1 deletion Publication/src/run_temporal_replicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def run_replicates(sws: np.ndarray = np.array([0, 102, 1., 1.])):
print("Replicate: ", i, " | Seed: ", seed, " | Weight EIBV: ", weight_eibv, " | Weight IVR: ", weight_ivr)
simulator = Simulator(weight_eibv=weight_eibv, weight_ivr=weight_ivr,
random_seed=seed, replicate_id=i, debug=debug)
simulator.run()
# simulator.run_myopic()
simulator.run_rrt()


if __name__ == "__main__":
Expand Down

0 comments on commit fbbcf00

Please sign in to comment.