Skip to content

Commit

Permalink
baseline cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
katetolstaya committed Jun 27, 2019
1 parent a4f0388 commit c464c6a
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 44 deletions.
2 changes: 1 addition & 1 deletion cfg/airsim_baseline.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ actor_lr = 5e-5
n_train_episodes = 400
beta_coeff = 0.993
test_interval = 40
n_test_episodes = 3
n_test_episodes = 20

# architecture parameters
k = 2
Expand Down
6 changes: 6 additions & 0 deletions results/airsim_trained2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
k, reward, std
1, -6.1264006465977925, 2.6261114461138306
2, -3.4652359381486413, 1.3084831858508834
3, -2.9150179750214456, 1.6347459314744373
4, -2.591131502530944, 0.5262619174971477

4 changes: 0 additions & 4 deletions results/n.csv
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
k, n_agents, reward
1, 25, -419.36150946154413, 228.81464681638593
1, 50, -432.9951122485818, 249.61795362199805
1, 75, -319.83185308018284, 130.14053520184876
1, 100, -229.15979292372407, 122.16289677324487
1, 125, -217.1340116775613, 95.3461704293501
1, 150, -172.14025454122398, 51.635444445613196
2, 25, -175.80376085839316, 190.7653062240825
2, 50, -89.97712855183387, 108.03483725875923
2, 75, -55.540402898312344, 11.146641164414202
2, 100, -50.51020781200708, 12.566522373659023
2, 125, -46.76860348867619, 12.555701772579592
2, 150, -37.0106466777022, 3.232041202865438
3, 25, -99.70804057695489, 115.87676249230482
3, 50, -73.35025660496456, 109.79197822945807
3, 75, -44.86283894212626, 4.923115098403242
3, 100, -40.95792156471694, 4.1560902247655385
3, 125, -41.15206481867972, 15.84355642218285
3, 150, -34.25862769738046, 2.3905789668612885
4, 25, -129.51668905023533, 221.61694939867266
4, 50, -44.96090491863062, 8.438123529368031
4, 75, -41.707591033111626, 4.70898675648138
4, 100, -38.293215563303235, 3.1199301223969256
Expand Down
2 changes: 0 additions & 2 deletions results/n_baseline.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
centralized, n_agents, reward
True, 25, -28.363746468002706, 6.456637188954312
True, 50, -21.189087350417914, 4.914202107841018
True, 75, -17.578174984474465, 3.725134289661792
True, 100, -14.899697200560103, 1.8157149806086754
True, 125, -14.497312413551816, 1.857963983379794
True, 150, -13.436401447590432, 1.508457092067479
False, 25, -4674.500102991744, 1087.290091768198
False, 50, -5414.270146056273, 1222.4711829412147
False, 75, -6172.847920185132, 791.1410941872234
False, 100, -6535.8762397044575, 554.0006754735136
Expand Down
6 changes: 3 additions & 3 deletions results/plot_bargraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def main():
mean_cost_decent = [6.840906470373157]
std_cost_decent = [1.6711923712693055]

mean_costs_airsim, std_costs_airsim = get_dict(['airsim_trained.csv'], k_ind)
mean_costs_stoch, std_costs_stoch = get_dict(['stoch_transfer_to_airsim.csv'], k_ind)
mean_costs_airsim, std_costs_airsim = get_dict(['airsim_trained2.csv'], k_ind)
mean_costs_stoch, std_costs_stoch = get_dict(['stoch_transfer_to_airsim2.csv'], k_ind)
ylabel = 'Cost'

# plot
Expand All @@ -47,7 +47,7 @@ def main():
p4 = ax.bar(-1, mean_cost_decent, width=width*3, yerr=std_cost_decent)


ax.legend((p1[0], p2[0], p3[0], p4[0]), ('Trained: AirSim', 'Trained: Point-Masses', 'Centralized', 'Decentralized'))
ax.legend((p1[0], p2[0], p3[0], p4[0]), ('Trained: AirSim', 'Trained: Point-Masses', 'Global', 'Local'))
plt.title('Testing in AirSim')
# plt.ylim(top=max_val, bottom=0)
plt.xlabel('K')
Expand Down
4 changes: 2 additions & 2 deletions results/plot_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
matplotlib.rc('font', **font)

_CENTRALIZED = 'Global'
_DECENTRALIZED = 'Local.'
_DECENTRALIZED = 'Local'

def main():

fig_fname = 'rad'
fig_fname = 'n'

if fig_fname == 'transfer_grid_n':
fnames = ['transfer_grid_n.csv']
Expand Down
6 changes: 6 additions & 0 deletions results/stoch_transfer_to_airsim2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
k, reward, std
1, -5.371718155747085, 2.107049489042026
2, -3.8907236770070335, 1.9490529683049205
3, -3.5587343557409077, 2.3253053480811885
4, -4.410319276747424, 2.4066994410746116

70 changes: 40 additions & 30 deletions test_one_traj.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test(args, actor_path, k):

learner.load_model(actor_path, device)

n_steps = 500
n_steps = 400

steps = np.zeros((n_steps,))
min_dists_mean = np.zeros((n_steps,))
Expand Down Expand Up @@ -80,35 +80,37 @@ def test(args, actor_path, k):

if step % 300 == 0:
env.render()
plt.savefig(save_dir + 'traj' + str(step) + '.eps', format='eps')
plt.savefig(save_dir + 'leader_traj' + str(step) + '.eps', format='eps')

plt.ioff()

y = min_dists_mean
y_min = min_dists_mean - min_dists_std
y_max = min_dists_mean + min_dists_std

fig = plt.figure()
plt.plot(steps, y, 'b-')
plt.fill_between(steps, y_min, y_max, color='lightblue')
plt.xlabel('Step')
plt.ylabel('Min. Distances')
plt.tight_layout()
plt.savefig(save_dir + 'min_dist.eps', format='eps')
plt.show()

y = vel_diffs_mean
y_min = vel_diffs_mean - vel_diffs_std
y_max = vel_diffs_mean + vel_diffs_std

fig = plt.figure()
plt.plot(steps, y, 'r-')
plt.fill_between(steps, y_min, y_max, color='orange')
plt.xlabel('Step')
plt.ylabel('Velocity Diff.')
plt.tight_layout()
plt.savefig(save_dir + 'vel_diff.eps', format='eps')
plt.show()
plt.ioff()
#
# y = min_dists_mean
# y_min = min_dists_mean - min_dists_std
# y_max = min_dists_mean + min_dists_std
#
# fig = plt.figure()
# plt.plot(steps, y, 'b-')
# plt.fill_between(steps, y_min, y_max, color='lightblue')
# plt.xlabel('Step')
# plt.ylabel('Min. Distances')
# plt.tight_layout()
# plt.savefig(save_dir + 'min_dist.eps', format='eps')
# plt.show()
#
# y = vel_diffs_mean
# y_min = vel_diffs_mean - vel_diffs_std
# y_max = vel_diffs_mean + vel_diffs_std
#
# fig = plt.figure()
# plt.plot(steps, y, 'r-')
# plt.fill_between(steps, y_min, y_max, color='orange')
# plt.xlabel('Step')
# plt.ylabel('Velocity Diff.')
# plt.tight_layout()
# plt.savefig(save_dir + 'vel_diff.eps', format='eps')
# plt.show()

env.close()

Expand All @@ -120,13 +122,21 @@ def main():
# actor_path = 'models/ddpg_actor_FlockingRelative-v0_k3'
# actor_path = 'models/ddpg_actor_FlockingStochastic-v0_stoch2'

k = 3
actor_path = 'models/ddpg_actor_FlockingRelative-v0_transfer' + str(k)
fname = 'cfg/dagger.cfg'
# k = 3
# actor_path = 'models/ddpg_actor_FlockingRelative-v0_transfer' + str(k)
# fname = 'cfg/dagger.cfg'

# actor_path = 'models/ddpg_actor_FlockingStochastic-v0_transfer_stoch' + str(k)
# fname = 'cfg/dagger_stoch.cfg'


k = 3
actor_path = 'models/ddpg_actor_FlockingRelative-v0_transfer' + str(k)
fname = 'cfg/dagger_leader.cfg'




config_file = path.join(path.dirname(__file__), fname)
config = configparser.ConfigParser()
config.read(config_file)
Expand Down
6 changes: 4 additions & 2 deletions test_one_traj2.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ def test(args, actor_path, k):
plt.plot(steps, y, 'b-', label='GNN')
plt.fill_between(steps, y_min, y_max, color='lightblue')

plt.plot(steps, y2, 'r-', label='Decentralized')
plt.plot(steps, y2, 'r-', label='Local')
plt.fill_between(steps, y_min2, y_max2, color='orange')

plt.axhline(y=1, linestyle='--', color='k', label='Comm. Radius')
plt.legend()

plt.xlabel('Step')
Expand All @@ -134,7 +136,7 @@ def test(args, actor_path, k):
plt.plot(steps, y, 'b-', label='GNN')
plt.fill_between(steps, y_min, y_max, color='lightblue')

plt.plot(steps, y2, 'r-', label='Decentralized')
plt.plot(steps, y2, 'r-', label='Local')
plt.fill_between(steps, y_min2, y_max2, color='orange')
plt.legend()
plt.xlabel('Step')
Expand Down

0 comments on commit c464c6a

Please sign in to comment.