-
Notifications
You must be signed in to change notification settings - Fork 4
/
plot_all.jl
675 lines (620 loc) · 43.5 KB
/
plot_all.jl
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
using ArgParse, JLD
include("./src/simulator.jl")
function parallel_plot()
s = ArgParseSettings(description = "arg parse here for parallel experimentation")
@add_arg_table! s begin
"--location" # data file location
"--topology", "-t" # topology name
"--te", "-a" # TE algorithm
"--plottype", "-p" # type of plot needed
"--option", "-o" # if availability, option number, otherwise just placeholder
"--scale", "-s" # if throughput, scale number, otherwise just placeholder
"--plotname", "-n" # the name of plot
"--inverselog", "-i" # inverse log for availability
"--lotteryticketset", "-l" # set of lottery tickets for optimization runtime plot
end
parsed_args = parse_args(s) # the result is a Dict{String,Any}
# println("Parsed args:")
# for (key,val) in parsed_args
# println(" $key => $(repr(val))")
# end
# println(parsed_args)
dir = parsed_args["location"]
topology = parsed_args["topology"]
AllAlgorithms = split(parsed_args["te"], ",")
plottype = parsed_args["plottype"]
option_num = parse(Int64, parsed_args["option"]) # for demand scaling
scale_num = parse(Float64, parsed_args["scale"]) # for ticket scaling
plotname = parsed_args["plotname"]
inverse_log = parse(Bool, parsed_args["inverselog"])
lotteryticket_set = split(parsed_args["lotteryticketset"], ",")
## demand scaling
scales = []
availability_AllTraffic = []
if topology == "B4"
scales = collect(1.0:0.5:6.0)
availability_AllTraffic = collect(1:1:30)
scenarios = collect(1:1:5)
topology_indexes = [1]
elseif topology == "IBM"
scales = collect(1.0:0.5:7.0)
availability_AllTraffic = collect(1:1:30)
scenarios = collect(1:1:3)
topology_indexes = [1]
end
## ticket number scaling
tickets = []
tickets_AllTraffic = []
if topology == "B4"
tickets = vcat(collect(1:1:9), collect(10:5:80))
tickets_AllTraffic = collect(1:1:30)
tickets_scenarios = collect(1:1:5)
tickets_topology_indexes = [1]
elseif topology == "IBM"
tickets = vcat(collect(1:1:9), collect(10:5:90))
tickets_AllTraffic = collect(1:1:30)
tickets_scenarios = collect(1:1:3)
tickets_topology_indexes = [1]
end
## optimization runtime
if topology == "B4"
runtime_tickets = [1,10,40,80,90,120]
runtime_AllTraffic = collect(1:1:30)
runtime_scenarios = collect(1:1:5)
runtime_topology_indexes = [1]
elseif topology == "IBM"
runtime_tickets = [1,10,40,80,90,120]
runtime_AllTraffic = collect(1:1:30)
runtime_scenarios = collect(1:1:3)
runtime_topology_indexes = [1]
end
Scenario_Availability = Dict{String,Array{Float64,4}}()
Flow_Availability = Dict{String,Array{Float64,4}}()
Bandwidth_Availability = Dict{String,Array{Float64,4}}()
conditional_Scenario_Availability = Dict{String,Array{Float64,4}}()
conditional_Flow_Availability = Dict{String,Array{Float64,4}}()
conditional_Bandwidth_Availability = Dict{String,Array{Float64,4}}()
DirectThroughput = Dict{String,Array{Float64,4}}()
SecureThroughput = Dict{String,Array{Float64,4}}()
ticket_DirectThroughput = Dict{String,Array{Float64,4}}()
ticket_SecureThroughput = Dict{String,Array{Float64,4}}()
Algo_RouterPorts = Dict{String,Array{Float64,4}}()
Algo_SolveTime = Dict{String,Array{Float64,4}}()
progress = ProgressMeter.Progress(length(AllAlgorithms)*length(topology_indexes)*length(scenarios)*length(availability_AllTraffic)*length(scales), .1, "Computing $(plottype)-$(plotname) plotting data...", 50)
for algorithm in AllAlgorithms
## jld data aggregation and processing
if plottype == "availability"
Scenario_Availability[algorithm] = zeros(length(topology_indexes), length(scenarios), length(availability_AllTraffic), length(scales))
Flow_Availability[algorithm] = zeros(length(topology_indexes), length(scenarios), length(availability_AllTraffic), length(scales))
Bandwidth_Availability[algorithm] = zeros(length(topology_indexes), length(scenarios), length(availability_AllTraffic), length(scales))
conditional_Scenario_Availability[algorithm] = zeros(length(topology_indexes), length(scenarios), length(availability_AllTraffic), length(scales))
conditional_Flow_Availability[algorithm] = zeros(length(topology_indexes), length(scenarios), length(availability_AllTraffic), length(scales))
conditional_Bandwidth_Availability[algorithm] = zeros(length(topology_indexes), length(scenarios), length(availability_AllTraffic), length(scales))
DirectThroughput[algorithm] = zeros(length(topology_indexes), length(scenarios), length(availability_AllTraffic), length(scales))
SecureThroughput[algorithm] = zeros(length(topology_indexes), length(scenarios), length(availability_AllTraffic), length(scales))
for tid in 1:length(topology_indexes)
topology_index = topology_indexes[tid]
for sid in 1:length(scenarios)
scenario_id = scenarios[sid]
for t in 1:length(availability_AllTraffic)
traffic_id = availability_AllTraffic[t]
for s in 1:length(scales)
scale_id = scales[s]
if plotname == "scenario_availability" || plotname == "all"
Scenario_Availability_FileName = "$(dir)/$(topology)/jld/$(algorithm)/Scenario_Availability_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_id)_$(option_num).jld"
if isfile(Scenario_Availability_FileName) == true
current_Scenario_Availability = load(Scenario_Availability_FileName, "Scenario_Availability")
Scenario_Availability[algorithm][tid, sid, t, s] = current_Scenario_Availability[algorithm][1,1] # assume parallel for single traffic and single scale
else
printstyled("Missing datafile $(Scenario_Availability_FileName)\n", color=:yellow)
Scenario_Availability[algorithm][tid, sid, t, s] = -1
end
end
if plotname == "flow_availability" || plotname == "all"
Flow_Availability_FileName = "$(dir)/$(topology)/jld/$(algorithm)/Flow_Availability_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_id)_$(option_num).jld"
if isfile(Flow_Availability_FileName) == true
current_Flow_Availability = load(Flow_Availability_FileName, "Flow_Availability")
Flow_Availability[algorithm][tid, sid, t, s] = current_Flow_Availability[algorithm][1,1] # assume parallel for single traffic and single scale
else
printstyled("Missing datafile $(Flow_Availability_FileName)\n", color=:yellow)
Flow_Availability[algorithm][tid, sid, t, s] = -1
end
end
if plotname == "bandwidth_availability" || plotname == "all"
Bandwidth_Availability_FileName = "$(dir)/$(topology)/jld/$(algorithm)/Bandwidth_Availability_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_id)_$(option_num).jld"
if isfile(Bandwidth_Availability_FileName) == true
current_Bandwidth_Availability = load(Bandwidth_Availability_FileName, "Bandwidth_Availability")
Bandwidth_Availability[algorithm][tid, sid, t, s] = current_Bandwidth_Availability[algorithm][1,1] # assume parallel for single traffic and single scale
else
printstyled("Missing datafile $(Bandwidth_Availability_FileName)\n", color=:yellow)
Bandwidth_Availability[algorithm][tid, sid, t, s] = -1
end
end
if plotname == "conditional_scenario_availability" || plotname == "all"
conditional_Scenario_Availability_FileName = "$(dir)/$(topology)/jld/$(algorithm)/conditional_Scenario_Availability_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_id)_$(option_num).jld"
if isfile(conditional_Scenario_Availability_FileName) == true
conditional_current_Scenario_Availability = load(conditional_Scenario_Availability_FileName, "conditional_Scenario_Availability")
conditional_Scenario_Availability[algorithm][tid, sid, t, s] = conditional_current_Scenario_Availability[algorithm][1,1] # assume parallel for single traffic and single scale
else
printstyled("Missing datafile $(conditional_Scenario_Availability_FileName)\n", color=:yellow)
conditional_Scenario_Availability[algorithm][tid, sid, t, s] = -1
end
end
if plotname == "conditional_flow_availability" || plotname == "all"
conditional_Flow_Availability_FileName = "$(dir)/$(topology)/jld/$(algorithm)/conditional_Flow_Availability_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_id)_$(option_num).jld"
if isfile(conditional_Flow_Availability_FileName) == true
conditional_current_Flow_Availability = load(conditional_Flow_Availability_FileName, "conditional_Flow_Availability")
conditional_Flow_Availability[algorithm][tid, sid, t, s] = conditional_current_Flow_Availability[algorithm][1,1] # assume parallel for single traffic and single scale
else
printstyled("Missing datafile $(conditional_Flow_Availability_FileName)\n", color=:yellow)
conditional_Flow_Availability[algorithm][tid, sid, t, s] = -1
end
end
if plotname == "conditional_bandwidth_availability" || plotname == "all"
conditional_Bandwidth_Availability_FileName = "$(dir)/$(topology)/jld/$(algorithm)/conditional_Bandwidth_Availability_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_id)_$(option_num).jld"
if isfile(conditional_Bandwidth_Availability_FileName) == true
conditional_current_Bandwidth_Availability = load(conditional_Bandwidth_Availability_FileName, "conditional_Bandwidth_Availability")
conditional_Bandwidth_Availability[algorithm][tid, sid, t, s] = conditional_current_Bandwidth_Availability[algorithm][1,1] # assume parallel for single traffic and single scale
else
printstyled("Missing datafile $(conditional_Bandwidth_Availability_FileName)\n", color=:yellow)
conditional_Bandwidth_Availability[algorithm][tid, sid, t, s] = -1
end
end
if plotname == "direct_throughput" || plotname == "all"
DirectThroughput_FileName = "$(dir)/$(topology)/jld/$(algorithm)/Direct_Throughput_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_id)_$(option_num).jld"
if isfile(DirectThroughput_FileName) == true
current_DirectThroughput = load(DirectThroughput_FileName, "DirectThroughput")
DirectThroughput[algorithm][tid, sid, t, s] = current_DirectThroughput[algorithm][1,1] # assume parallel for single traffic and single scale
else
printstyled("Missing datafile $(DirectThroughput_FileName)\n", color=:yellow)
DirectThroughput[algorithm][tid, sid, t, s] = -1
end
end
if plotname == "secure_throughput" || plotname == "all"
SecureThroughput_FileName = "$(dir)/$(topology)/jld/$(algorithm)/Secure_Throughput_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_id)_$(option_num).jld"
if isfile(SecureThroughput_FileName) == true
current_SecureThroughput = load(SecureThroughput_FileName, "SecureThroughput")
SecureThroughput[algorithm][tid, sid, t, s] = current_SecureThroughput[algorithm][1,1] # assume parallel for single traffic and single scale
else
printstyled("Missing datafile $(SecureThroughput_FileName)\n", color=:yellow)
SecureThroughput[algorithm][tid, sid, t, s] = -1
end
end
ProgressMeter.next!(progress, showvalues = [])
end
end
end
end
end
if plottype == "throughput"
ticket_DirectThroughput[algorithm] = zeros(length(tickets_topology_indexes), length(tickets_scenarios), length(tickets_AllTraffic), length(tickets))
ticket_SecureThroughput[algorithm] = zeros(length(tickets_topology_indexes), length(tickets_scenarios), length(tickets_AllTraffic), length(tickets))
if algorithm == "ARROW" || algorithm == "ARROW_BIN"
for tid in 1:length(tickets_topology_indexes)
topology_index = tickets_topology_indexes[tid]
for sid in 1:length(tickets_scenarios)
scenario_id = tickets_scenarios[sid]
for t in 1:length(tickets_AllTraffic)
traffic_id = tickets_AllTraffic[t]
for k in 1:length(tickets)
ticket_id = tickets[k]
ticket_DirectThroughput_FileName = "$(dir)/$(topology)/jld/$(algorithm)/Direct_Throughput_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_num)_$(ticket_id).jld"
if isfile(ticket_DirectThroughput_FileName) == true
ticket_current_DirectThroughput = load(ticket_DirectThroughput_FileName, "DirectThroughput")
ticket_DirectThroughput[algorithm][tid, sid, t, k] = ticket_current_DirectThroughput[algorithm][1,1] # assume parallel for single traffic and single ticket num
else
printstyled("Missing datafile $(ticket_DirectThroughput_FileName)\n", color=:yellow)
ticket_DirectThroughput[algorithm][tid, sid, t, k] = -1
end
ticket_SecureThroughput_FileName = "$(dir)/$(topology)/jld/$(algorithm)/Secure_Throughput_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_num)_$(ticket_id).jld"
if isfile(ticket_SecureThroughput_FileName) == true
ticket_current_SecureThroughput = load(ticket_SecureThroughput_FileName, "SecureThroughput")
ticket_SecureThroughput[algorithm][tid, sid, t, k] = ticket_current_SecureThroughput[algorithm][1,1] # assume parallel for single traffic and single ticket num
else
printstyled("Missing datafile $(ticket_SecureThroughput_FileName)\n", color=:yellow)
ticket_SecureThroughput[algorithm][tid, sid, t, k] = -1
end
ProgressMeter.next!(progress, showvalues = [])
end
end
end
end
else # FFC,TEAVAR,ARROW_NAIVE
for tid in 1:length(tickets_topology_indexes)
topology_index = tickets_topology_indexes[tid]
for sid in 1:length(tickets_scenarios)
scenario_id = tickets_scenarios[sid]
for t in 1:length(tickets_AllTraffic)
traffic_id = tickets_AllTraffic[t]
for k in 1:length(tickets)
ticket_id = 1
ticket_DirectThroughput_FileName = "$(dir)/$(topology)/jld/$(algorithm)/Direct_Throughput_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_num)_$(ticket_id).jld"
if isfile(ticket_DirectThroughput_FileName) == true
ticket_current_DirectThroughput = load(ticket_DirectThroughput_FileName, "DirectThroughput")
ticket_DirectThroughput[algorithm][tid, sid, t, k] = ticket_current_DirectThroughput[algorithm][1,1] # assume parallel for single traffic and single ticket num
else
printstyled("Missing datafile $(ticket_DirectThroughput_FileName)\n", color=:yellow)
ticket_DirectThroughput[algorithm][tid, sid, t, k] = -1
end
ticket_SecureThroughput_FileName = "$(dir)/$(topology)/jld/$(algorithm)/Secure_Throughput_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_num)_$(ticket_id).jld"
if isfile(ticket_SecureThroughput_FileName) == true
ticket_current_SecureThroughput = load(ticket_SecureThroughput_FileName, "SecureThroughput")
ticket_SecureThroughput[algorithm][tid, sid, t, k] = ticket_current_SecureThroughput[algorithm][1,1] # assume parallel for single traffic and single ticket num
else
printstyled("Missing datafile $(ticket_SecureThroughput_FileName)\n", color=:yellow)
ticket_SecureThroughput[algorithm][tid, sid, t, k] = -1
end
ProgressMeter.next!(progress, showvalues = [])
end
end
end
end
end
end
if plottype == "routerports"
Algo_RouterPorts[algorithm] = zeros(length(topology_indexes), length(scenarios), length(availability_AllTraffic), length(scales))
SecureThroughput[algorithm] = zeros(length(topology_indexes), length(scenarios), length(availability_AllTraffic), length(scales))
for tid in 1:length(topology_indexes)
topology_index = topology_indexes[tid]
for sid in 1:length(scenarios)
scenario_id = scenarios[sid]
for t in 1:length(availability_AllTraffic)
traffic_id = availability_AllTraffic[t]
for s in 1:length(scales)
scale_id = scales[s]
Algo_RouterPorts_Filename = "$(dir)/$(topology)/jld/$(algorithm)/Algo_RouterPorts_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_id)_$(option_num).jld"
if isfile(Algo_RouterPorts_Filename) == true
current_Algo_RouterPorts = load(Algo_RouterPorts_Filename, "Algo_RouterPorts")
Algo_RouterPorts[algorithm][tid, sid, t, s] = sum(current_Algo_RouterPorts[algorithm][1,1,:]) # assume parallel for single traffic and single scale
# println(Algo_RouterPorts[algorithm][tid, sid, t, s])
else
printstyled("Missing datafile $(Algo_RouterPorts_Filename)\n", color=:yellow)
Algo_RouterPorts[algorithm][tid, sid, t, s] = -1
# println(Algo_RouterPorts[algorithm][tid, sid, t, s])
end
SecureThroughput_FileName = "$(dir)/$(topology)/jld/$(algorithm)/Secure_Throughput_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_id)_$(option_num).jld"
if isfile(SecureThroughput_FileName) == true
current_SecureThroughput = load(SecureThroughput_FileName, "SecureThroughput")
SecureThroughput[algorithm][tid, sid, t, s] = current_SecureThroughput[algorithm][1,1] # assume parallel for single traffic and single scale
else
printstyled("Missing datafile $(SecureThroughput_FileName)\n", color=:yellow)
SecureThroughput[algorithm][tid, sid, t, s] = -1
end
ProgressMeter.next!(progress, showvalues = [])
end
end
end
end
end
if plottype == "optimizationtime"
Algo_SolveTime[algorithm] = zeros(length(topology_indexes), length(scenarios), length(availability_AllTraffic), length(scales))
for tid in 1:length(runtime_topology_indexes)
topology_index = runtime_topology_indexes[tid]
for sid in 1:length(runtime_scenarios)
scenario_id = runtime_scenarios[sid]
for t in 1:length(runtime_AllTraffic)
traffic_id = runtime_AllTraffic[t]
for k in 1:length(runtime_tickets)
runtime_option_num = runtime_tickets[k]
Algo_Runtime_Filename = "$(dir)/$(topology)/jld/$(algorithm)/Algo_Runtime_$(topology_index)_$(scenario_id)_$(traffic_id)_$(scale_num)_$(runtime_option_num).jld"
if isfile(Algo_Runtime_Filename) == true
current_Algo_SolveTime = load(Algo_Runtime_Filename, "Algo_Runtime")
Algo_SolveTime[algorithm][tid, sid, t, k] = current_Algo_SolveTime[algorithm][1,1] # assume parallel for single traffic and single scale
else
printstyled("Missing datafile $(Algo_Runtime_Filename)\n", color=:yellow)
Algo_SolveTime[algorithm][tid, sid, t, k] = -1
end
end
end
end
end
end
end
## plotting
if plottype == "availability"
if plotname == "scenario_availability" || plotname == "all"
println("plotting $(plotname)")
xname = "Demand scales"
yname = "Scenario availability"
figname = "$(dir)/$(topology)/scenario_availability.png"
figname2 = "$(dir)/$(topology)/scenario_availability_ribbon.png"
line_plot(scales, Scenario_Availability, xname, yname, figname, figname2, AllAlgorithms, false, true, inverse_log, false)
figname_zoom = "$(dir)/$(topology)/scenario_availability_zoom.png"
figname_zoom2 = "$(dir)/$(topology)/scenario_availability_zoom_ribbon.png"
line_plot(scales, Scenario_Availability, xname, yname, figname_zoom, figname_zoom2, AllAlgorithms, true, true, inverse_log, false)
figname_med = "$(dir)/$(topology)/scenario_availability_med.png"
figname2_med = "$(dir)/$(topology)/scenario_availability_ribbon_med.png"
line_plot(scales, Scenario_Availability, xname, yname, figname_med, figname2_med, AllAlgorithms, false, false, inverse_log, false)
figname_zoom_med = "$(dir)/$(topology)/scenario_availability_zoom_med.png"
figname_zoom2_med = "$(dir)/$(topology)/scenario_availability_zoom_ribbon_med.png"
line_plot(scales, Scenario_Availability, xname, yname, figname_zoom_med, figname_zoom2_med, AllAlgorithms, true, false, inverse_log, false)
end
if plotname == "flow_availability" || plotname == "all"
println("plotting $(plotname)")
xname = "Demand scales"
yname = "Flow availability"
figname = "$(dir)/$(topology)/flow_availability.png"
figname2 = "$(dir)/$(topology)/flow_availability_ribbon.png"
line_plot(scales, Flow_Availability, xname, yname, figname, figname2, AllAlgorithms, false, true, inverse_log, false)
figname_zoom = "$(dir)/$(topology)/flow_availability_zoom.png"
figname_zoom2 = "$(dir)/$(topology)/flow_availability_zoom_ribbon.png"
line_plot(scales, Flow_Availability, xname, yname, figname_zoom, figname_zoom2, AllAlgorithms, true, true, inverse_log, false)
figname_med = "$(dir)/$(topology)/flow_availability_med.png"
figname2_med = "$(dir)/$(topology)/flow_availability_ribbon_med.png"
line_plot(scales, Flow_Availability, xname, yname, figname_med, figname2_med, AllAlgorithms, false, false, inverse_log, false)
figname_zoom_med = "$(dir)/$(topology)/flow_availability_zoom_med.png"
figname_zoom2_med = "$(dir)/$(topology)/flow_availability_zoom_ribbon_med.png"
line_plot(scales, Flow_Availability, xname, yname, figname_zoom_med, figname_zoom2_med, AllAlgorithms, true, false, inverse_log, false)
end
if plotname == "bandwidth_availability" || plotname == "all"
println("plotting $(plotname)")
xname = "Demand scales"
yname = "Bandwidth availability"
figname = "$(dir)/$(topology)/bandwidth_availability.png"
figname2 = "$(dir)/$(topology)/bandwidth_availability_ribbon.png"
line_plot(scales, Bandwidth_Availability, xname, yname, figname, figname2, AllAlgorithms, false, true, inverse_log, false)
figname_zoom = "$(dir)/$(topology)/bandwidth_availability_zoom.png"
figname_zoom2 = "$(dir)/$(topology)/bandwidth_availability_zoom_ribbon.png"
line_plot(scales, Bandwidth_Availability, xname, yname, figname_zoom, figname_zoom2, AllAlgorithms, true, true, inverse_log, false)
figname_med = "$(dir)/$(topology)/bandwidth_availability_med.png"
figname2_med = "$(dir)/$(topology)/bandwidth_availability_ribbon_med.png"
line_plot(scales, Bandwidth_Availability, xname, yname, figname_med, figname2_med, AllAlgorithms, false, false, inverse_log, false)
figname_zoom_med = "$(dir)/$(topology)/bandwidth_availability_zoom_med.png"
figname_zoom2_med = "$(dir)/$(topology)/bandwidth_availability_zoom_ribbon_med.png"
line_plot(scales, Bandwidth_Availability, xname, yname, figname_zoom_med, figname_zoom2_med, AllAlgorithms, true, false, inverse_log, false)
end
if plotname == "conditional_scenario_availability" || plotname == "all"
println("plotting $(plotname)")
xname = "Demand scales"
yname = "conditional_Scenario availability"
figname = "$(dir)/$(topology)/conditional_scenario_availability.png"
figname2 = "$(dir)/$(topology)/conditional_scenario_availability_ribbon.png"
line_plot(scales, conditional_Scenario_Availability, xname, yname, figname, figname2, AllAlgorithms, false, true, inverse_log, false)
figname_zoom = "$(dir)/$(topology)/conditional_scenario_availability_zoom.png"
figname_zoom2 = "$(dir)/$(topology)/conditional_scenario_availability_zoom_ribbon.png"
line_plot(scales, conditional_Scenario_Availability, xname, yname, figname_zoom, figname_zoom2, AllAlgorithms, true, true, inverse_log, false)
figname_med = "$(dir)/$(topology)/conditional_scenario_availability_med.png"
figname2_med = "$(dir)/$(topology)/conditional_scenario_availability_ribbon_med.png"
line_plot(scales, conditional_Scenario_Availability, xname, yname, figname_med, figname2_med, AllAlgorithms, false, false, inverse_log, false)
figname_zoom_med = "$(dir)/$(topology)/conditional_scenario_availability_zoom_med.png"
figname_zoom2_med = "$(dir)/$(topology)/conditional_scenario_availability_zoom_ribbon_med.png"
line_plot(scales, conditional_Scenario_Availability, xname, yname, figname_zoom_med, figname_zoom2_med, AllAlgorithms, true, false, inverse_log, false)
end
if plotname == "conditional_flow_availability" || plotname == "all"
println("plotting $(plotname)")
xname = "Demand scales"
yname = "conditional_Flow availability"
figname = "$(dir)/$(topology)/conditional_flow_availability.png"
figname2 = "$(dir)/$(topology)/conditional_flow_availability_ribbon.png"
line_plot(scales, conditional_Flow_Availability, xname, yname, figname, figname2, AllAlgorithms, false, true, inverse_log, false)
figname_zoom = "$(dir)/$(topology)/conditional_flow_availability_zoom.png"
figname_zoom2 = "$(dir)/$(topology)/conditional_flow_availability_zoom_ribbon.png"
line_plot(scales, conditional_Flow_Availability, xname, yname, figname_zoom, figname_zoom2, AllAlgorithms, true, true, inverse_log, false)
figname_med = "$(dir)/$(topology)/conditional_flow_availability_med.png"
figname2_med = "$(dir)/$(topology)/conditional_flow_availability_ribbon_med.png"
line_plot(scales, conditional_Flow_Availability, xname, yname, figname_med, figname2_med, AllAlgorithms, false, false, inverse_log, false)
figname_zoom_med = "$(dir)/$(topology)/conditional_flow_availability_zoom_med.png"
figname_zoom2_med = "$(dir)/$(topology)/conditional_flow_availability_zoom_ribbon_med.png"
line_plot(scales, conditional_Flow_Availability, xname, yname, figname_zoom_med, figname_zoom2_med, AllAlgorithms, true, false, inverse_log, false)
end
if plotname == "conditional_bandwidth_availability" || plotname == "all"
println("plotting $(plotname)")
xname = "Demand scales"
yname = "conditional Bandwidth availability"
figname = "$(dir)/$(topology)/conditional_bandwidth_availability.png"
figname2 = "$(dir)/$(topology)/conditional_bandwidth_availability_ribbon.png"
line_plot(scales, conditional_Bandwidth_Availability, xname, yname, figname, figname2, AllAlgorithms, false, true, inverse_log, false)
figname_zoom = "$(dir)/$(topology)/conditional_bandwidth_availability_zoom.png"
figname_zoom2 = "$(dir)/$(topology)/conditional_bandwidth_availability_zoom_ribbon.png"
line_plot(scales, conditional_Bandwidth_Availability, xname, yname, figname_zoom, figname_zoom2, AllAlgorithms, true, true, inverse_log, false)
figname_med = "$(dir)/$(topology)/conditional_bandwidth_availability_med.png"
figname2_med = "$(dir)/$(topology)/conditional_bandwidth_availability_ribbon_med.png"
line_plot(scales, conditional_Bandwidth_Availability, xname, yname, figname_med, figname2_med, AllAlgorithms, false, false, inverse_log, false)
figname_zoom_med = "$(dir)/$(topology)/conditional_bandwidth_availability_zoom_med.png"
figname_zoom2_med = "$(dir)/$(topology)/conditional_bandwidth_availability_zoom_ribbon_med.png"
line_plot(scales, conditional_Bandwidth_Availability, xname, yname, figname_zoom_med, figname_zoom2_med, AllAlgorithms, true, false, inverse_log, false)
end
if plotname == "direct_throughput" || plotname == "all"
println("plotting $(plotname)")
xname = "Demand scales"
yname = "Direct throughput"
figname = "$(dir)/$(topology)/DirectThroughput.png"
figname2 = "$(dir)/$(topology)/DirectThroughput_ribbon.png"
line_plot(scales, DirectThroughput, xname, yname, figname, figname2, AllAlgorithms, false, true, false, true)
figname_med = "$(dir)/$(topology)/DirectThroughput_med.png"
figname2_med = "$(dir)/$(topology)/DirectThroughput_ribbon_med.png"
line_plot(scales, DirectThroughput, xname, yname, figname_med, figname2_med, AllAlgorithms, false, false, false, true)
end
if plotname == "secure_throughput" || plotname == "all"
println("plotting $(plotname)")
xname = "Demand scales"
yname = "Guaranteed throughput under Availability"
figname = "$(dir)/$(topology)/SecureThroughput.png"
figname2 = "$(dir)/$(topology)/SecureThroughput_ribbon.png"
line_plot(scales, SecureThroughput, xname, yname, figname, figname2, AllAlgorithms, false, true, false, true)
figname_med = "$(dir)/$(topology)/SecureThroughput_med.png"
figname2_med = "$(dir)/$(topology)/SecureThroughput_ribbon_med.png"
line_plot(scales, SecureThroughput, xname, yname, figname_med, figname2_med, AllAlgorithms, false, false, false, true)
end
open("$(dir)/$(topology)/Availability.txt", "w+") do io
writedlm(io, ("ScenarioAvailability",))
for alg in AllAlgorithms
writedlm(io, (alg, Scenario_Availability[alg]))
end
writedlm(io, ("FlowAvailability",))
for alg in AllAlgorithms
writedlm(io, (alg, Flow_Availability[alg]))
end
writedlm(io, ("BandwidthAvailability",))
for alg in AllAlgorithms
writedlm(io, (alg, Bandwidth_Availability[alg]))
end
end
if plotname == "direct_throughput" || plotname == "secure_throughput" || plotname == "all"
open("$(dir)/$(topology)/Throughput.txt", "w+") do io
writedlm(io, ("Guaranteed Throughput",))
for alg in AllAlgorithms
writedlm(io, (alg, SecureThroughput[alg]))
end
writedlm(io, ("Direct Throughput",))
for alg in AllAlgorithms
writedlm(io, (alg, DirectThroughput[alg]))
end
end
end
end
if plottype == "throughput"
xname = "Number of Lottery Tickets"
yname = "Guaranteed throughput under Availability"
figname = "$(dir)/$(topology)/SecureThroughput.png"
figname2 = "$(dir)/$(topology)/SecureThroughput_ribbon.png"
line_plot(tickets, ticket_SecureThroughput, xname, yname, figname, figname2, AllAlgorithms, false, true, false, true)
figname_med = "$(dir)/$(topology)/SecureThroughput_med.png"
figname2_med = "$(dir)/$(topology)/SecureThroughput_ribbon_med.png"
line_plot(tickets, ticket_SecureThroughput, xname, yname, figname_med, figname2_med, AllAlgorithms, false, false, false, true)
xname = "Number of Lottery Tickets"
yname = "Direct throughput"
figname = "$(dir)/$(topology)/DirectThroughput.png"
figname2 = "$(dir)/$(topology)/DirectThroughput_ribbon.png"
line_plot(tickets, ticket_DirectThroughput, xname, yname, figname, figname2, AllAlgorithms, false, true, false, true)
figname_med = "$(dir)/$(topology)/DirectThroughput_med.png"
figname2_med = "$(dir)/$(topology)/DirectThroughput_ribbon_med.png"
line_plot(tickets, ticket_DirectThroughput, xname, yname, figname_med, figname2_med, AllAlgorithms, false, false, false, true)
open("$(dir)/$(topology)/Throughput.txt", "w+") do io
writedlm(io, ("Guaranteed Throughput",))
for alg in AllAlgorithms
writedlm(io, (alg, ticket_SecureThroughput[alg]))
end
writedlm(io, ("Direct Throughput",))
for alg in AllAlgorithms
writedlm(io, (alg, ticket_DirectThroughput[alg]))
end
end
end
if plottype == "routerports"
colormap = Dict(
"HYPERTHETICAL" => "black",
"ARROW" => "red",
"ARROW_NAIVE" => "blue",
"ARROW_BIN" => "red",
"FFC1" => "green",
"FFC2" => "yellow",
"TEAVAR" => "purple",
"ECMP" => "orange",
)
all_sum_routerports = zeros(length(AllAlgorithms))
nbars = length(AllAlgorithms)
barWidth = 1/(nbars + 1)
open("$(dir)/$(topology)/routerports.txt", "w+") do io
writedlm(io, ("Router Ports",))
for s in 1:length(scales)
scale_id = scales[s]
average_routerports = zeros(length(AllAlgorithms))
for aa in 1:length(AllAlgorithms)
algorithm = AllAlgorithms[aa]
vectorized = reshape(Algo_RouterPorts[algorithm][:,:,:,s], size(Algo_RouterPorts[algorithm][:,:,:,s],1)*size(Algo_RouterPorts[algorithm][:,:,:,s],2)*size(Algo_RouterPorts[algorithm][:,:,:,s],3))
null_position = findall(x->x==-1, vectorized)
vectorized = deleteat!(vectorized, null_position)
nan_position = findall(x->isnan(x), vectorized)
real_vectorized = deleteat!(vectorized, nan_position)
average_routerports[aa] = sum(real_vectorized)
end
average_routerports /= length(availability_AllTraffic)*length(scenarios)
PyPlot.clf()
sum_routerports = zeros(length(AllAlgorithms))
for aa in 1:length(AllAlgorithms)
# calculate secure throughput
vectorized = reshape(SecureThroughput[AllAlgorithms[aa]][:,:,:,s], size(SecureThroughput[AllAlgorithms[aa]][:,:,:,s],1)*size(SecureThroughput[AllAlgorithms[aa]][:,:,:,s],2)*size(SecureThroughput[AllAlgorithms[aa]][:,:,:,s],3))
null_position = findall(x->x==-1, vectorized)
vectorized = deleteat!(vectorized, null_position)
nan_position = findall(x->isnan(x), vectorized)
real_vectorized = deleteat!(vectorized, nan_position)
throughput_avg = round(sum(real_vectorized)/length(real_vectorized), digits=4)
if throughput_avg == 0 || isnan(average_routerports[aa]) || isnan(throughput_avg)
sum_routerports[aa] = 0
else
# println("average_routerports[aa] ", average_routerports[aa], " throughput_avg ", throughput_avg)
sum_routerports[aa] = average_routerports[aa] / throughput_avg
end
all_sum_routerports[aa] += sum_routerports[aa]
writedlm(io, (scale_id, AllAlgorithms[aa], average_routerports[aa], throughput_avg, sum_routerports[aa]))
end
## Normalized with respect to max router ports
# max_routerports = maximum(sum_routerports)
# normalized_sum_routerports = sum_routerports ./ max_routerports
## Normalized with respect to hyperthetical TE
hyperthetical_routerports = sum_routerports[1] # fix the first one to be hyperthetical
normalized_sum_routerports = sum_routerports ./ hyperthetical_routerports
# println("normalized_sum_routerports ", normalized_sum_routerports)
for aa in 1:length(AllAlgorithms)
PyPlot.bar(AllAlgorithms[aa], normalized_sum_routerports[aa], width=barWidth, alpha = 0.8, label=AllAlgorithms[aa], color=colormap[AllAlgorithms[aa]])
end
PyPlot.xlabel("TE algorithms")
PyPlot.ylabel("Router ports (overall subscribed link bw)")
PyPlot.xticks(rotation=45)
figname = "$(dir)/$(topology)/router_ports_$(scale_id).png"
PyPlot.title(topology)
PyPlot.savefig(figname)
end
end
PyPlot.clf()
## Normalized with respect to max router ports
# max_all_routerports = maximum(all_sum_routerports)
# normalized_all_sum_routerports = all_sum_routerports ./ max_all_routerports
## Normalized with respect to hyperthetical TE
hyperthetical_all_routerports = all_sum_routerports[1] # fix the first one to be hyperthetical
normalized_all_sum_routerports = all_sum_routerports ./ hyperthetical_all_routerports
println("normalized_all_sum_routerports ", normalized_all_sum_routerports)
for aa in 1:length(AllAlgorithms)
PyPlot.bar(AllAlgorithms[aa], normalized_all_sum_routerports[aa], width=barWidth, alpha = 0.8, label=AllAlgorithms[aa], color=colormap[AllAlgorithms[aa]])
end
PyPlot.xlabel("TE algorithms")
PyPlot.ylabel("Router ports (overall subscribed link bw)")
PyPlot.xticks(rotation=45)
figname = "$(dir)/$(topology)/router_ports_all.png"
PyPlot.title(topology)
PyPlot.savefig(figname)
open("$(dir)/$(topology)/routerports_agg.txt", "w+") do io
writedlm(io, ("Normalized Router Ports",))
for aa in 1:length(AllAlgorithms)
writedlm(io, (AllAlgorithms[aa], normalized_all_sum_routerports[aa]))
end
end
end
if plottype == "optimizationtime"
average_runtime = zeros(length(AllAlgorithms),length(lotteryticket_set))
for aa in 1:length(AllAlgorithms)
algorithm = AllAlgorithms[aa]
for k in 1:length(lotteryticket_set)
vectorized = reshape(Algo_SolveTime[algorithm][:,:,:,k], size(Algo_SolveTime[algorithm][:,:,:,k],1)*size(Algo_SolveTime[algorithm][:,:,:,k],2)*size(Algo_SolveTime[algorithm][:,:,:,k],3))
null_position = findall(x->x==-1, vectorized)
vectorized = deleteat!(vectorized, null_position)
nan_position = findall(x->isnan(x), vectorized)
real_vectorized = deleteat!(vectorized, nan_position)
average_runtime[aa,k] = round(sum(real_vectorized)/length(real_vectorized), digits=4)
end
end
PyPlot.clf()
nbars = length(AllAlgorithms)
barWidth = 1/(nbars + 1)
for aa in 1:length(AllAlgorithms)
for k in 1:length(lotteryticket_set)
PyPlot.bar(lotteryticket_set[k], average_runtime[aa,k], width=barWidth, alpha = 0.8, label=lotteryticket_set[k])
end
end
PyPlot.xlabel("Number of Lottery Tickets")
PyPlot.ylabel("Optimization Solve Time (seconds)")
PyPlot.xticks(rotation=45)
figname = "$(dir)/$(topology)/optimization_solve_time.png"
PyPlot.title(topology)
PyPlot.savefig(figname)
open("$(dir)/$(topology)/optimization_solve_time.txt", "w+") do io
writedlm(io, ("Optimization solve time",))
for aa in 1:length(AllAlgorithms)
writedlm(io, (AllAlgorithms[aa], average_runtime[aa]))
end
end
end
printstyled("\nTE simulation completed! Please find $(topology)'s [$(plottype) ($(plotname))] results in $(dir)\n\n", color=:blue)
end
parallel_plot()