35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
import pandas as pd
|
|
import matplotlib
|
|
matplotlib.use("Agg")
|
|
import matplotlib.pyplot as plt
|
|
from fleet_sim import run, STRATEGIES
|
|
|
|
KEYS = ("strategy", "robots", "seed", "tasks_per_hour", "total_wait",
|
|
"wait_per_task", "replans", "yields", "charge_steps")
|
|
ROBOT_COUNTS = (2, 4, 6, 8, 10)
|
|
|
|
rows = []
|
|
for strat in STRATEGIES:
|
|
for n in ROBOT_COUNTS:
|
|
for seed in range(5):
|
|
r = run(n, strat, seed=seed)
|
|
rows.append({k: r[k] for k in KEYS})
|
|
|
|
df = pd.DataFrame(rows)
|
|
df.to_csv("results/experiments.csv", index=False)
|
|
summary = df.groupby(["strategy", "robots"]).mean(numeric_only=True).reset_index()
|
|
print(summary[["strategy", "robots", "tasks_per_hour", "wait_per_task", "yields"]].round(1).to_string(index=False))
|
|
|
|
fig, ax = plt.subplots(1, 2, figsize=(11, 4))
|
|
for strat, g in summary.groupby("strategy"):
|
|
ax[0].plot(g.robots, g.tasks_per_hour, marker="o", label=strat)
|
|
ax[1].plot(g.robots, g.wait_per_task, marker="o", label=strat)
|
|
ax[0].set(title="Throughput vs fleet size", xlabel="Robots", ylabel="Tasks per hour")
|
|
ax[1].set(title="Waiting time vs fleet size", xlabel="Robots", ylabel="Seconds waiting per task")
|
|
ax[0].legend()
|
|
ax[0].grid(alpha=0.3)
|
|
ax[1].grid(alpha=0.3)
|
|
fig.tight_layout()
|
|
fig.savefig("results/throughput.png", dpi=150)
|
|
# plt.show()
|