Skip to content

AyselRahimli/Navetra-TeknofestBronzeMedal

Repository files navigation

🚦 Navetra — Future-Aware Traffic Prediction & Routing

Navetra predicts near-future traffic speeds on large urban road networks and uses those predictions directly for routing decisions.

Unlike classical navigation systems that react only to current conditions, Navetra explicitly models how traffic evolves over time and computes routes based on expected future states.


What Navetra Does

Navetra operates on a city-scale road graph and provides:

  • Segment-level traffic speed forecasts
  • Time-dependent routing using predicted travel times
  • Route optimization over future departure windows
  • A unified API that works with or without trained ML models

Routing decisions are driven directly by predicted speeds rather than post-hoc heuristics.


Core Modeling Approach

Navetra combines spatial and temporal learning in a modular pipeline.

Spatial Modeling — DSTCGCN

A graph neural network operating on an edge-as-node road graph captures how congestion propagates across connected road segments.

Temporal Modeling — PatchTST

A patch-based temporal transformer models longer-range temporal patterns such as:

  • Rush hour dynamics
  • Weekday vs weekend behavior
  • Night-time traffic recovery

Together, this hybrid architecture enables accurate forecasting of future traffic conditions across the network.

An STGAFormer-based model is included as an experimental baseline for comparison.


Results (Istanbul Road Network)

Evaluated on a large Istanbul road graph using future speed prediction and end-to-end routing metrics:

Metric Result
Speed MAE ~2–3 km/h
ETA RMSE ~5 minutes
Hit@±5 min ~89%

ETA errors are measured along full predicted routes rather than individual segments.


Visual Examples

City-Scale Traffic Prediction

image

Segment-Level Speed Forecasts

image

All visualizations are generated directly from model outputs and routing results.


System Overview

Navetra follows a production-oriented pipeline:

  1. Road network extraction from OSM or shapefiles
  2. Graph construction (segments + directed adjacency)
  3. Spatio-temporal data generation
  4. GNN + temporal model training
  5. Prediction and routing served via a Flask API
  6. Web or mobile clients consume future-aware routes

The same API operates in both ML-driven and simulation-driven modes.


Running the API

python traffic_prediction_api.py ^
  --model_path path\to\model.pth ^
  --model_type dstcgcn_patchtst ^
  --data_dir complete_training_data ^
  --port 5000

Health Check

GET http://localhost:5000/health

Returns model status, loaded datasets, and graph size.


API Endpoints (Overview)

  • GET /health
    Returns system status and active prediction mode.

  • GET /traffic/current
    Returns predicted segment speeds within a viewport.

  • GET /predict/all
    Lightweight speed predictions (optionally bounded).

  • POST /route/optimize
    Finds the best departure time within a future window.

  • POST /routes/forecast
    Returns multiple future routes for different departure times.


Routing Internals

  • Directed graph with time-dependent edge weights
  • Edge weight equals predicted travel time
  • Future departure times interpolate predicted speeds
  • Routing uses sparse Dijkstra for scalability

Routing decisions are fully driven by predicted traffic evolution.


ML and Simulation Modes

Navetra explicitly distinguishes between operating modes:

  • ML Mode
    Uses trained GNN + PatchTST models when artifacts are available.

  • Simulation Mode
    Falls back to a time-aware, road-type-aware traffic simulation when models or features are missing.

Both modes expose identical API endpoints.


Intended Use

Navetra is suitable for:

  • Spatio-temporal traffic modeling research
  • Urban mobility experiments
  • Smart city simulations
  • Mobile or web-based routing applications

The system prioritizes clarity, correctness, and extensibility.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors