"""Public progress page for the group -> build/site/ (index.html + figures). Regenerated from build/; never hand-edit. Deploy: npx wrangler pages deploy build/site --project-name bigbend-signal-study """ import json, html, shutil, pathlib, sys, datetime sys.path.insert(0, str(pathlib.Path(__file__).parent)) from common import BUILD, ROOT, corridor import plans as P import site_figs as F import site_explain as X SITE = BUILD/"site" E = html.escape def tbl(head, rows, cls=""): return (f'
' + "".join(f"" for h in head) + "" + "".join("" + "".join(f"" for c in r) + "" for r in rows) + "
{h}
{c}
") def main(): SITE.mkdir(parents=True, exist_ok=True) for src, dst in ((BUILD/"report/results.png", "results.png"), (BUILD/"report/corridor.png", "corridor.png"), (BUILD/"study1/prediction.png", "study1-prediction.png"), (BUILD/"study1/convergence.png", "study1-convergence.png")): shutil.copy(src, SITE/dst) cor = corridor(); S = json.load(open(BUILD/"results_summary.json")); V = json.load(open(BUILD/"validation.json")) s1 = json.load(open(BUILD/"study1/summary.json")); dem = json.load(open(BUILD/"sumo/demand.json")) cur = S["county-current"]["delay_mean"]; fo = S["formula-optimum-standin"]["delay_mean"]; sl = S["study1-sumo-loop"]["delay_mean"] inter = [r for r in V if r["kind"] == "interior"]; ok = sum(r["geh"] < 5 for r in inter) tot = sum(A["q_vph"] for l in cor["lights"] for A in l["approaches"].values()) today = datetime.date.today().strftime("%B %-d, %Y") # tables vol = [[f"{l['name']} (#{l['id']})", d, f"{A['q_vph']:.0f}", f"{A['turn_share']['L']:.2f}", f"{A['turn_share']['T']:.2f}", f"{A['turn_share']['R']:.2f}", A["lanes"], E(A["q_ref"].split("/")[-1])] for l in cor["lights"] for d, A in l["approaches"].items()] tim = [] for l in cor["lights"]: T = l["timing"] tim.append([f"{l['name']} (#{l['id']})", E(T["sheet_date"]), T["pattern"], T["C_s"], T["offset_county_s"], " ".join(f"{k}:{v}" for k, v in sorted(T["splits"].items(), key=lambda kv: int(kv[0]))), T["main_block_s"], T["side_block_s"], T["L_s"]]) links = [[f"{k['from']} → {k['to']}", f"{k['length_m']:.0f}", f"{k['speed_mps']:.1f}", f"{k['tau_s']:.1f}"] for k in cor["links"]] res = [] for name, v in sorted(S.items(), key=lambda kv: kv[1]["delay_mean"]): pl = P.load(name); fd = P.formula_delay(cor, pl) res.append([f"{E(name)}" if name in ("county-current",) else E(name), f"{pl['C']:.1f}", f"{v['delay_mean']:.1f} ± {v['delay_sd']:.1f}", f"{100*(v['delay_mean']/cur-1):+.0f}%", f"{v['stops_mean']:.2f}", f"{v['throughput_mean']:.0f}", "—" if fd is None else f"{fd:.1f}", E(pl["source"])]) val = [[f"{r['name']} (#{r['light']})", r["approach"], r["kind"], r["target_vph"], r["sim_vph"], f"{r['geh']:.2f}"] for r in V] bal = [[b["link"], b["direction"], f"{b['propagated_vph']:.0f}", f"{b['target_vph']:.0f}", f"{b['balance_vph']:+.0f}"] for b in dem["balancing"]] prov = [] for l in cor["lights"]: for d, A in l["approaches"].items(): prov.append([f"#{l['id']} {d}", "volume", f"{A['q_vph']:.0f} veh/h", A["q_source"], E(A["q_evidence"])]) prov.append([f"#{l['id']} {d}", "saturation flow (model)", f"{A['s_vph']:.0f} veh/h", A["s_source"], E(A.get("s_evidence", ""))]) prov.append([f"#{l['id']}", "lost time L", f"{l['timing']['L_s']} s", "measured", E(f"County sheet, {l['timing']['lost_time_basis']}")]) pm = cor["params"] for k in ("p", "g_min_s", "C_min_s", "C_max_s", "x_max"): prov.append(["model", k, pm[k], pm["model_source"], "model defaults from the Nov 10 formulation"]) prov.append(["network", "left-turn bay length", "90 m", "assumed", "typical urban 75–100 m; not measured"]) pipeline = [ ["1", "Parse + verify County data", "County PDFs (timing sheets, turning counts)", "count CSVs, timing JSON; every count checked against the sheet's printed totals"], ["2", "Build corridor dataset", "config, raw + measured data", "corridor.json: every number tagged measured / derived / assumed"], ["3", "Optimizer input", "corridor.json", "optimizer_input.json / .csv for the model"], ["4", "SUMO network", "corridor.json", "4 signals at real spacing, real approach lanes + left bays, posted speeds"], ["5", "SUMO demand", "corridor.json", "entry flows, measured turn shares, mid-block balancing flows"], ["6", "Timing plans", "corridor.json, County timing", "baselines, County current plan, formula optimum"], ["7", "Simulate", "plans", "10 seeded runs per plan: delay, stops, throughput"], ["8", "Validate", "runs vs counts", "GEH per approach"], ["9", "Tables + figures", "everything above", "report tables, figures, this page"], ] css = """ :root{--bg:#fff;--fg:#000;--mut:#444;--rule:#000;--hair:#bbb;--shade:#f3f3f3;color-scheme:light} *{box-sizing:border-box} html{background:var(--bg)} body{margin:0;background:var(--bg);color:var(--fg);font-family:"Times New Roman",Times,"Liberation Serif",serif;font-size:17px;line-height:1.5; padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));padding-block:40px 64px} main{max-width:860px;margin:0 auto} header{text-align:center;border-bottom:2px solid var(--rule);padding-bottom:18px;margin-bottom:22px} h1{font-size:28px;font-weight:700;line-height:1.2;margin:0 0 8px;text-wrap:balance} .meta{color:var(--mut);font-size:15px;margin:2px 0} h2{font-size:20px;margin:34px 0 8px;border-bottom:1px solid var(--rule);padding-bottom:3px} h3{font-size:17px;margin:20px 0 6px;font-style:italic;font-weight:400} p,li{max-width:72ch} ol,ul{padding-left:22px} .abstract{margin:0 auto 10px;max-width:72ch;font-size:16px} .abstract b{font-variant:small-caps;letter-spacing:.04em} .tw{overflow-x:auto;margin:8px 0 4px} table{border-collapse:collapse;width:100%;font-size:14.5px;font-variant-numeric:tabular-nums} thead th{border-top:1.5px solid var(--rule);border-bottom:1px solid var(--rule);text-align:left;padding:5px 7px;font-weight:700;vertical-align:bottom} td{border-bottom:1px solid var(--hair);padding:4px 7px;vertical-align:top} tbody tr:last-child td{border-bottom:1.5px solid var(--rule)} .cap{font-size:14px;color:var(--mut);margin:2px 0 14px} figure{margin:14px 0} figure img,figure svg{display:block;max-width:100%;border:1px solid var(--hair);background:#fff} figcaption{font-size:14px;color:var(--mut);margin-top:4px} .figs{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:14px} .figs>*{min-width:0} code,pre{font-family:"Courier New",Courier,monospace;font-size:13.5px} pre{background:var(--shade);padding:10px 12px;overflow-x:auto;border:1px solid var(--hair)} .status td:nth-child(2){font-weight:700;white-space:nowrap} details{border-top:1px solid var(--hair);margin-top:10px;padding-top:6px} summary{cursor:pointer;font-weight:700} details.explain{border:1px solid var(--rule);border-top:1px solid var(--rule);margin:6px 0 12px;padding:0} details.explain>summary{font-weight:400;font-style:italic;font-size:15px;padding:4px 10px;list-style:none} details.explain>summary::-webkit-details-marker{display:none} details.explain>summary::before{content:"▸ "} details.explain[open]>summary::before{content:"▾ "} details.explain[open]>summary{border-bottom:1px solid var(--hair)} .exp{padding:4px 14px 8px;font-size:16px} .exp p,.exp li{max-width:none} a{color:var(--fg)} footer{margin-top:40px;border-top:1px solid var(--rule);padding-top:8px;font-size:13px;color:var(--mut)} """ status = [ ["Real corridor data: County timing + turning counts for all 4 signals, verified", "Done"], ["SUMO simulation of the corridor, validated against counts", "Done"], ["All timing plans simulated (10 seeds each); results tables + figures", "Done"], ["Study 1 (simulator-in-the-loop vs formula model)", "Done (first full run)"], ["Reproducible code package + README (one command)", "Done (data/simulation part)"], ["Michael + Noah's optimizer (signal_opt.py) plugged in", "Open: stand-in used"], ["Group agreement on the modelling choices in §8", "Open"], ["Written report sections (Data, Setup, Study 1)", "Open"], ["Full report (8–12 pp), Contributions, submission + code to TA", "Open"], ] page = rf""" Big Bend Signal Timing Study

Optimizing Traffic-Signal Timing on Big Bend Boulevard:
Data, Simulation and Validation

CSE 5403 Algorithms for Nonlinear Optimization · Washington University in St. Louis · Fall 2026

Progress report from the data and simulation workstream · {today}

Summary. 4 County signals on Big Bend Blvd · weekday 5–6 PM · real County timing + counts · SUMO simulation validated ({ok}/{len(inter)} GEH < 5) · County plan {cur:.0f} veh-h/h → model plan {fo:.0f} ({100*(1-fo/cur):.0f}% less) → simulator-optimized {sl:.0f} ({100*(1-sl/cur):.0f}% less). Preliminary: optimizer is our stand-in for the group's code.

1. Corridor and scope

4 signals, north → south · main road Big Bend (NB/SB), cross streets (EB/WB) · design hour weekday 5–6 PM · {tot:,.0f} veh/h total approach volume (summed over the 4 intersections).

{F.map_svg(cor)}
Figure 1. Study area, St. Louis County (Clayton / University City): the four signals and the Big Bend corridor (bold).
Schematic of the four signals with PM approach volumes and spacing
Figure 2. Schematic: PM approach volumes (veh/h) and spacing.
{tbl(["link", "length (m)", "speed (m/s)", "travel time τ (s)"], links)}

Table 1. Links between consecutive signals (length from County coordinates; posted speeds from MoDOT 2025).

2. Data

2.1 Sources

{tbl(["source", "what we use", "status"], [ ["St. Louis County timing sheets (4 signals)", "PM pattern 37: cycle, splits, offsets, yellow/all-red, phase sequence", "measured"], ["St. Louis County turning counts (4 signals)", "5–6 PM volumes by approach + L/T/R · Forsyth 2017, FPP 2021, Wydown 2025, Clayton 2026", "measured · verified vs sheet totals"], ["MoDOT 2025", "lanes, speed limits", "measured"], ["County signal inventory", "signal IDs, ownership, coordinates", "measured"], ["OpenStreetMap", "approach lanes at the stop line", "measured"]])}

Every number is tagged measured / derived / assumed (appendix).

2.2 PM peak-hour volumes

{tbl(["intersection", "approach", "veh/h", "L", "T", "R", "lanes", "source"], vol)}

Table 2. Measured approach volumes and turning shares, 5:00–6:00 PM. Lanes are approach lanes at the stop line.

2.3 Current signal timing (County, PM pattern)

{tbl(["intersection", "sheet", "pattern", "cycle (s)", "offset (s)", "phase splits (s)", "Big Bend block", "cross block", "lost time L (s)"], tim)}

Table 3. County timing, weekday PM. Splits include yellow and all-red. Lost time is the total clearance along the phase sequence.

3. Method

3.1 Pipeline

{tbl(["step", "what", "input", "output"], pipeline)}

Table 4. One command (./run_all.sh) reruns all steps. Simulation + Code: live mini-simulation and every program →

3.2 Timing model

Variables: cycle C, Big Bend green gi, offsets · objective: Webster + platoon delay · constraints: 60 ≤ C ≤ 150 s, min greens, x ≤ 0.9 · solver: multistart SLSQP.

3.3 Simulation

{tbl(["setting", "value"], [ ["software", "SUMO 1.28"], ["network", "4 signals at real spacing · real approach lanes · left-turn bays · posted speeds"], ["demand", "measured volumes + turn shares · mid-block balancing flows (Table 5)"], ["signals", "County phase sequence (incl. left arrows), scaled to each plan · right turn on red"], ["run", "15 min warm-up + 60 min measured · 10 seeds per plan"], ["metric", "delay = time lost on corridor links + time waiting to enter (veh-h per hour)"]])} {tbl(["link", "direction", "propagated veh/h", "counted veh/h", "balancing veh/h"], bal)}

Table 5. Mid-block balancing flows: counted volume into a signal minus the volume propagated from the previous signal.

4. Validation

Simulated vs counted volumes, GEH < 5 = pass · interior approaches: {ok}/{len(inter)} pass.

{tbl(["intersection", "approach", "kind", "counted veh/h", "simulated veh/h", "GEH"], val)}

Table 6. Simulated vs counted volumes under the County's current timing (mean of 10 seeds).

5. Results

{tbl(["plan", "cycle (s)", "SUMO delay, veh-h/h (mean ± sd)", "vs County", "stops / veh", "throughput veh/h", "formula delay", "source"], res)}

Table 7. All plans, 10 seeds each. formula-optimum-standin = our stand-in for the group's optimizer.

{F.results_svg(S)}
Figure 3. Simulated corridor delay by plan; County's current timing in black (error bars: one standard deviation over seeds).

6. Study 1: simulator-in-the-loop vs formula model

{tbl(["test", "result"], [ ["Does the formula rank plans like SUMO? ({s1['prediction']['n_plans']} random plans)", "weakly · Spearman ρ = {s1['prediction']['spearman']:.2f}"], ["Formula optimizer", "{fo:.0f} veh-h/h · {s1['formula_optimizer']['seconds']} s"], ["Simulator-in-the-loop (Nelder–Mead, {s1['sumo_loop']['evaluations']} evals)", "{sl:.0f} veh-h/h · ~{s1['sumo_loop']['seconds']//60} min"]])}
{F.prediction_svg(BUILD/"study1/prediction.csv")}
Figure 4. Formula vs simulated delay, 30 random feasible plans.
{F.convergence_svg(BUILD/"study1/optimization.csv")}
Figure 5. Simulator-in-the-loop optimization: best delay found vs evaluations.

7. Interfaces for the optimizer

In: optimizer_input.json (q, s per approach; τ per link; parameters) · Out: plan file:

{{ "name": "...", "C": 124.7,
  "lights": {{ "051": {{"g_main": 37.0, "offset_s": 0.0}},
              "040": {{"g_main": 49.8, "offset_s": 52.7}}, ... }} }}
g_main   = Big Bend green (s); cross-street green = C - L_i - g_main
offset_s = start of the Big Bend block relative to Forest Park Pkwy (s)

8. Modelling choices for the group to confirm

  1. Lost time + capacity computed along the real signal sequence (L ≈ 21–27 s) · needs Michael + Noah's OK · switchable back.
  2. Real signals use left-turn arrows · simulation includes them · revisit "future work".
  3. Simulated network generated from measured geometry (full OpenStreetMap version jammed).
  4. Assumed: 1,800 veh/h/lane · p = 0.8 · 90 m left bays · right turn on red.

9. Status

{tbl(["item", "status"], [[a, b] for a, b in status], "status")}

10. Reproducing the results

cd pipeline
./run_all.sh                                   # data, network, plans, 10-seed runs, validation, tables
.venv/bin/python src/study1.py --n-random 30 --budget 120   # Study 1

Inputs: data/, config/ · outputs: build/ (regenerated) · Simulation + Code: all code, settings and data, plus a zip →

Appendix: where every number comes from {tbl(["where", "input", "value", "source", "evidence"], prov)}
""" vals = dict(cur=cur, fo=fo, sl=sl, ok=ok, n_inter=len(inter), rho=s1["prediction"]["spearman"], pct_fo=100*(1-fo/cur)) heads = {"1": "

1. Corridor and scope

", "2": "

2. Data

", "3": "

3. Method

", "4": "

4. Validation

", "5": "

5. Results

", "6": "

6. Study 1: simulator-in-the-loop vs formula model

", "7": "

7. Interfaces for the optimizer

", "8": "

8. Modelling choices for the group to confirm

", "9": "

9. Status

", "10": "

10. Reproducing the results

"} for k, h in heads.items(): assert h in page, h page = page.replace(h, h + X.block(k, **vals), 1) i = page.index('

'); j = page.index("

", i) + 4 page = page[:j] + '
' + X.block("summary", **vals) + "
" + page[j:] (SITE/"index.html").write_text(page) print("wrote", SITE/"index.html") if __name__ == "__main__": main()