Skip to content

About

Real-time urban parking dynamic pricing & congestion rerouting engine built from scratch with Python, Pathway streaming, NumPy, Pandas, and Bokeh.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Real-Time Dynamic Pricing Engine for Urban Parking Lots

An end-to-end streaming dynamic pricing and congestion-rerouting engine built from scratch using Python, NumPy, Pandas, Pathway, and Bokeh (Summer Analytics 2025 Capstone — Consulting & Analytics Club × Pathway).

Problem & Architecture

Static parking tariffs cause peak-hour overcrowding and off-peak underutilization. This system ingests chronologically ordered telemetry across 14 urban parking lots (18,368 raw records spanning 73 days), normalizes multi-factor demand signals, incorporates spatial competitor pricing via Haversine proximity, and emits smooth, bounded prices ($5.00–$20.00 from a $10.00 base) through a real-time Pathway streaming pipeline.

dataset.csv (18,368 rows, 14 lots)
   │
   ▼  Data Audit & Cleaning (dedup 86 keys, clip 241 >100% occ, encode 'cycle', flag GPS outlier)
   │
   ├──► Model 1: Daily-Reset Linear Baseline (Occupancy / Capacity)
   ├──► Model 2: Tanh-Normalized Demand + EMA Smoothing (η = 0.45)
   ├──► Model 3: Haversine Spatial Competition (1.0 km) + Rerouting Engine
   │
   ▼  Pathway Real-Time Simulation (pw.demo.replay_csv → @pw.udf → 30-min tumbling windows)
   │
   ▼  Interactive Bokeh Dashboards (Multi-model comparison, cluster competition, streamed market avg)

Key Engineering & Quantitative Results

  • Data Quality & Anomaly Handling: Cleaned 18,368 → 18,282 unique (lot, timestamp) records by resolving 86 duplicate timestamp rows, clipping 241 over-capacity readings (>100% utilization), encoding an undocumented cycle vehicle class (1,762 rows), and isolating a ~1,561 km GPS coordinate outlier (BHMMBMMBX01) so spatial pricing never degrades.
  • Price Smoothness & Volatility Control: Applying tanh demand normalization with per-lot EMA smoothing (η = 0.45) reduced step-to-step price jitter by 44.1% ($1.067 → $0.596/step), and spatial competition in Model 3 further reduced it to 46.5% total ($0.571/step).
  • Demand Elasticity & Revenue Impact: Model 3 differentiates off-peak ($7.44 avg at <40% occupancy) from peak congestion ($14.10 avg at >=80% occupancy), delivering a +7.64% simulated revenue proxy lift (+8.58% in Model 2) over static $10.00 pricing while keeping the overall mean price anchored at $10.11.
  • Automated Congestion Rerouting: Triggered 1,639 real-time reroute recommendations (9.0% of intervals) when a lot reached >=85% occupancy while cheaper nearby lots (<=1.0 km) had available capacity, saving drivers $9.55 on average (up to $11.23).
  • Real-Time Streaming Pipeline: Replayed globally time-ordered sensor events through Pathway (pw.demo.replay_csv, @pw.udf, pw.temporal.tumbling 30-minute aggregations, and pw.io.csv.write) with persisted Bokeh visualizations.

Model Summary

Model Mean Price Std Dev Range Off-Peak (<40%) Peak (>=80%) Revenue Lift vs. $10
Static Baseline $10.00 $0.00 [$10.00, $10.00] $10.00 $10.00 0.00%
Model 1 (Linear) $13.30 $2.79 [$10.00, $20.00] — — —
Model 2 (Demand + EMA) $10.04 $3.48 [$5.00, $17.21] $6.78 $15.09 +8.58%
Model 3 (Competitive + Reroute) $10.11 $2.93 [$5.07, $17.06] $7.44 $14.10 +7.64%

Repository Files

Quickstart

Option 1: Google Colab (Full Pathway Streaming + Bokeh)

  1. Upload dynamic_pricing_capstone.ipynb and dataset.csv to Google Colab (Linux runtime required for pathway).
  2. Run Runtime → Run all; missing packages (pathway, bokeh) are installed automatically in Cell 1.
  3. Inspect the interactive Bokeh comparisons and the streamed pathway_pricing_output.csv / pathway_market_window.csv outputs.

Option 2: Local Module & Unit Tests

pip install -r requirements.txt
pytest -v

About

Real-time urban parking dynamic pricing & congestion rerouting engine built from scratch with Python, Pathway streaming, NumPy, Pandas, and Bokeh.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages