File size: 1,408 Bytes
81ae663 | 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 | """Measure route multiplicity and temperature effects from exact graph laws."""
import argparse
from pathlib import Path
import pandas as pd
from dooable.graph import toy_graph
from dooable.exact import solve, tilted_reference, endpoint_distribution, expected_cost
def main():
p = argparse.ArgumentParser()
p.add_argument("--output", default="results/exact_sweep")
args = p.parse_args()
out = Path(args.output)
out.mkdir(parents=True, exist_ok=True)
rows = []
for multiplicity in [1, 2, 4, 8, 16]:
graph = toy_graph(multiplicity)
rewards = {"A": 0.0, "B": 0.0}
for temperature in [0.1, 0.3, 0.7, 1.0, 2.0]:
for name, policy in [
("exact", solve(graph, rewards, temperature).forward),
("reference_tilt", tilted_reference(graph, rewards)),
]:
rows.append(
{
"multiplicity": multiplicity,
"temperature": temperature,
"method": name,
"probability_A": endpoint_distribution(graph, policy)["A"],
"mean_cost": expected_cost(graph, policy),
}
)
pd.DataFrame(rows).to_csv(out / "measurements.csv", index=False)
print(f"Saved {len(rows)} exact comparisons to {out}")
if __name__ == "__main__":
main()
|