Skip to content

AI-powered highway traffic shockwave detection and prediction system using MT-STNet deep learning model with real-time monitoring and intelligent decision support

License

Notifications You must be signed in to change notification settings

timwei0801/Highway_trafficwave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

170 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Highway Traffic Shockwave System

Highway Intelligent Traffic Shockwave Warning System

AI Decision System for Future Traffic Prediction โ€” Based on Deep Learning Fusion with Physics and Shockwave Theory

Live Demo License: MIT Python FastAPI Next.js TypeScript TensorFlow DOI Award Conference

English | ไธญๆ–‡


Demo

System Demo

Real-time demonstration of the traffic shockwave warning system in action


Overview

Taiwan's highways handle over 3 million vehicle trips daily. Traditional passive traffic management struggles with sudden congestion events.

This research discovers that traffic congestion propagation shares striking similarities with seismic wave propagation, leading to an innovative hybrid prediction system that combines:

  • Physics-Based Detection: Rankine-Hugoniot kinematic wave theory
  • Deep Learning Prediction: MT-SWNet with graph neural networks
  • RAG-Enhanced AI: Intelligent decision support system
System Overview

๐Ÿ† Awards & Recognition

Achievement Event Date
๐Ÿฅˆ 2nd Place (1st Place Vacant) National Expressway Intelligent Traffic Competition Oct 2024
๐ŸŽค Invited Speaker 2025 Chinese Institute of Transportation Annual Conference Dec 2025

This project was presented at the 2025 Annual Meeting of the Chinese Institute of Transportation, sharing our innovative approach of combining deep learning with physics-based shockwave theory for highway traffic prediction.

Competition Showcase

Competition Poster

Official Competition Poster

Conference Banner

2025 CIT Annual Conference

Presentation

Conference Presentation


Key Features

Real-Time Monitoring Shockwave Detection AI Prediction Smart Routing
62 ETC stations across Taiwan Sub-5 second alert latency 10-60 min advance forecast Dynamic route optimization

Shockwave Severity Levels

Level Speed Drop Visual Action
๐ŸŸข Mild 10-20 km/h Green Minor delays expected
๐ŸŸก Moderate 20-30 km/h Yellow Consider alternative routes
๐Ÿ”ด Severe 30+ km/h Red Route change recommended

System Screenshots

Driver Interface

Driver Dashboard

Features Highlight
  • Interactive traffic map with real-time congestion status
  • Shockwave radar visualization with propagation animation
  • AI-powered route suggestions
  • Personalized departure time recommendations

Admin Control Center

Admin Dashboard

Features Highlight
  • Network-wide traffic monitoring
  • MT-SWNet prediction visualization (90% confidence)
  • AI decision support recommendations
  • Historical trend analysis

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        Frontend Layer                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚   Driver    โ”‚  โ”‚    Admin    โ”‚  โ”‚     Real-time Map       โ”‚ โ”‚
โ”‚  โ”‚  Dashboard  โ”‚  โ”‚   Control   โ”‚  โ”‚   (React + Leaflet)     โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚ WebSocket / REST API
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Backend Layer                              โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚              FastAPI Server (Port 8000)                  โ”‚  โ”‚
โ”‚  โ”‚  โ€ข /api/traffic    โ€ข /api/shockwave   โ€ข /api/prediction  โ”‚  โ”‚
โ”‚  โ”‚  โ€ข /api/location   โ€ข /api/rag         โ€ข /api/admin       โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚   MT-SWNet     โ”‚  โ”‚   Shockwave    โ”‚  โ”‚   RAG AI       โ”‚   โ”‚
โ”‚  โ”‚   Predictor    โ”‚  โ”‚   Detector     โ”‚  โ”‚   Assistant    โ”‚   โ”‚
โ”‚  โ”‚  (TensorFlow)  โ”‚  โ”‚ (LWR Physics)  โ”‚  โ”‚   (Ollama)     โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Data Layer                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚  TDX API   โ”‚  โ”‚  TISC API  โ”‚  โ”‚   SQLite + Graph Data  โ”‚   โ”‚
โ”‚  โ”‚ (Real-time)โ”‚  โ”‚ (Real-time)โ”‚  โ”‚    (62ร—62 Adjacency)   โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

MT-SWNet Model

Model Architecture

The Multi-Task ShockWave Network features:

  • Encoder: Dual ST-Physical Blocks with spatial attention, temporal attention, and multi-head GCN
  • Decoder: Masked ST-Physical Block with generative inference
  • Multi-task Output: Simultaneous flow, speed, and density prediction

Key Innovation: Graph structure embedding with degree, edge, and distance matrices for capturing road network topology.

MT-SWNet Architecture

Performance Comparison

Model MAE (veh/5min) RMSE MAPE (%) Rยฒ
MT-SWNet 12.3 18.7 8.5 0.912
Graph-WaveNet 13.2 19.8 8.9 0.903
AGCRN 13.8 21.2 9.3 0.895
DCRNN 14.5 22.1 9.8 0.887
LSTM 18.9 28.7 13.5 0.798
ARIMA 21.3 32.1 15.7 0.721

Shockwave Detection Theory

LWR Traffic Flow Model

Based on the Lighthill-Whitham-Richards continuity equation:

$$\frac{\partial \rho}{\partial t} + \frac{\partial (\rho u)}{\partial x} = 0$$

Where:

  • ฯ = traffic density
  • u = vehicle speed

Rankine-Hugoniot Condition

Shockwave propagation speed:

$$s = \frac{f(\rho_R) - f(\rho_L)}{\rho_R - \rho_L}$$

Shockwave Theory Shockwave Propagation

Data Sources & Processing

Data Sources

Data Sources

Historical Data from TISC (Taiwan Highway Traffic Database):

  • eTag paired path dynamic information
  • Median travel time by vehicle type (M04A)
  • Median travel speed by vehicle type (M05A)
  • Trip counts by vehicle type (M08A)

Real-time Data from TDX Platform:

  • ETC gantry paired section traffic
  • VD vehicle detector real-time data
  • CMS variable message sign information

Data Quality Control

Data Quality Control

Vehicle PCU Standardization

PCU Formula

Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18.0+
  • TDX API credentials (Apply here)
  • Google Maps API key (Get here)

Installation

# Clone repository
git clone https://github.com/timwei0801/Highway_trafficwave.git
cd Highway_trafficwave

# Backend setup
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

# Frontend setup
cd frontend && npm install && cd ..

# Configure environment
cp .env.example .env
# Edit .env with your API credentials

Run

# Option 1: One-command deployment
./deploy.sh

# Option 2: Manual startup
# Terminal 1 - Backend
cd api && python main.py

# Terminal 2 - Frontend
cd frontend && npm run dev

Access Points

Interface URL Description
๐Ÿš— Driver Dashboard http://localhost:3000/driver Navigation & alerts
๐ŸŽ›๏ธ Admin Control http://localhost:3000/admin System management
๐Ÿ“š API Docs http://localhost:8000/docs Swagger UI

API Examples

Get Active Shockwaves
import requests

response = requests.get('http://localhost:8000/api/shockwave/active')
shockwaves = response.json()

for sw in shockwaves['active_shockwaves']:
    print(f"Severity: {sw['severity']}, Speed Drop: {sw['speed_drop']} km/h")
Traffic Prediction
payload = {
    "station_ids": ["01F0340N", "01F0360N"],
    "prediction_steps": 12  # 60 minutes
}

response = requests.post('http://localhost:8000/api/prediction/traffic', json=payload)
predictions = response.json()
AI Assistant Query
payload = {
    "query": "Best time to travel from Taipei to Hsinchu?",
    "context": {"origin": "Taipei", "destination": "Hsinchu"}
}

response = requests.post('http://localhost:8000/api/rag/chat', json=payload)
print(response.json()['response'])

Performance

87%

Shockwave Detection Accuracy

<5s

Detection Latency

90%

Prediction Confidence

Citation

@article{zou2024mtstnet,
  title={MT-STNet: A Novel Multi Task Spatiotemporal Network for Highway Traffic Flow Prediction},
  author={Zou, Guojian and others},
  journal={IEEE Transactions on Intelligent Transportation Systems},
  year={2024},
  doi={10.1109/TITS.2024.3411638}
}

@software{highway_shockwave_system,
  title={Highway Intelligent Traffic Shockwave Warning System},
  author={Wei, Tim},
  year={2024},
  url={https://github.com/timwei0801/Highway_trafficwave}
}

Note: MT-SWNet is our team's enhanced version based on the original MT-STNet architecture.


License

This project is licensed under the MIT License - see LICENSE for details.


Acknowledgments

  • MT-STNet Research Team - Original deep learning model architecture
  • Taiwan Ministry of Transportation - TDX Open Data Platform
  • TensorFlow, FastAPI, Next.js - Open source frameworks

GitHub Stars GitHub Forks

AI-Powered Traffic Safety Based on Cutting-Edge Scientific Research

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •