Skip to content

HighOnKeys/dynamic-parking-pricing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dynamic Parking Pricing using Real-Time Streaming

This project implements dynamic parking pricing models using real-time streaming data, processed via Pathway and visualized with Bokeh. The objective is to optimize parking lot pricing dynamically based on demand signals such as occupancy volatility, queue length, traffic conditions, and more.


Models Implemented

Model Name Description
1 Linear Pricing Adjusts price based on daily fluctuations in occupancy rate.
2 Demand-Based Pricing Prices based on weighted demand factors such as queue, traffic, special day, and vehicle type.

Tech Stack

Category Tools/Libraries
Real-Time Engine pathway
Data Handling pandas, numpy
Visualization bokeh, panel, seaborn, matplotlib
Environment Google Colab / Jupyter
Output Formats CSV, JSONL, HTML

Architecture Diagram

Architecture diagram

This flowchart outlines the end-to-end pipeline for the Dynamic Parking Pricing system, detailing both Model 1 (Linear Pricing) and Model 2 (Demand-Based Pricing):

Overall Workflow:

Raw Data Input

  • Starts with a CSV dataset containing fields like timestamp, occupancy, capacity, queue length, traffic condition, vehicle type, and special day indicators.

Preprocessing

  • Combines date and time fields into a proper timestamp.
  • Computes occupancy rate as occupancy / capacity.

Real-time Stream Ingestion

  • The processed CSV is fed into the system using Pathway's CSV replay to simulate a real-time data stream.

Data Flow Summary

Model 1: Linear Pricing

➤ Group Data by Lot and Day Uses tumbling time windows to isolate and group each parking lot's data on a per-day basis.

➤ Compute Volatility Calculates the maximum and minimum occupancy rates observed throughout the day.

Formula:

price = 10 + (max_occupancy_rate - min_occupancy_rate) / capacity

➤ Save Output Saves per-lot, per-day prices as .jsonl and .html files for analysis and display.

➤ Visualize with Bokeh Generates interactive time-series plots of parking prices using Bokeh dashboards.

Workflow:

CSV ➝ Timestamp Merge ➝ OccupancyRate ➝ Pathway Tumbling Window ➝
Compute Max/Min ➝ Apply Price Formula ➝ JSONL Output ➝ Bokeh/Panel

Model 1 Visuals:

Model 1 Trend Model 1 Combined


Model 2: Demand-Based Pricing

➤ Encode Features Converts string-based inputs:

TrafficConditionNearby → Numeric traffic level

VehicleType → Encoded vehicle factor

➤ Group Data by Lot and Day Like Model 1, uses Pathway tumbling windows to aggregate per lot per day.

➤ Compute Averages Calculates daily average values for:

Occupancy Rate

Queue Length

Traffic Level

Vehicle Factor

Demand Formula:

demand = 1*occ + 0.5*queue - 0.2*traffic + 2*special + 0.8*vehicle

Price Formula:

price = base * (1 + lambda * min(demand / max_demand, 1))

base = 10

max_demand = 50

➤ Save Output Outputs are written to .jsonl and .html for tracking daily pricing trends.

➤ Visualize with Bokeh Interactive charts illustrate how price fluctuates based on demand-related features.

Workflow:

CSV ➝ Timestamp Merge ➝ Feature Encoding ➝ Pathway Tumbling Window ➝
Aggregate Demand Components ➝ Compute Demand ➝ Normalize ➝
Compute Price ➝ JSONL Output ➝ Bokeh/Panel

Model 2 Visual:

Model 2 Trend Model 2 Combined


Interactive HTML Outputs

File Description
outputs/model1_price_trends.html Lot-wise trends from Model 1
outputs/model2_price_trends.html Lot-wise trends from Model 2
outputs/model2_combined_price_comparison.html Combined trends across lots (Model 2)

CSV Pricing Outputs (converted from jsonl --> csv)

File Description
outputs/pricing_output_model1.csv Final price output from Model 1 (Linear-Based)
outputs/pricing_output_model2.csv Final price output from Model 2 (Demand-Based)

Notebooks Included

  • notebooks/model1_linear_pricing.ipynb
  • notebooks/model2_demand_pricing.ipynb

Project Status

  • Real-time stream simulation with Pathway
  • Model 1: Volatility-based pricing
  • Model 2: Demand-based pricing
  • Bokeh-based dashboard visualization
  • HTML/JSONL output export

Future Improvements

  • API Integration – Stream real-time data via WebSocket or REST.
  • Smarter Geospatial Logic – Use GPS and road network data.
  • Advanced Pricing Models – Add ML/RL-based dynamic pricing.
  • Better Visualizations – Interactive dashboards with filters and heatmaps.
  • Historical Logging – Store pricing data for analysis.
  • A/B Testing – Compare model performance across lots.
  • Modular Codebase – Refactor into reusable components with config support.
  • Docker Support – Easy deployment via Docker and Compose.
  • Testing & CI – Add unit tests and GitHub Actions.
  • Security Enhancements – Role-based access and secure endpoints.

About

Real-time dynamic parking pricing models using streaming data with Pathway, Bokeh, and Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published