-
Notifications
You must be signed in to change notification settings - Fork 0
/
Figure9.py
321 lines (255 loc) · 15.8 KB
/
Figure9.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
import matplotlib.pyplot as plt
import numpy as np
import pickle
if __name__ == '__main__':
Figure = plt.figure(figsize=(15.36,8.96))
plt.subplot(2,3,1)
AlphaList = [0,2,3,4,5,6,7,8,9,10]
AlphaValue = ['Cali\nbrated','200','300','400','500','600','700','800','900','1000']
for k in [4000]:
NoMean = []
RandMean = []
RandStd = []
DegMean = []
DegStd = []
ShorrMean = []
ShorrStd = []
GreedyMean = []
GreedyStd = []
for alpha in AlphaList:
with open('Data/PreCOVID-Clearance/PreCOVID-Clearance-'+str(alpha)+'.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
NoMean.append(np.mean(np.sum(loads_other_no[int((k-500)/500),:,:],axis=1)))
RandMean.append(np.mean(np.sum(loads_other_rand[int((k-500)/500),:,:],axis=1)))
RandStd.append(np.std(np.sum(loads_other_rand[int((k-500)/500),:,:],axis=1)))
DegMean.append(np.mean(np.sum(loads_other_deg[int((k-500)/500),:,:],axis=1)))
DegStd.append(np.std(np.sum(loads_other_deg[int((k-500)/500),:,:],axis=1)))
ShorrMean.append(np.mean(np.sum(loads_other_shorr[int((k-500)/500),:,:],axis=1)))
ShorrStd.append(np.std(np.sum(loads_other_shorr[int((k-500)/500),:,:],axis=1)))
GreedyMean.append(np.mean(np.sum(loads_other_greedy[int((k-500)/500),:,:],axis=1)))
GreedyStd.append(np.std(np.sum(loads_other_greedy[int((k-500)/500),:,:],axis=1)))
RandMean = np.array(RandMean)/np.array(NoMean)
RandStd = np.array(RandStd)/np.array(NoMean)
DegMean = np.array(DegMean)/np.array(NoMean)
DegStd = np.array(DegStd)/np.array(NoMean)
ShorrMean = np.array(ShorrMean)/np.array(NoMean)
ShorrStd = np.array(ShorrStd)/np.array(NoMean)
GreedyMean = np.array(GreedyMean)/np.array(NoMean)
GreedyStd = np.array(GreedyStd)/np.array(NoMean)
x1 = np.array(list(range(10))) + 1 - 0.3
x2 = np.array(list(range(10))) + 1 - 0.1
x3 = np.array(list(range(10))) + 1 + 0.1
x4 = np.array(list(range(10))) + 1 + 0.3
plt.bar(x1,RandMean,yerr=RandStd,capsize=4,color='C7',label='Random',width=0.2)
plt.bar(x2,DegMean,yerr=DegStd,capsize=4,color='C0',label='Degree',width=0.2)
plt.bar(x3,ShorrMean,yerr=ShorrStd,capsize=4,color='#6B8E23',label='Shorr',width=0.2)
plt.bar(x4,GreedyMean,yerr=GreedyStd,capsize=4, color='C3',label='Greedy-Spectral',width=0.2)
plt.xlabel("Number of cases", fontsize=18)
plt.ylabel(r"$\gamma_{Loads}$", fontsize=18)
plt.hlines(1,0.5,10.5,linewidth=1,color='black',linestyle='dashed')
plt.xticks(np.array(list(range(10)))+1,AlphaValue,fontsize=10)
plt.xlim(0.5,10.5)
plt.ylim(bottom=0,top=1.1)
plt.title('UVA-PreCOVID: Budget k='+str(k),fontsize=14)
plt.legend(loc=3,fontsize=14)
plt.subplot(2,3,2)
AlphaList = [0,2,3,4,5,6,7,8,9,10]
AlphaValue = ['Cali\nbrated','200','300','400','500','600','700','800','900','1000']
for k in [4000]:
NoMean = []
RandMean = []
RandStd = []
DegMean = []
DegStd = []
ShorrMean = []
ShorrStd = []
GreedyMean = []
GreedyStd = []
for alpha in AlphaList:
with open('Data/PreCOVID-Clearance/PreCOVID-Clearance-'+str(alpha)+'.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
NoMean.append(np.mean(np.sum(cum_new_cases_no[int((k-500)/500),:,:],axis=1)))
RandMean.append(np.mean(np.sum(cum_new_cases_rand[int((k-500)/500),:,:],axis=1)))
RandStd.append(np.std(np.sum(cum_new_cases_rand[int((k-500)/500),:,:],axis=1)))
DegMean.append(np.mean(np.sum(cum_new_cases_deg[int((k-500)/500),:,:],axis=1)))
DegStd.append(np.std(np.sum(cum_new_cases_deg[int((k-500)/500),:,:],axis=1)))
ShorrMean.append(np.mean(np.sum(cum_new_cases_shorr[int((k-500)/500),:,:],axis=1)))
ShorrStd.append(np.std(np.sum(cum_new_cases_shorr[int((k-500)/500),:,:],axis=1)))
GreedyMean.append(np.mean(np.sum(cum_new_cases_greedy[int((k-500)/500),:,:],axis=1)))
GreedyStd.append(np.std(np.sum(cum_new_cases_greedy[int((k-500)/500),:,:],axis=1)))
RandMean = np.array(RandMean)/np.array(NoMean)
RandStd = np.array(RandStd)/np.array(NoMean)
DegMean = np.array(DegMean)/np.array(NoMean)
DegStd = np.array(DegStd)/np.array(NoMean)
ShorrMean = np.array(ShorrMean)/np.array(NoMean)
ShorrStd = np.array(ShorrStd)/np.array(NoMean)
GreedyMean = np.array(GreedyMean)/np.array(NoMean)
GreedyStd = np.array(GreedyStd)/np.array(NoMean)
x1 = np.array(list(range(10))) + 1 - 0.3
x2 = np.array(list(range(10))) + 1 - 0.1
x3 = np.array(list(range(10))) + 1 + 0.1
x4 = np.array(list(range(10))) + 1 + 0.3
plt.bar(x1,RandMean,yerr=RandStd,capsize=4,color='C7',label='Random',width=0.2)
plt.bar(x2,DegMean,yerr=DegStd,capsize=4,color='C0',label='Degree',width=0.2)
plt.bar(x3,ShorrMean,yerr=ShorrStd,capsize=4,color='#6B8E23',label='Shorr',width=0.2)
plt.bar(x4,GreedyMean,yerr=GreedyStd,capsize=4, color='C3',label='Greedy-Spectral',width=0.2)
plt.xlabel("Number of cases", fontsize=18)
plt.ylabel(r"$\gamma_{Cases}$", fontsize=18)
plt.hlines(1,0.5,10.5,linewidth=1,color='black',linestyle='dashed')
plt.xticks(np.array(list(range(10)))+1,AlphaValue,fontsize=10)
plt.xlim(0.5,10.5)
plt.ylim(bottom=0,top=1.1)
plt.title('UVA-PreCOVID: Budget k='+str(k),fontsize=14)
#plt.legend(loc=1,fontsize=14)
plt.subplot(2,3,3)
threshold = 500
for k in [4000]:
Rand = []
Deg = []
Shorr = []
Greedy = []
for alpha in AlphaList:
with open('Data/PreCOVID-Clearance/PreCOVID-Clearance-'+str(alpha)+'.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
Rand.append(len(np.where(cum_new_cases_rand[int((k-500)/500),:1000,-1]>threshold)[0]))
Deg.append(len(np.where(cum_new_cases_deg[int((k-500)/500),:1000,-1]>threshold)[0]))
Shorr.append(len(np.where(cum_new_cases_shorr[int((k-500)/500),:1000,-1]>threshold)[0]))
Greedy.append(len(np.where(cum_new_cases_greedy[int((k-500)/500),:1000,-1]>threshold)[0]))
X = np.array(list(range(10))) + 1
plt.plot(X, Rand, '-', label='Random', linewidth=2, color='C7')
plt.plot(X, Deg, '-', label='Degree', linewidth=2, color='C0')
plt.plot(X, Shorr, '-', label='Shorr Score', linewidth=2, color='#6B8E23')
plt.plot(X, Greedy, '-', label='Greedy-Spectral', linewidth=2, color='C3')
plt.xlabel("Number of Cases", fontsize=18)
plt.ylabel(r"$Prob[Cases > 500]$", fontsize=18)
plt.xticks(np.array(list(range(10)))+1,AlphaValue,fontsize=10)
plt.xlim(0.5,10.5)
plt.yticks([0,200,400,600,800,1000],['0','0.2','0.4','0.6','0.8','1.0'],fontsize=14)
plt.ylim(bottom=0,top=1000)
plt.title('UVA-PreCOVID: Budget k='+str(k),fontsize=14)
plt.subplot(2,3,4)
AlphaList = [0,2,3,4,5,6,7,8,9,10]
AlphaValue = ['Cali\nbrated','200','300','400','500','600','700','800','900','1000']
for k in [4000]:
NoMean = []
RandMean = []
RandStd = []
DegMean = []
DegStd = []
ShorrMean = []
ShorrStd = []
GreedyMean = []
GreedyStd = []
for alpha in AlphaList:
with open('Data/PostCOVID-Clearance/PostCOVID-Clearance-'+str(alpha)+'.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
NoMean.append(np.mean(np.sum(loads_other_no[int((k-500)/500),:,:],axis=1)))
RandMean.append(np.mean(np.sum(loads_other_rand[int((k-500)/500),:,:],axis=1)))
RandStd.append(np.std(np.sum(loads_other_rand[int((k-500)/500),:,:],axis=1)))
DegMean.append(np.mean(np.sum(loads_other_deg[int((k-500)/500),:,:],axis=1)))
DegStd.append(np.std(np.sum(loads_other_deg[int((k-500)/500),:,:],axis=1)))
ShorrMean.append(np.mean(np.sum(loads_other_shorr[int((k-500)/500),:,:],axis=1)))
ShorrStd.append(np.std(np.sum(loads_other_shorr[int((k-500)/500),:,:],axis=1)))
GreedyMean.append(np.mean(np.sum(loads_other_greedy[int((k-500)/500),:,:],axis=1)))
GreedyStd.append(np.std(np.sum(loads_other_greedy[int((k-500)/500),:,:],axis=1)))
RandMean = np.array(RandMean)/np.array(NoMean)
RandStd = np.array(RandStd)/np.array(NoMean)
DegMean = np.array(DegMean)/np.array(NoMean)
DegStd = np.array(DegStd)/np.array(NoMean)
ShorrMean = np.array(ShorrMean)/np.array(NoMean)
ShorrStd = np.array(ShorrStd)/np.array(NoMean)
GreedyMean = np.array(GreedyMean)/np.array(NoMean)
GreedyStd = np.array(GreedyStd)/np.array(NoMean)
x1 = np.array(list(range(10))) + 1 - 0.3
x2 = np.array(list(range(10))) + 1 - 0.1
x3 = np.array(list(range(10))) + 1 + 0.1
x4 = np.array(list(range(10))) + 1 + 0.3
plt.bar(x1,RandMean,yerr=RandStd,capsize=4,color='C7',label='Random',width=0.2)
plt.bar(x2,DegMean,yerr=DegStd,capsize=4,color='C0',label='Degree',width=0.2)
plt.bar(x3,ShorrMean,yerr=ShorrStd,capsize=4,color='#6B8E23',label='Shorr',width=0.2)
plt.bar(x4,GreedyMean,yerr=GreedyStd,capsize=4, color='C3',label='Greedy-Spectral',width=0.2)
plt.xlabel("Number of cases\n\n(a) "+r"$\gamma_{Loads}$", fontsize=18)
plt.ylabel(r"$\gamma_{Loads}$", fontsize=18)
plt.hlines(1,0.5,10.5,linewidth=1,color='black',linestyle='dashed')
plt.xticks(np.array(list(range(10)))+1,AlphaValue,fontsize=10)
plt.xlim(0.5,10.5)
plt.ylim(bottom=0,top=1.1)
plt.title('UVA-PostCOVID: Budget k='+str(k),fontsize=14)
plt.legend(loc=3,fontsize=14)
plt.subplot(2,3,5)
AlphaList = [0,2,3,4,5,6,7,8,9,10]
AlphaValue = ['Cali\nbrated','200','300','400','500','600','700','800','900','1000']
for k in [4000]:
NoMean = []
RandMean = []
RandStd = []
DegMean = []
DegStd = []
ShorrMean = []
ShorrStd = []
GreedyMean = []
GreedyStd = []
for alpha in AlphaList:
with open('Data/PostCOVID-Clearance/PostCOVID-Clearance-'+str(alpha)+'.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
NoMean.append(np.mean(np.sum(cum_new_cases_no[int((k-500)/500),:,:],axis=1)))
RandMean.append(np.mean(np.sum(cum_new_cases_rand[int((k-500)/500),:,:],axis=1)))
RandStd.append(np.std(np.sum(cum_new_cases_rand[int((k-500)/500),:,:],axis=1)))
DegMean.append(np.mean(np.sum(cum_new_cases_deg[int((k-500)/500),:,:],axis=1)))
DegStd.append(np.std(np.sum(cum_new_cases_deg[int((k-500)/500),:,:],axis=1)))
ShorrMean.append(np.mean(np.sum(cum_new_cases_shorr[int((k-500)/500),:,:],axis=1)))
ShorrStd.append(np.std(np.sum(cum_new_cases_shorr[int((k-500)/500),:,:],axis=1)))
GreedyMean.append(np.mean(np.sum(cum_new_cases_greedy[int((k-500)/500),:,:],axis=1)))
GreedyStd.append(np.std(np.sum(cum_new_cases_greedy[int((k-500)/500),:,:],axis=1)))
RandMean = np.array(RandMean)/np.array(NoMean)
RandStd = np.array(RandStd)/np.array(NoMean)
DegMean = np.array(DegMean)/np.array(NoMean)
DegStd = np.array(DegStd)/np.array(NoMean)
ShorrMean = np.array(ShorrMean)/np.array(NoMean)
ShorrStd = np.array(ShorrStd)/np.array(NoMean)
GreedyMean = np.array(GreedyMean)/np.array(NoMean)
GreedyStd = np.array(GreedyStd)/np.array(NoMean)
x1 = np.array(list(range(10))) + 1 - 0.3
x2 = np.array(list(range(10))) + 1 - 0.1
x3 = np.array(list(range(10))) + 1 + 0.1
x4 = np.array(list(range(10))) + 1 + 0.3
plt.bar(x1,RandMean,yerr=RandStd,capsize=4,color='C7',label='Random',width=0.2)
plt.bar(x2,DegMean,yerr=DegStd,capsize=4,color='C0',label='Degree',width=0.2)
plt.bar(x3,ShorrMean,yerr=ShorrStd,capsize=4,color='#6B8E23',label='Shorr',width=0.2)
plt.bar(x4,GreedyMean,yerr=GreedyStd,capsize=4, color='C3',label='Greedy-Spectral',width=0.2)
plt.xlabel("Number of cases\n\n(b) "+r"$\gamma_{Cases}$", fontsize=18)
plt.ylabel(r"$\gamma_{Cases}$", fontsize=18)
plt.hlines(1,0.5,10.5,linewidth=1,color='black',linestyle='dashed')
plt.xticks(np.array(list(range(10)))+1,AlphaValue,fontsize=10)
plt.xlim(0.5,10.5)
plt.ylim(bottom=0,top=1.1)
plt.title('UVA-PostCOVID: Budget k='+str(k),fontsize=14)
#plt.legend(loc=1,fontsize=14)
plt.subplot(2,3,6)
threshold = 500
for k in [4000]:
Rand = []
Deg = []
Shorr = []
Greedy = []
for alpha in AlphaList:
with open('Data/PostCOVID-Clearance/PostCOVID-Clearance-'+str(alpha)+'.pkl', 'rb') as pkl:
cum_new_cases_no, cum_new_cases_rand, cum_new_cases_deg, cum_new_cases_greedy, cum_new_cases_shorr, loads_other_no, loads_other_rand, loads_other_deg, loads_other_greedy, loads_other_shorr, rhos_rand, rhos_deg, rhos_greedy, rhos_shorr = pickle.load(pkl)
Rand.append(len(np.where(cum_new_cases_rand[int((k-500)/500),:1000,-1]>threshold)[0]))
Deg.append(len(np.where(cum_new_cases_deg[int((k-500)/500),:1000,-1]>threshold)[0]))
Shorr.append(len(np.where(cum_new_cases_shorr[int((k-500)/500),:1000,-1]>threshold)[0]))
Greedy.append(len(np.where(cum_new_cases_greedy[int((k-500)/500),:1000,-1]>threshold)[0]))
X = np.array(list(range(10))) + 1
plt.plot(X, Rand, '-', label='Random', linewidth=2, color='C7')
plt.plot(X, Deg, '-', label='Degree', linewidth=2, color='C0')
plt.plot(X, Shorr, '-', label='Shorr Score', linewidth=2, color='#6B8E23')
plt.plot(X, Greedy, '-', label='Greedy-Spectral', linewidth=2, color='C3')
plt.xlabel("Number of Cases\n\n(c) "+r"$Prob[Cases > 500]$", fontsize=18)
plt.ylabel(r"$Prob[Cases > 500]$", fontsize=18)
plt.xticks(np.array(list(range(10)))+1,AlphaValue,fontsize=10)
plt.xlim(0.5,10.5)
plt.yticks([0,200,400,600,800,1000],['0','0.2','0.4','0.6','0.8','1.0'],fontsize=14)
plt.ylim(bottom=0,top=1000)
plt.title('UVA-PostCOVID: Budget k='+str(k),fontsize=14)
plt.tight_layout()
plt.savefig('Figure9.pdf')