initial commit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
import os
|
||||
|
||||
csv_file = "results/synthetic_data/raw/20260302_183202.csv"
|
||||
save_folder = f"results/synthetic_data/derived/{os.path.splitext(os.path.basename(csv_file))[0]}"
|
||||
os.makedirs(save_folder, exist_ok=True)
|
||||
|
||||
df = pd.read_csv(csv_file)
|
||||
# df = df[df["reached"] == True].copy()
|
||||
|
||||
key_cols = ["nodes", "density", "std", "sigma", "trial", "seed"]
|
||||
|
||||
pivot_time = (
|
||||
df.pivot_table(index=key_cols, columns="algorithm", values="time", aggfunc="mean")
|
||||
.reset_index()
|
||||
)
|
||||
pivot_time["speed_ratio"] = pivot_time["binary"] / pivot_time["fibonacci"]
|
||||
|
||||
# print((pivot_time["speed_ratio"] > 1).sum())
|
||||
# print((pivot_time["speed_ratio"] < 1).sum())
|
||||
|
||||
relax = (
|
||||
df[df["algorithm"] == "binary"][key_cols + ["relax_success"]]
|
||||
)
|
||||
|
||||
merged = pivot_time.merge(relax, on=key_cols, how="left")
|
||||
|
||||
plt.figure(figsize=(6, 4))
|
||||
plt.scatter(merged["relax_success"], merged["speed_ratio"], marker=".")
|
||||
plt.axhline(y=1.0, color='red', linestyle='--')
|
||||
plt.xlabel("decrease_key (binary)")
|
||||
plt.ylabel("speed_ratio (binary / fibonacci)")
|
||||
plt.title("decrease_key vs speed_ratio")
|
||||
plt.grid(True)
|
||||
plt.tight_layout()
|
||||
plt.savefig(f"{save_folder}/decrease_key_vs_speed_ratio.png", dpi=300)
|
||||
plt.close()
|
||||
Reference in New Issue
Block a user