"""One local page to review everything built so far -> pipeline/REVIEW.html (regenerated from build/, never hand-edited)."""
import json, re, html, pathlib, sys
sys.path.insert(0, str(pathlib.Path(__file__).parent))
from common import BUILD, ROOT
REP = BUILD/"report"
def md_to_html(md):
out, rows = [], []
def flush():
if rows:
head, body = rows[0], [r for r in rows[2:]]
out.append("
" + "".join(f"| {html.escape(c)} | " for c in head) + "
"
+ "".join("" + "".join(f"| {html.escape(c)} | " for c in r) + "
" for r in body) + "
")
rows.clear()
for line in md.splitlines():
if line.startswith("|"):
rows.append([c.strip() for c in line.strip("|").split("|")])
else:
flush()
if line.startswith("# "):
continue
elif line.strip():
out.append(f"{html.escape(line)}
")
flush()
return "\n".join(out)
def section(title, body, open_=False):
return f"{title}
{body}
"
def main():
S = json.load(open(BUILD/"results_summary.json"))
cur = S["county-current"]["delay_mean"]
best = min(S.items(), key=lambda kv: kv[1]["delay_mean"])
s1 = json.load(open(BUILD/"study1/summary.json"))
V = json.load(open(BUILD/"validation.json")); inter = [r for r in V if r["kind"] == "interior"]
rd = lambda n: (REP/n).read_text() if (REP/n).exists() else ""
ready = [
("Real corridor data (County timing + counts, all 4 lights), verified against printed totals", "ready", "data/measured/, build/report/volumes.md, timing.md"),
("Where every number comes from (measured / derived / assumed)", "ready", "build/report/provenance.md"),
("SUMO network + traffic demand, checked against counts", "ready", f"validation: {sum(r['geh'] < 5 for r in inter)}/{len(inter)} interior approaches GEH < 5"),
("Plan → SUMO pipeline, every plan run with 10 seeds", "ready", "build/results_summary.json, build/report/results.md"),
("Baselines: County current (real), equal split, Webster, SUMO coordination", "ready", "plans/"),
("Study 1 (simulator-in-the-loop vs formula)", "ready (first full run)", "build/study1/"),
("Code package + README rerun (./run_all.sh)", "ready for our part", "pipeline/README.md"),
("Michael + Noah's optimizer plugged in", "NOT YET: stand-in used", "src/plans.py::from_their_format, src/to_optimizer.py"),
("Group sign-off: corridor switch, model input changes (lost time, capacity), left arrows", "NOT YET", "message the group"),
("Written report (8-12 pp): our Data/Setup/Study 1 sections", "NOT YET written", "tables + figures ready to drop in"),
("Other members' sections, Contributions lines, final PDF, package email to TA", "NOT YET", "comes after the above"),
]
status_rows = "".join(f"| {a} | {s} | {w} |
" for a, s, w in ready)
page = f"""Traffic Project Review
CSE 5403 traffic project: our part, review
Big Bend Blvd, Forest Park Pkwy → Clayton Rd, PM peak · generated from pipeline/build · not the final report
{cur:.0f}veh-h/h delay, County's current PM timing (simulated)
{best[1]['delay_mean']:.0f}best plan ({best[0]}): {100*(1-best[1]['delay_mean']/cur):.0f}% less delay
{sum(r['geh'] < 5 for r in inter)}/{len(inter)}simulated volumes match County counts (GEH < 5)
{s1['prediction']['spearman']:.2f}formula vs SUMO rank correlation (Study 1, 30 plans)
Is it submission-ready?
No. Our technical pieces are done and reproducible; the report and the final package are not written yet, and two things wait on the group.
| piece | status | where |
{status_rows}
{section("Results: every plan (SUMO, 10 seeds)", md_to_html(rd("results.md")), True)}
{section("Validation: simulated vs counted volumes", md_to_html(rd("validation.md")))}
{section("Measured PM volumes and turn shares", md_to_html(rd("volumes.md")))}
{section("County PM timing (from the sheets)", md_to_html(rd("timing.md")))}
{section("Where every number comes from", md_to_html(rd("provenance.md")))}
{section("Study 1 numbers", ""+html.escape(json.dumps(s1, indent=1))+"
")}
{section("Choices to tell the group", "- Simulated network generated from real data (raw OpenStreetMap version jammed on side merges; still available).
- SUMO runs each plan with the County's real phase sequence incl. left arrows, arrows sized to measured left-turn traffic.
- Model inputs changed (Michael + Noah to approve): lost time and capacity worked out along the real signal sequence. Switchable back.
- Right turn on red; 90 m left bays (assumed); small mid-block flows for side streets/driveways; design hour 5-6 PM.
- 'formula-optimum-standin' is our implementation of their model until signal_opt.py arrives.
")}
"""
(ROOT/"REVIEW.html").write_text(page)
print("wrote", ROOT/"REVIEW.html")
if __name__ == "__main__":
main()