Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proactive Traffic Sims

Source code for the paper "Evaluating the Value of Predictive Information in Partially Observed Networked Systems: A Traffic Control Case Study."

A short-term traffic-speed prediction model (an MLP using time and large-scale event features) drives a Variable Speed Limit (VSL) controller in a microscopic SUMO simulation of an area of Manchester, UK, containing two event venues (the Etihad Stadium and the Co-Op Live arena). Seven control strategies are compared on CO₂ emissions, trip duration, time loss, waiting time, and speed.

Repository structure

model/         Traffic-speed prediction: data loading, feature engineering,
               MLP training, prediction — plus the four bundled trained models
simulations/   SUMO pipeline: per-day setup, demand generation, VSL control
               strategies, arterial-coverage extension, runner, and analysis
  base-sim/    The base SUMO network for the study area
tools/         Shared configuration (config.py)
data-backup/   Minimal InfluxDB backup + restore / export scripts
results/       Raw per-cell result CSVs (125 cells) for inspection
requirements.txt

Requirements

  • Python 3.11+python -m venv venv && source venv/bin/activate && pip install -r requirements.txt
  • SUMO 1.27.0 — with the SUMO_HOME environment variable set and the SUMO tools/ directory on PYTHONPATH (provides sumolib and traci).
  • InfluxDB 2.x — stores the traffic, weather, and event time series used to train the models and generate demand.

Configuration

Copy your credentials into tools/config.py (placeholders are committed; do not commit real values):

INFLUXDB_URL    = "http://localhost:8086"
INFLUXDB_TOKEN  = "YOUR_INFLUXDB_TOKEN"
INFLUXDB_ORG    = "..."
INFLUXDB_BUCKET = "..."
OPENROUTER_KEY  = "YOUR_OPENROUTER_KEY"   # only needed for LLM attendance features

Data (InfluxDB backup)

A minimal dataset is provided in data-backup/influx_backup.lp.gz (gzipped InfluxDB line protocol, ~9 MB) containing exactly what the pipeline needs:

  • vehicle speed for the two Drakewell platforms over the full training window (2021 – 2025) — trains the models and places the virtual sensors;
  • vehicle counts (car_*) over the simulation period (Mar – Oct 2024) — generates the demand;
  • all recorded events at the relevant venues — the event features.

Restore it into a local InfluxDB 2.x instance (requires the influx CLI):

INFLUXDB_TOKEN=your-token ./data-backup/restore_backup.sh

This creates the traffic_prediction_project org and the traffic_prediction_bucket bucket (if missing) and writes the data. To regenerate the backup from a fully populated InfluxDB, run python data-backup/export_backup.py.

How to run

Each script below is run once. Every one loops internally over all 25 simulation days (and the runner additionally over the five SUMO seeds), so you do not run them per day or per seed. The day and seed lists are constants at the top of each file.

Run the simulations/ scripts from the simulations/ directory, with the repo root on PYTHONPATH (so tools and model import):

cd simulations
export PYTHONPATH=..

0. Set up the per-day directories — copies the base network, config, and sensor placement into simulation-days/{day}/ for all 25 days:

python setup_days.py

1. Train the prediction models (optional — the four trained models are already bundled under model/). One MLP per sensor and direction:

python ../model/batch_training.py

2. Generate per-day speed predictions for all 25 days × 4 sensors (uses the bundled models, so this works without step 1):

python ../model/predict.py

3. Generate the demand — one fixed demand per day. The demand uses randomTrips' default seed (42) and is shared across the five SUMO seeds. Two scripts cover the two day groups:

python generate_demand.py          # 9 event days
python generate_demand_16days.py   # 16 general days

4. Run the simulations — all seven strategies, for every day and SUMO seed (43–47), in a single invocation (25 days × 5 seeds = 125 cells):

python run_simu_sumo1.27.py

Inspect a single run in the SUMO GUI:

./run_gui.sh 2024-09-18 43 predictive_round5

Results

Each simulation run writes its raw results directly — no extra step is needed to obtain them. For every (day, seed) cell the runner produces:

File Contents
aggregated_metrics.csv one row per strategy with all headline metrics (CO2_per_VKT_g_per_km, avg_duration, avg_timeLoss, avg_waitingTime, avg_speed, total_CO2_g, total_VKT_km, vehicle_count, …)
simulation_metrics.csv the 30-minute network time series (CO₂ and VKT rates)
vsl_edge_map.csv the road-fragment → sensor mapping used in that run

The raw per-cell aggregated_metrics.csv for all 125 cells (25 days × 5 seeds) are bundled under results/{day}/seed_{seed}/, so the outcomes can be inspected without re-running the 875 simulations. To print a per-strategy summary by day type (event / general):

python simulations/analyze.py

This reports the mean of each metric across days and seeds, with the percentage change against the baseline. (The paper's finer four-cell stratification — weekday vs non-workday, with peak / event-centric time windows — is computed on top of these same raw cells.)

Control strategies

baseline, lower_limit, reactive_rule, predictive, predictive_round2, predictive_round5, predictive_30.

Notes

Some runner scripts contain absolute paths and HPC (SLURM) settings specific to the development environment; adjust these to your own setup.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages