{"id":51130758,"url":"https://github.com/anders94/traffic-coordination","last_synced_at":"2026-06-25T12:01:26.324Z","repository":{"id":366069271,"uuid":"1274957532","full_name":"anders94/traffic-coordination","owner":"anders94","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-20T04:50:40.000Z","size":444,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-20T06:22:36.639Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anders94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-20T04:41:59.000Z","updated_at":"2026-06-20T04:50:43.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/anders94/traffic-coordination","commit_stats":null,"previous_names":["anders94/traffic-coordination"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/anders94/traffic-coordination","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anders94%2Ftraffic-coordination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anders94%2Ftraffic-coordination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anders94%2Ftraffic-coordination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anders94%2Ftraffic-coordination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anders94","download_url":"https://codeload.github.com/anders94/traffic-coordination/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anders94%2Ftraffic-coordination/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34773843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-25T12:01:25.539Z","updated_at":"2026-06-25T12:01:26.302Z","avatar_url":"https://github.com/anders94.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Adaptive, Camera-Augmented Traffic Signal Control\n\nMake signalized intersections more efficient purely by **re-timing the lights** — using\nexisting sensors plus added cameras, with controllers that **learn from the reward**\nrather than being hand-tuned. This repo is a staged R\u0026D exploration of *what\nactually moves the needle* on signal timing, built on a small, transparent, self-contained\ntraffic simulator. It is a research journal in code, not a product.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"img/phase-1.gif\" alt=\"Phase 1: learned single-intersection control\" width=\"420\"\u003e\n  \u003cbr\u003e\n  \u003cem\u003ePhase 1 — the learned controller holding the highway green and clearing the side\n  street just in time (delay cost ticking up top).\u003c/em\u003e\n\u003c/p\u003e\n\n\u003e **Framing.** Camera/AI adaptive control already ships commercially (NoTraffic,\n\u003e InSync, Surtrac), and realistic gains from re-timing are bounded (~10% on poorly-tuned,\n\u003e under-saturated corridors; ~0 or negative under saturation). The value here is not\n\u003e novelty — it is measuring, with adversarial rigor, which levers matter and which\n\u003e don't. **The full findings log is [`docs/JOURNAL.md`](docs/JOURNAL.md).**\n\n## Status\n\n| Phase | Question | Status |\n|---|---|---|\n| 1 — Single intersection | Can a learner beat conventional timing on one light? | ✅ done |\n| 2 — Corridor \u0026 coordination | Does coordinating offsets produce a green wave? | ✅ done |\n| 3 — Perception | What does a camera add over a loop detector? | ✅ done |\n| 4 — Interoperability \u0026 safety | What makes a learning controller deployable? | ✅ done |\n| 5 — Pilot | Shadow-mode on a live intersection | ⬜ planned |\n\n## Headline findings (the through-line)\n\n- **Being demand-responsive is the dominant single-intersection win** (~55% lower delay\n  than a fixed split); beating a good adaptive baseline after that is hard.\n- **\"Minimize total delay\" needs a worst-case-wait cap**, or it starves the side street.\n  A *learnable* objective can honor delay + fairness at once; a fixed optimal rule can't.\n- **Coordination (offsets) is the big corridor lever** — a green wave roughly halves\n  arterial stops and delay — and good **split tuning** dissolves the two-way tradeoff.\n- **Adaptivity ≠ coordination.** A hand-combined coordinated-actuated controller, *and* a\n  multi-agent RL controller, both failed to beat a well-tuned coordinated fixed plan —\n  reproducing the real-world result that simulation-strong RL hasn't beaten SCATS/SCOOT.\n- **Camera look-ahead is mostly a control-*policy* win, not a sight-distance win.** The\n  value of seeing farther saturates at ~one clearance-distance (~100 m) for reactive\n  control; long range pays off only for planning/coordination and for jobs loops can't do\n  (turning counts, emergency preemption, pedestrians, anomalies).\n- **A two-layer safety architecture makes \"let it learn\" deployable**: the policy can only\n  *request* timing within an envelope it cannot violate, and an independent conflict\n  monitor trips to flash-red on any unsafe display. The real barriers are institutional\n  (standards/procurement/liability), not algorithmic.\n\n## What's here\n\n| Path | Purpose |\n|---|---|\n| `sim/intersection.py` | Single-intersection microsim: per-approach speeds, accel/decel + start-up, per-vehicle delay |\n| `sim/corridor.py` | Multi-intersection arterial corridor (two-way through traffic + cross streets) |\n| `sim/signal.py` | The **proactive safety envelope** — min/max green, yellow + all-red clearance |\n| `safety/conflict_monitor.py` | The **independent conflict monitor** (software MMU): trips to flash-red on unsafe displays |\n| `envs/` | Gymnasium env (single light) + multi-agent corridor env, with camera-horizon look-ahead |\n| `controllers/` | Baselines (`fixed_time`, `actuated`, `max_pressure`), `dqn` learner, `anticipatory`, and corridor controllers (coordinated / max-pressure / coordinated-adaptive / learned) |\n| `scenarios/` | `divided_highway_side_street`, `arterial_corridor`, `arterial_corridor_varying` |\n| `experiments/` | Eval + training + the per-phase studies (see below) |\n| `viz/render.py` | Render a rollout to a looping GIF |\n| `docs/JOURNAL.md` | The running research journal (findings F1–F17) |\n\n## Quick start\n\n```bash\npython -m venv .venv \u0026\u0026 source .venv/bin/activate\npip install -e .                 # baselines + evals (no torch needed)\npip install -e '.[learn,viz]'    # add DQN training + GIF rendering\n```\n\n### Phase 1 — single intersection\n```bash\npython -m experiments.eval --scenario divided_highway_side_street --seeds 8\npython -m experiments.train --episodes 250 --out runs/dqn.pt   # learn the policy\npython -m experiments.eval --dqn runs/dqn.pt --seeds 8          # include it\npython -m viz.render --controller dqn --dqn runs/dqn.pt --out runs/sim.gif\n```\n\n### Phase 2 — corridor \u0026 coordination\n```bash\npython -m experiments.corridor_eval --seeds 5                   # green wave vs lock-step vs adaptive\npython -m experiments.corridor_eval --green-cross 8 --seeds 5   # split-tuned coordinated plan\npython -m experiments.corridor_train --scenario arterial_corridor_varying \\\n    --episodes 150 --horizon 3600 --out runs/corridor_dqn.pt    # learned multi-agent\npython -m experiments.corridor_eval --learned runs/corridor_dqn.pt --green-cross 8 --seeds 5\n```\n\n### Phase 3 — perception (what a camera adds)\n```bash\npython -m experiments.perception_eval --seeds 5        # sight horizon × traffic, one light\npython -m experiments.corridor_perception --seeds 5    # sight horizon on the corridor\n```\n\n### Phase 4 — safety\n```bash\npython -m experiments.safety_demo    # envelope + conflict monitor vs adversarial/faulty controllers\n```\n\n## The objective (single intersection)\n\nReward per step is `-(total delay this step) - beta * (fairness excess this step)`.\nMinimising the return minimises aggregate vehicle-delay (Webster's classic objective,\n== \"sum of every car's wasted time\") while a per-approach **max-wait cap** prevents the\nside street from being starved — the documented failure mode of every adaptive system\nstudied. A run that breaches the cap is a fairness failure regardless of its delay number.\n\n## Not a product\n\nThis is R\u0026D. There is no field hardware, no real perception pipeline (the camera is\nmodeled as ground-truth look-ahead), and the corridor sim is trustworthy only in the\nunder-saturated regime (it does not model gridlock spillback). External validation (e.g.\nSUMO) and a shadow-mode pilot are the natural next steps. See the journal for caveats.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanders94%2Ftraffic-coordination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanders94%2Ftraffic-coordination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanders94%2Ftraffic-coordination/lists"}