-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot4.py
More file actions
56 lines (44 loc) · 3.58 KB
/
plot4.py
File metadata and controls
56 lines (44 loc) · 3.58 KB
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
import matplotlib.pyplot as plt
import numpy as np
def percentage(base, cost):
return [a/b for a, b in zip(cost, base)]
fig = plt.figure()
ax = fig.add_subplot()
size_list = ['Facebook1', 'Facebook2', 'Microsoft1', 'Microsoft2', 'pFabric', 'ProjecToR']
# facebook, cluster C, shuffled
chord = [1309.9208221684503, 805.6022218947872, 359.0544290914899, 422.28302679558215, 1309.9208221684503, 345.9098019664969]
binary_search_in_buckets_local_routing = [776.159635422484, 735.8556994243837, 157.1768693108454, 219.8985787775248, 1267.1177511905141, 157.64150985235173]
binary_search_in_buckets_shortest_path_routing = [550.3324722783392, 505.0317893720176, 140.0560689399199, 193.16371129671916, 896.9668479531698, 139.8326874875196]
# binary_search_unrestricted_one_side = [735.6088018603198, 685.0277930994928, 195.6402336072743, 261.2735789774195, 1199.5820301137944, 205.2401154999259]
# binary_search_unrestricted_both_sides = [497.2676278759026, 459.89835732820626, 153.18782746809921, 185.64438441782258, 807.6513363228069, 152.3170599461329]
global_view_round_by_round_local_routing = [807.5800730967522, 761.3790811126273, 173.72571076173307, 246.94714686313932, 1277.1412962982756, 178.53924153943436]
global_view_round_by_round_shortest_path_routing = [465.93666470008077, 424.51727035241566, 121.0033146485735, 155.51091784622417, 750.8984141834092, 122.69394328879679]
permutations = [602.1853576465742, 557.0543873296123, 231.64406622350208, 288.90590285662284, 900.5868111236957, 233.83907238407605]
total_width, n_algos = 0.9, 6
width = total_width / n_algos
x_chord = list(range(len(size_list)))
# for index in range(len(x_chord)):
# x_chord[index] *= 2
x_BS_restricted_LR = [pos + width for pos in x_chord]
x_BS_restricted_SPR = [pos + 2*width for pos in x_chord]
# x_BS_unrestricted_OS =[pos + 3*width for pos in x_chord]
# x_BS_unrestricted_BS = [pos + 4*width for pos in x_chord]
x_GV_round_LR = [pos + 3*width for pos in x_chord]
x_GV_round_SPR = [pos + 4*width for pos in x_chord]
x_perm = [pos + 5*width for pos in x_chord]
ax.bar(x_chord, percentage(chord, chord), width=width, label='Chord', color='#4C6643')
ax.bar(x_BS_restricted_LR, percentage(chord, binary_search_in_buckets_local_routing), width=width, label='BS in buckets with local routing', color='#AFCFA6')
ax.bar(x_BS_restricted_SPR, percentage(chord, binary_search_in_buckets_shortest_path_routing), width=width, label='BS in buckets with shortest path routing', color='#F5D44B')
# ax.bar(x_BS_unrestricted_OS, percentage(chord, binary_search_unrestricted_one_side), width=width, label='BS from one side', color='#D47828')
# ax.bar(x_BS_unrestricted_BS, percentage(chord, binary_search_unrestricted_both_sides), width=width, label='BS from both sides', color='#B73508')
# ax.bar(x_GV_round_LR, percentage(chord, global_view_round_by_round_local_routing), width=width, label='demand-aware global view with local routing', color='#CF929E')
ax.bar(x_GV_round_LR, percentage(chord, global_view_round_by_round_local_routing), width=width, label='demand-aware global view with local routing', color='#D47828')
ax.bar(x_GV_round_SPR, percentage(chord, global_view_round_by_round_shortest_path_routing), width=width, label='demand-aware global view with shortest path routing', color='#B73508')
ax.bar(x_perm, percentage(chord, permutations), width=width, label='permutations', color='#CF929E')
ax.set_xticks([pos+total_width/2-width/2 for pos in x_chord], size_list)
ax.set_xlabel('dataset')
ax.set_ylabel('Cost ratio to Chord')
ax.set_title('Demand-aware peer selection algorithms')
plt.legend(fontsize=6)
plt.savefig('./Figures/algorithms_20230831.pdf')
plt.show()