-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_channels.py
135 lines (99 loc) · 4.49 KB
/
plot_channels.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import numpy as np
import matplotlib.pyplot as plt
time_epochs = 9
runs = 1
Xchants = np.zeros(shape=(time_epochs, runs))
Xchants_pk = np.zeros(shape=(time_epochs, runs))
Epidemic_ALL = np.zeros(shape=(time_epochs, runs))
Epidemic_LTE = np.zeros(shape=(time_epochs, runs))
Epidemic_TV = np.zeros(shape=(time_epochs, runs))
Epidemic_CBRS = np.zeros(shape=(time_epochs, runs))
Epidemic_ISM = np.zeros(shape=(time_epochs, runs))
SprayNWait_ALL = np.zeros(shape=(time_epochs, runs))
HotPotato_ALL = np.zeros(shape=(time_epochs, runs))
T = 180
startTime = [660, 840]
num_messages = 150
num_mules = 10
num_Pusers = 20
path = "DataMules/UMass/2007-11-06/1/Link_Exists/"
p_id = 1
channels = [x for x in range(2,11)]
#Get data for XChants
for time in startTime:
t = 0
for channel in channels:
path_to_metrics = path + "LE_" + str(time) + "_" + str(T) + "/" + "XChant/ALL/mules_" + \
str(num_mules) + "/channels_" + str(channel) + "/P_users_" + str(num_Pusers) + \
"/" + str(num_messages) + "/metrics.txt"
with open(path_to_metrics, "r") as f:
lines = f.readlines()[1:]
for line in lines:
line_arr = line.strip().split()
if "180" in line_arr:
if time == 660:
Xchants_pk[t][0] = line_arr[p_id]
elif time == 840:
Xchants[t][0] = line_arr[p_id]
t += 1
#Get data for Epidemic
t = 0
for channel in channels:
path_to_metrics = path + "LE_" + str(startTime[1]) + "_" + str(T) + "/" + "Epidemic/ALL/mules_" + \
str(num_mules) + "/channels_" + str(channel) + "/P_users_" + str(num_Pusers) + \
"/" + str(num_messages) + "/metrics.txt"
with open(path_to_metrics, "r") as f:
lines = f.readlines()[1:]
for line in lines:
line_arr = line.strip().split()
if "180" in line_arr:
Epidemic_ALL[t][0] = line_arr[p_id]
t += 1
x = np.array([x for x in range(2,11, 1)])
plt.xticks(fontsize=25)
plt.yticks(fontsize=25)
plt.xticks(np.arange(2, 11, 2))
# plt.xlim(0,12)
fig_name = "dummy.eps"
if p_id == 1:
plt.ylabel('Message delivery ratio', fontsize=25)
plt.xlabel('Number of channels', fontsize=25)
plt.ylim(-0.05,1)
fig_name = "Plots/pdr_num_channels_UMass.eps"
if p_id == 2:
plt.ylim(-1, 65)
plt.ylabel('Network delay (min)', fontsize=25)
plt.xlabel('Number of channels', fontsize=25)
fig_name = "Plots/latency_num_channels_UMass.eps"
if p_id == 3:
plt.ylabel('Energy expenditure (KJ)', fontsize=25)
plt.xlabel('Number of channels', fontsize=25)
plt.ylim(-1, 13)
fig_name = "Plots/energy_num_channels_UMass.eps"
if p_id == 4:
plt.ylabel('Message overhead', fontsize=25)
plt.xlabel('Number of channels', fontsize=25)
plt.ylim(-1, 36)
fig_name = "Plots/overhead_num_channels_UMass.eps"
# plt.errorbar(x, Epidemic_CBRS, 0, marker='h', markersize=10, linestyle='--', linewidth=3)
# plt.errorbar(x, Epidemic_ISM, 0, marker='p', markersize=10, linestyle='--', linewidth=3)
# plt.errorbar(x, Epidemic_LTE, 0, marker='v', markersize=10, linestyle='--', linewidth=3)
# plt.errorbar(x, Epidemic_TV, 0, marker='<', markersize=10, linestyle='--', linewidth=3)
plt.errorbar(x, Xchants, 0, marker='D', markersize=10, linestyle='-', linewidth=3, color="#813a5c")
plt.errorbar(x, Xchants_pk, 0, marker='o',markersize=10, linestyle='-', linewidth=3, color="#49FF00")
# plt.errorbar(x, Epidemic_ALL, 0, marker='>', markersize=10, linestyle='-', linewidth=3)
# plt.errorbar(x, SprayNWait_ALL, 0, marker='^', markersize=10, linestyle='-', linewidth=3)
# plt.errorbar(x, HotPotato_ALL, 0, marker='x', markersize=10, linestyle='-', linewidth=3)
# plt.legend(["ER (CBRS)", "ER (ISM)", "ER (LTE)", "ER (TV)", "dDSAaR", "dDSAaR (Ideal)", "S-ER ", "S-SnW ", "S-HP"],
# loc="center", bbox_to_anchor=(.5, 0.9), fontsize=15, ncol=3, frameon=False)
if p_id == 1:
plt.legend([ "dDSAaR", "dDSAaR (Ideal)"], loc="center", bbox_to_anchor=(.5,0.9), fontsize=15, ncol = 3, frameon=False)
elif p_id == 2:
plt.legend([ "dDSAaR", "dDSAaR (Ideal)"], loc="center", bbox_to_anchor=(.5,0.9), fontsize=15, ncol = 3, frameon=False)
elif p_id ==3:
plt.legend([ "dDSAaR", "dDSAaR (Ideal)"], loc="center", bbox_to_anchor=(.5,0.9), fontsize=15, ncol = 3, frameon=False)
elif p_id ==4:
plt.legend([ "dDSAaR", "dDSAaR (Ideal)"], loc="center", bbox_to_anchor=(.5,0.9), fontsize=15, ncol = 3, frameon=False)
plt.tight_layout()
plt.savefig(fig_name)
plt.show()