in scripts/figs.py [0:0]
def draw_PR_heuristics(double=True):
# Define heuristics and data
heuristics = [
"No\nRep", "Access Traffic\nVolume", "Inverse\nDataset Size",
"Job Access\nFrequency", "Access Traffic\nDensity", "Job Access\nDensity (Moirai)"
]
replication_times = [(93+254+94)/3, (120+181+15)/3, (20+111+11)/3, (11+87+34)/3, (55+119+48)/3, (2+3+1)/3] # Approximate from table (h)
num_edges = [1252, 1102, 855, 763, 819, 509] # In K
num_jobs = [356, 350, 307, 322, 330, 256] # In K
num_tables = [134, 133, 113, 133, 133, 119] # In K
x = np.arange(len(heuristics)) # the label locations
if double:
width = 0.25
fig, axes = plt.subplots(2, 1, figsize=(15, 6), sharex=True)
ax1, ax2 = axes
ax1.bar(x, replication_times, width, color='skyblue')
ax1.set_ylabel("Optimization\nTime (hr)")
ax1.set_ylim(0, 168)
ax1.grid(axis='y')
ax2.bar(x - width, num_edges, width, label="# Edges", color='salmon', hatch='/')
ax2.bar(x, num_jobs, width, label="# Jobs", color='mediumseagreen', hatch='\\')
ax2.bar(x + width, num_tables, width, label="# Tables", color='mediumpurple', hatch='|')
ax2.set_ylabel("Count (K)")
ax2.set_ylim(0, 1500)
ax2.set_xticks(x)
ax2.set_xticklabels(heuristics)
ax2.grid(axis='y', linestyle='--', alpha=0.6)
ax2.legend()
else:
width = 0.18
fig, ax1 = plt.subplots(figsize=(14, 4.5))
ax2 = ax1.twinx()
# Adjust positions so all 4 bars are shown for each heuristic
ax1.bar(x - 1.7 * width, replication_times, width, label="Optimization Time", color=colors_default[0])
ax1.legend(loc='upper left', fontsize=font_size + 3)
for i, time in enumerate(replication_times):
ax1.text(
x[i] - 2.4 * width if (i == 0 or i == 1) else x[i] - 2 * width, time + 3, # position slightly above the bar
f"{round(time)}hr", ha='center', va='bottom', fontsize=font_size + 1
)
ax2.bar(x - 0.4 * width, num_edges, width, label="# Edges", color=colors_default[1], hatch='/')
ax2.bar(x + 0.6 * width, num_jobs, width, label="# Jobs", color=colors_default[2], hatch='\\')
ax2.bar(x + 1.6 * width, num_tables, width, label="# Tables", color=colors_default[3], hatch='|')
ax2.legend(loc='upper right', fontsize=font_size+3)
ax1.set_ylabel("Optimization\nTime (hr)", fontsize=font_size + 2)
ax1.set_ylim(0, 250)
# ax1.grid(axis='y')
yticks = ax1.get_yticks()
ax1.set_yticks(yticks)
ax1.set_yticklabels([int(tick) for tick in yticks], fontsize=font_size + 2)
ax2.set_ylabel("Count (K)", fontsize=font_size + 2)
ax2.set_ylim(0, 1500)
ax1.set_xticks(x)
ax1.set_xticklabels(heuristics, rotation=10)
ax2.grid(axis='y', linestyle='--', alpha=0.6)
ax2.set_yticklabels([int(x) for x in ax2.get_yticks()], fontsize=font_size + 2)
# # Merge legends from both axes
# bars, labels = [], []
# for ax in [ax1, ax2]:
# h, l = ax.get_legend_handles_labels()
# bars += h
# labels += l
# ax2.legend(bars, labels, loc='upper right', fontsize=font_size + 2)
plt.tight_layout()
plt.savefig(f"optimization_time_{double}.pdf", bbox_inches='tight')