TransitAI Core

Digital twin · use case · online

Anomaly detection.

Disruptions, special events and failed sensors, spotted within five minutes on every party's public feed and on the loads agencies share. The alert goes to the agency, the region, and the neighbours whose connections it breaks. Told as one story in seven chapters: an agency joins, an incident is caught, an agency leaves.

Start the storyThe decisions behind it

Chapter 1

An agency joins.

Brampton Transit joins a region that already watches TTC and MiWay. Five steps, from a signature to the first loads. Names are an illustration: no agency has agreed to anything.

The region reads only the feeds of parties in its registry, public or not. The adapter runs in the agency's account and costs it about two dollars a month. Buildings from the MIT-licensed Age of AI project; see the credits.
This contract
live loads v1: boardings, alightings, visits and the mean load on board by route, direction, stop and 5-minute window; sent every 5 minutes, within 2; counts of people only; read by the detector; kept 24 hours on the live lane
What comes back
Alerts on your own feed and vehicles, and neighbours' delays that break your connections
Join without loads
A feed-only party is watched and alerted too; it just gets no crowding alerts

Chapter 2

How it works: feeds in, alerts out.

Press Play, or tap a step below the picture. Highlighted arrows cross an account border: feeds and loads coming in, alerts going out. Each step names the general part and the recommended AWS service beside it.

Nothing is trained on our data. Rules catch dead feeds; a ready-made detector catches unusual delays and crowds.

Two ways to find one

Rules

  • Feed gap: nothing from a feed or a vehicle.
  • Frozen: a vehicle in service that does not move.
  • Jump: a position too far from the last one.
  • Dead counter: a stop whose counts read nobody while buses pass; the vehicle check runs at home.

Expected against seen

  • Each vehicle matched to its timetable: how late.
  • One value per route and direction every 5 minutes.
  • A band per series: what is usual at this hour.
  • Two windows outside it: an alert.

Who is affected

  • Shared stops on the late route, from the registry.
  • Last night's transfer totals: who changes there, when.
  • Names the neighbour, not the rider.
  • No transfer totals, no neighbour named.

What an alert says

FieldExampleNote
kindfeed_gap · frozen_vehicle · position_jump · dead_counter · delay_anomaly · load_anomalyrules the first four; the detector the last two
partyTTCwhose feed or vehicle
whereroute, direction; vehicle or stop for a ruleas the party's own feed names them
since17:05the first window outside
expected / seen2 to 6 min late / 19 min latethe band and the value, for the detector's alerts
affectsMiWay, at the stops the routes sharefrom shared stops and transfer totals; empty when unknown
labelsnow · event nearbyplanned: weather and events are not sourced yet

On the real month

Sample anomaly replay.

The same rules and a simple band, replayed over MiWay's September 2024: about 48 delay alerts a weekday across 63 routes, a dial that trades alerts for patience, and one evening when route 18 ran 26 minutes late for nearly three hours.

Open the sample replay

Chapter 3

An incident, town by town.

The region as a small world. One evening a TTC route runs late and MiWay riders are about to miss their connection. Follow it from the feeds to the red flags. Press ? for the legend, ⛶ for full screen.

A bird is a public feed; a sealed cart is 5-minute loads; a rider with a red flag is an alert. The incident is an illustration, not a real event.

Chapter 4

The architecture: what runs where.

Every part, with AWS's own icons, accounts as boxes. Blue arrows are the only crossings. The shared parts are drawn because every use case is costed with them.

Anomaly detection architecture: TTC's public feeds polled and its 5-minute loads pushed into the region's live lane; rules and an expected-band detector; an alert built, the affected neighbour looked up, and delivered to TTC's and MiWay's control rooms and the region's views; shared parts, a heartbeat and a leaving job beside.
Services are recommendations, not settled. Open the image for full size.

Reading it, left to right

  1. Two things come in. Public feeds, which the region fetches itself every 10 seconds. And 5-minute loads, which the agency's adapter sends: counts of people, nothing about a rider.
  2. One live lane. Both land on one ordered stream, kept 24 hours under the region's key, and are archived as a TIDES table for replays.
  3. Two readers. The rules look at each vehicle against its own last state. The second reader matches each vehicle to its timetable and writes how late and how full each route is, every 5 minutes.
  4. A band per series. A built-in detector learns what is usual for each route at each hour. Nothing is trained by us; a pre-trained model is the costed upgrade.
  5. The alert is built once. Kind, party, where, since, expected and seen, and who is affected: neighbours that share a stop with the late route and exchange riders there.
  6. Three hear. The agency it happened at, the neighbours named, and the region's own map. Each agency receives alerts in its own account and routes them as it likes.
  7. When we fail, we say so. A heartbeat tells a dead feed from a dead poller. An alert nobody took is held and retried. Both page the region's on-call, never a control room.
  8. Planned, dashed. Weather and event calendars would label an alert (snow, a game). They are not sourced and not costed.

Every service, every connection

Interactive detailed architecture.

The same picture in full: thirty-nine components with their roles, the Chronos upgrade drawn dashed, every connection labelled with what flows on it, the failure paths and the leaving job drawn. Hover a component and only its links stay lit.

Open the interactive architectureStill picture

When something fails

What failsWhat happensWho is told
A party's feed goes silentThe feed-gap rule fires; delay alerts for that party stop and show as unknown, never as normalthat party; neighbours see unknown
The region's poller stopsThe heartbeat alarm fires within a minute; no feed-gap alerts are sent, since the feeds are finethe region's on-call
Loads arrive late or in the wrong shapeA rule fires; crowding alerts pause for that party; delay alerts carry onthe sending agency
A receiver does not take an alertRetried for an hour, then held 14 days and replayable; the live feed still shows itthe region's on-call
A new party, or a new routeRules work from the first minute; a band needs two weeks of history before it may alarmnobody; the series is marked learning

Chapter 5

Who owns what.

DataLivesKeyWho may readOn leaving
Passenger counter recordsagency accountagencythe agency onlyuntouched
Public feeds, archivedregion accountregionthe party itself; anyone under a contractthat party's part deleted, old snapshots expired
5-minute loadsthe live lane, 24 hoursregion, on arrivalthe detector onlygone within 24 hours
Delay and load per routeregion account, as metricsregionthe detector; the region's viewsalarms and bands deleted at once; values age out in 63 days
Last state per vehicleregion accountregionthe rules onlydeleted
Alertsthe region's log, 13 months; a copy with each receiverregion; each receiver's ownthe party it concerns, the region, neighbours named on itcopies already sent stay with receivers
Who-is-affected lookupregion accountbuilt from transfer totals under each agency's keythe alert builder onlyrevoke the key: gone at the next nightly rebuild
No card, no rider
Nothing in this use case reads a fare card. Loads are counts from door sensors. The only fare-derived input is last night's transfer totals, already small-cell protected at home.
The trade-off we accepted
Loads rest under the region's key, not the agency's, because they live 24 hours and name nobody. The price: CloudWatch keeps metric values until they age out and offers no delete, so "at once" is true of alarms, state and archive, not of the last 63 days of route averages.
Decisions
3, 29 to 32, 41 to 43, 51 to 54

Chapter 6

What it costs: cloud only.

This use case on its own, on the seven-party scenario, at AWS list prices, with the shared parts included in full. Every box in the detailed picture has a line in the model; the planned weather input does not.

Whole region, per year
$9.3k low · $17.4k typical · $29.4k high
Within 1 minute instead
$18.5k a year, typical: about $1.1k more
With Chronos
$19.8k a year, typical: one always-on model endpoint
What drives it
The per-series price of metrics and anomaly alarms (1,680 series), then the live lane and its poller
One full agency
$29 a year for the adapter; a feed-only party pays nothing
Against the earlier figure
$17.3k in the first model; $103 a year more here for the second reader, timetables, lookup, alert log, retry queue, heartbeat, a key and the leaving job
Source
explorations/anomaly-cost/model.py, on top of explorations/dt-cost/model.py

Trade-offs

ChoiceChosenInstead ofWhy
Alert speedWithin 5 minutesWithin 1 minuteAt 1 minute only 61% of route-windows in the sample hold three stop visits to take a median over, against 96% at 5; the cloud saving is small, the false alarms are not
How long a miss must lastTwo windowsOneIn the sample one window gives about four times the alerts of two
DetectorCloudWatch's built-in anomaly detectionA pre-trained model (Chronos) on SageMakerNo model to run; inference only, as the instructors asked; Chronos costed as the upgrade
InputsPublic feeds plus shared loadsPublic feeds onlyLoads show special events and dead counters; a party sharing none still gets the rest
Whose feeds are readRegistered parties onlyEvery public feed in the regionPublic is not the same as agreed; leaving must be able to mean not watched
Who hearsAgency, region and affected neighboursThe agency onlyA delay on TTC breaks MiWay connections; that is the federated value
Where loads restThe region's key, 24 hoursThe agency's key, like transfer totalsCounts that name nobody and expire in a day do not need a revocable key

Chapter 7

An agency leaves.

The mirror of joining. Brampton switches its adapter off; the region stops reading its feeds and deletes what it can at once. What cannot be deleted at once is said plainly.

Neighbours see "unknown" for a party that left, like any party not sharing.

Decided

  • Decisions 24, 29 to 35, 38 to 40, 51 to 53: see the decisions page
  • Drawn around 5-minute alerts; 1 minute stays priced

Open

  • Decision 54, proposed: registered parties only, loads under the region's key, the failure paths, two windows before an alert
  • Whether a leaver's alerts are purged from the region's log before 13 months
  • Weather and event data, named by the instructor, not yet sourced
  • Private networking and threat detection are not drawn

Caveats

  • Positions are estimated from the sample's blocks, not measured pings
  • Series counts assume 70 routes per agency; TTC alone has more
  • CloudWatch's detector is per series and knows nothing about the network
  • A stale timetable makes every delay wrong; the check for it is not drawn
  • Nothing deployed; costs are a design estimate, not a quote

↑ ↓ to move · ↵ to open · esc to close