AI-powered railway traffic control using graph-based scheduling and reinforcement learning. Fewer delays. Less manual work. More trains on time.
Core capabilities
The rail network is modelled as a weighted graph. Dijkstra's algorithm finds the globally optimal path for every train in O(E log V) time.
A Python RL agent is penalized for every minute of delay. Over thousands of simulation steps it learns to preempt congestion before it forms.
Scheduling decisions are executed without human intervention. The system handles rerouting, priority queuing, and conflict resolution autonomously.
When a segment is blocked or congested, the system recalculates an alternate optimal path within milliseconds — no dispatcher required.
Live network topology, train positions, delay heatmaps, and RL reward curves — all visualized in a real-time React frontend.
Designed for networks with hundreds of simultaneous trains. Automated logic removes the human bottleneck that caps throughput in dense corridors.
How it works
Dijkstra handles the geography. RL handles the uncertainty. Together they cover what neither could alone.
Stations are vertices. Track segments are weighted edges. Edge weight encodes distance, speed limit, and current congestion level.
Graph theoryFor every train departure, Dijkstra finds the globally shortest path from origin to destination in O(E log V). This becomes the base schedule.
Dijkstra's algorithmA Python RL agent observes the state space (train positions, segment loads, delay accumulations) and learns a policy that minimizes total delay reward.
Reinforcement learningWhen the RL policy predicts a delay penalty exceeding the threshold, it triggers a re-run of Dijkstra with updated edge weights — rerouting before the congestion forms.
Dynamic reroutingEvery dispatch, reroute, and penalty event is streamed to the frontend in real time. Operators see the network, not a spreadsheet.
React + WebSocketTechnology stack
Core routing engine. Models the rail network as a weighted directed graph. Guarantees shortest-path solution in every scheduling cycle.
Python · heapq · networkxPython RL agent trained in simulation. Reward function penalizes delay accumulation; policy learns to reroute proactively in congested conditions.
Python · OpenAI Gym · stable-baselines3Real-time dashboard displaying live train positions, delay heatmaps, optimal path overlays, and RL reward curves over time.
React · WebSocket · RechartsSimulation results
All metrics measured against a baseline scheduler with no graph optimisation and no RL, running identical traffic loads in simulation.
Graph-based Dijkstra scheduling cuts the time between a train's departure trigger and its confirmed route assignment by nearly half.
RL penalty-based training taught the agent to anticipate high-load segments and preemptively reroute, keeping trains on schedule.
Automated dispatch and real-time rerouting removed the need for a human dispatcher on the majority of scheduling decisions.
Under the hood
Open source
Explore the full simulation, training logs, and React dashboard on GitHub.