Skip to content

Commit

Permalink
param
Browse files Browse the repository at this point in the history
  • Loading branch information
katetolstaya committed Jun 23, 2019
1 parent f26a3cf commit 71615d7
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 1 deletion.
17 changes: 17 additions & 0 deletions cfg/rad.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ dt = 0.01

header = k, comm_radius, reward


[4, 0.8]
k = 4
comm_radius = 4.0

[3, 4.0]
k = 3
comm_radius = 4.0

[2, 4.0]
k = 2
comm_radius = 4.0

[1, 4.0]
k = 1
comm_radius = 4.0

[4, 0.8]
k = 4
comm_radius = 0.8
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion results/dt.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
k, dt, reward
k, dt, reward_mean, reward_std
1, 0.1, -1270917.0522448036, 452924.35657368874
1, 0.075, -30928.217654153723, 4563.656872878289
1, 0.05, -14397.50841863872, 1673.3872385991804
Expand Down
90 changes: 90 additions & 0 deletions results/plot_bargraph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import matplotlib
import matplotlib.pyplot as plt
import csv
import numpy as np
from collections import OrderedDict

font = {'family': 'serif',
'weight': 'bold',
'size': 14}
matplotlib.rc('font', **font)

_CENTRALIZED = 'Centr.'
_DECENTRALIZED = 'Decentr.'

def main():

# fig_fname = 'airsim_trained'
# fnames = ['airsim_trained.csv']

fig_fname = 'stoch_transfer_to_airsim'
fnames = ['stoch_transfer_to_airsim.csv']


# colors = {_CENTRALIZED: 'green', _DECENTRALIZED: 'red', '4': 'blue', '3': 'darkviolet', '2': 'orange', '1': 'gold'}
save_dir = 'fig/'

# fnames = ['rad.csv', 'rad_baseline.csv']
# xlabel = 'Comm. Radius'
k_ind = 0


mean_costs, std_costs = get_dict(fnames, k_ind)

# max_val, min_dec = get_max(mean_costs)
# max_val = max_val + 10.0
ylabel = 'Cost'
# title = ylabel + ' vs. ' + xlabel

# plot
fig, ax = plt.subplots()

ax.bar(mean_costs.keys(), mean_costs.values(), yerr = std_costs.values())


# ax.legend()
plt.title('Trained on Stochastic Point-Mass Model')
# plt.ylim(top=max_val, bottom=0)
plt.xlabel('K')
plt.ylabel(ylabel)

plt.savefig(save_dir + fig_fname + '.eps', format='eps')
plt.show()


def get_dict(fnames, k_ind):
mean_costs = OrderedDict()
std_costs = OrderedDict()

for fname in fnames:
with open(fname, 'r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
next(plots, None)
for row in plots:

if len(row) == 3:
k = row[k_ind].strip()
mean = float(row[1]) * -1.0
std = float(row[2])

mean_costs[k] = mean
std_costs[k] = std

return mean_costs, std_costs


def get_max(list_costs):
# compute average over diff seeds for each parameter combo
max_val = -1.0 * np.Inf
min_decentralized = 1.0 * np.Inf

for k in list_costs.keys():
for v in list_costs[k].keys():
if k != _DECENTRALIZED:
max_val = np.maximum(max_val, list_costs[k][v])
else:
min_decentralized = np.minimum(min_decentralized, list_costs[k][v])
return max_val, min_decentralized

if __name__ == "__main__":
main()
5 changes: 5 additions & 0 deletions results/stoch_transfer_to_airsim.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
k, reward, std
1, -5.905066259211232, 2.2105622358605097
2, -3.9234482654695833, 1.043596249170607
3, -6.772500496052969, 2.5845733981345425
4, -7.013095494140333, 2.6972839846893635

0 comments on commit 71615d7

Please sign in to comment.