Calibrate SUMO traffic simulations against real-world congestion data
Reason this release was yanked:
This version was a part of the early development stage of demandify.
Project description
Welcome to demandify!
[!CAUTION] BETA VERSION: This project is currently in early beta (0.0.1). Expect frequent breaking changes and instability. Use at your own risk.
Turn real-world traffic data into accurate SUMO simulations.
Have you ever wanted to create a realistic traffic simulation but got stuck figuring out where the cars should go? demandify solves that.
It's simple: Pick a spot on the map and demandify will:
- Fetch real-time congestion data from TomTom 🗺️
- Build a clean SUMO network 🛣️
- Use the Genetic Algorithm to figure out the demand pattern to match that traffic 🧬
The result? A ready-to-run SUMO scenario that allows you to test your urban routing policies, even for your CAVs! (wink wink).
Features
- 🌍 Real-world calibration: Uses TomTom Traffic Flow API for live congestion data
- 🎯 Seeded & reproducible: Same seed = identical results for same congestion and bbox
- 🚗 Car-only SUMO networks: Automatic OSM → SUMO conversion with car filtering
- 🧬 Genetic algorithm: Optimizes demand to match observed speeds
- 💾 Smart caching: Content-addressed caching for fast re-runs
- 📊 Beautiful reports: HTML reports with visualizations and statistics
- 🖥️ Clean web UI: Leaflet map, real-time progress stepper, log console
Quickstart
1. Install demandify
# Clone the repository
git clone <repository-url>
cd demandify
# Install in development mode
pip install -e .
2. Install SUMO 🚦
demandify requires SUMO (Simulation of Urban MObility) to power its simulations.
👉 Download SUMO from the official website
Once installed, verify it's working:
demandify doctor
3. Get a TomTom API Key
- Sign up at https://developer.tomtom.com/
- Create a new app and copy the API key
- The free tier includes 2,500 requests/day
4. Run demandify
demandify
This starts the web server at http://127.0.0.1:8000
5. Calibrate a scenario
- Draw a bounding box on the map
- Configure parameters (defaults work well):
- Time window: 15 or 30 minutes
- Seed: any integer for reproducibility
- GA population/generations: controls quality vs speed
- Paste your API key (one-time, stored locally)
- Click "Start Calibration"
- Watch the progress through 8 stages
- Download your scenario with
demand.csv, SUMO network, and report
6. Run Headless (Optional) 🤖
You can run the full calibration pipeline directly from the command line, ideal for automation or remote servers.
# Basic usage (defaults: window=15, pop=50, gen=20)
demandify run "2.2961,48.8469,2.3071,48.8532" --name Paris_Test_01
# Advanced usage with custom parameters
demandify run "2.2961,48.8469,2.3071,48.8532" \
--name Paris_Optimization \
--window 30 \
--seed 123 \
--pop 100 \
--gen 50 \
--mutation 0.5 \
--elitism 2
Note: The CLI will pause after fetching/matching data to show matching statistics and ask for confirmation before starting the intensive calibration.
Parameters
| Argument | Type | Default | Description |
|---|---|---|---|
bbox |
String | (Req) | Bounding box (west,south,east,north) |
--name |
String | Auto | Custom Run ID/Name |
--window |
Int | 15 | Simulation duration (min) |
--seed |
Int | 42 | Random seed |
--pop |
Int | 50 | GA Population size |
--gen |
Int | 20 | GA Generations |
--mutation |
Float | 0.5 | Mutation rate (per individual) |
--crossover |
Float | 0.7 | Crossover rate |
--elitism |
Int | 2 | Top individuals to keep |
--sigma |
Int | 20 | Mutation magnitude (step size) |
--indpb |
Float | 0.3 | Mutation probability (per gene) |
--origins |
Int | 10 | Number of origin candidates |
--destinations |
Int | 10 | Number of destination candidates |
--max-ods |
Int | 50 | Max OD pairs to generate |
--bin-size |
Int | 5 | Time bin size in minutes |
--initial-population |
Int | 1000 | Target initial number of vehicles (controls sparse initialization) |
How It Works
demandify follows an 8-stage pipeline:
- Validate inputs - Check bbox, parameters, API key
- Fetch traffic snapshot - Get real-time speeds from TomTom
- Fetch OSM extract - Download road network data
- Build SUMO network - Convert OSM to car-only SUMO
.net.xml - Map matching - Match traffic segments to SUMO edges
- Initialize demand - Select origin/destination pairs and time bins
- Calibrate demand - Run GA to optimize vehicle counts
- Export scenario - Generate
demand.csv, routes, config, and report
Variability & Consistency
While demandify uses seeding (random seed) for all internal stochastic operations (OD selection, GA evolution), perfect reproducibility is not guaranteed due to the inherently chaotic nature of traffic microsimulation (SUMO) and real-time data inputs.
Seeding ensures consistency (runs look similar), but small timing differences in OS scheduling or dynamic routing decisions can lead to divergent outcomes.
Caching
demandify caches:
- OSM extracts (by bbox)
- SUMO networks (by bbox + conversion params)
- Traffic snapshots (by bbox + timestamp bucket)
- Map matching results
Cache location: ~/.demandify/cache/
Clear cache: demandify cache clear
CLI Commands
# Start web server (default)
demandify
# Run headless calibration
demandify run "west,south,east,north"
# Check system requirements
demandify doctor
# Clear cache
demandify cache clear
# Show version
demandify --version
Output Files
Each run creates a folder with:
demand.csv- Travel demand with exact schema:ID,origin link id,destination link id,departure timestep
trips.xml- SUMO trips fileroutes.rou.xml- Routed SUMO routesnetwork.net.xml- SUMO networkscenario.sumocfg- SUMO configuration (ready to run)observed_edges.csv- Observed traffic speedsrun_meta.json- Complete run metadatareport.html- Calibration report with visualizations
Run the scenario:
cd demandify_runs/run_<timestamp>
sumo-gui -c scenario.sumocfg
Configuration
API Keys
Three ways to provide your TomTom API key:
- Web UI: Paste in the form (saved to
~/.demandify/config.json) - Environment variable:
export TOMTOM_API_KEY=your_key .envfile: Copy.env.exampleto.envand add your key
Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black demandify/
# Lint
ruff check demandify/
License
MIT
Acknowledgments
- SUMO: Eclipse SUMO
- TomTom: Traffic Flow API
- OpenStreetMap: © OpenStreetMap contributors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file demandify-0.0.1.tar.gz.
File metadata
- Download URL: demandify-0.0.1.tar.gz
- Upload date:
- Size: 2.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf33bc15928908fe1e16bd8c5deea8ba7156cbe71bc6cc5dbfdb1a421a02b819
|
|
| MD5 |
62dc71494cfd295c6ebd783577166e87
|
|
| BLAKE2b-256 |
c34258756a372c1bcc3a9404a34275fcab8e6e603d6f8ca632b2971dc16d81a9
|
File details
Details for the file demandify-0.0.1-py3-none-any.whl.
File metadata
- Download URL: demandify-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f09762331c4830d9c81f8edb017d11b1e0a0425967622de5cd62f9ced01d29d
|
|
| MD5 |
867c8165d823c58a837318f5c2d13800
|
|
| BLAKE2b-256 |
2718a14f925325a0ae60f3732249cf58c30bff4a44b91621914c7ce2023748fc
|