A comprehensive Streamlit-based digital twin simulation platform for battery swap station networks. This tool allows operations planners to test "what-if" scenarios before deploying changes in the real network.
- Real-time Network Overview: View all swap stations on an interactive Delhi map
- Live KPI Monitoring: Track key performance indicators including:
- Average wait time
- Lost swaps per hour
- Idle inventory
- Charger utilization
- Operational cost
- City throughput
- Station Details: Click on any station to view detailed metrics and configuration
-
Demand Changes:
- City-wide demand multiplier
- Station-specific overrides
- Time-window surge events
-
Infrastructure Changes:
- Add new swap stations
- Modify existing stations (increase/decrease chargers)
- Disable stations for maintenance scenarios
-
Policy Configuration:
- Fixed threshold replenishment
- Scheduled refill
- Predictive refill
- Inter-station balancing
- KPI Comparison: Side-by-side baseline vs scenario comparison
- Confidence Intervals: 95% CI for predictions
- Time Series Visualizations: Track metrics over simulation horizon
- Cost-Benefit Analysis: Financial impact assessment with ROI calculations
- Interactive Maps: Visualize network changes and station status
- Python 3.8 or higher
- pip package manager
-
Clone or download the project files
-
Install required dependencies:
pip install -r requirements.txtRequired packages:
- streamlit
- folium
- streamlit-folium
- plotly
- pandas
- numpy
- matplotlib
- scipy
- fpdf
- Pillow
- Run the application:
streamlit run app.pyThe dashboard will open automatically in your default web browser at http://localhost:8501
- Start at the Dashboard Home
- Review current network KPIs
- Click on station markers to view detailed information
- Identify bottlenecks and underutilized stations
- Navigate to Scenario Builder
- Configure your intervention:
- Demand Tab: Adjust demand patterns (e.g., +20% city-wide, concert event surge)
- Infrastructure Tab: Add stations or modify existing ones
- Policy Tab: Select replenishment strategy
- Review the scenario summary
- Click Run Simulation
- The system will automatically switch to Results Analysis
- Review KPI comparison table
- Check confidence intervals for reliability
- Examine time series charts for temporal patterns
- Assess cost-benefit analysis for financial viability
- View updated network map with changes highlighted
- Return to Scenario Builder to test alternative interventions
- Compare up to 2 scenarios simultaneously
- Export results as PDF report (coming soon)
The simulation engine implements the following mathematical models from the problem statement:
W_q,i(t) = (c_i * Ο_i(t))^c_i * Ο_i(t) / (c_i! * (1 - Ο_i(t))^2 * Ξ»_i(t)) * P_0,i(t)
LostSwaps_i(t) = Ξ»_i(t) * P_K,i(t)
IdleInventory_i(t) = c_i - Ξ»_i(t) / ΞΌ_i
Utilization_i(t) = Ο_i(t) = Ξ»_i(t) / (c_i * ΞΌ_i)
Cost_i(t) = Ξ±*c_i + Ξ²*Ξ»_i(t)*W_q,i(t) + Ξ³*LostSwaps_i(t)
CityThroughput(t) = Ξ£_i min(Ξ»_i(t), c_i*ΞΌ_i)
- Ξ± (Alpha): Fixed cost coefficient (default: βΉ1000/hour)
- Ξ² (Beta): Wait time cost coefficient (default: βΉ50/minute)
- Ξ³ (Gamma): Lost swap cost coefficient (default: βΉ200/swap)
- Configurable from 1 hour to 168 hours (1 week)
- Simulation runs at minute-level granularity
Each station has:
- Chargers (c_i): Number of charging units
- Bays: Number of swap bays
- Inventory Capacity: Maximum batteries
- Arrival Rate (Ξ»_i): Customers per minute
- Service Rate (ΞΌ_i): Swaps per charger per minute (default: 0.5)
The system includes 8 pre-configured stations across Delhi:
- Connaught Place Hub
- Karol Bagh Station
- Nehru Place Center
- Dwarka Express
- Rohini Junction
- Lajpat Nagar Point
- Saket Mall Station
- Mayur Vihar Hub
- Intervention: Add mobile station near venue + 300% demand surge
- Expected Impact: -68% wait time, -83% lost swaps
- ROI: Positive net impact
- Intervention: Add 2 new stations in underserved areas
- Expected Impact: +25% throughput, -40% city-wide lost swaps
- Cost: Additional βΉ2L/month operational cost
- Intervention: +2 chargers at top 3 bottleneck stations
- Expected Impact: -30% wait time at those stations
- ROI: High (lower marginal cost than new station)
The dashboard follows BatterySmart's brand identity:
- Primary Colors: Blue (#0066CC) and Green (#00CC66)
- Light Theme: Clean, professional interface
- Status Indicators:
- π’ Green: Healthy (utilization < 75%)
- π Orange: Warning (utilization 75-90%)
- π΄ Red: Critical (utilization > 90%)
βββββββββββββββββββββββββββββββββββββββ
β Streamlit Frontend β
β - Interactive Dashboard β
β - Folium Maps β
β - Plotly Visualizations β
βββββββββββββββ¬ββββββββββββββββββββββββ
β
βββββββββββββββΌββββββββββββββββββββββββ
β Simulation Engine (Python) β
β - Discrete-event simulation β
β - Queueing theory models β
β - KPI calculations β
βββββββββββββββ¬ββββββββββββββββββββββββ
β
βββββββββββββββΌββββββββββββββββββββββββ
β Session State (In-memory) β
β - Station configurations β
β - Simulation results β
β - Scenario definitions β
βββββββββββββββββββββββββββββββββββββββ
- PDF report export functionality
- Multi-scenario comparison (>2 scenarios)
- Historical data import from CSV
- Machine learning-based demand forecasting
- Real-time data integration via API
- User authentication and saved scenarios
- Collaborative scenario sharing
- Advanced optimization algorithms
- 3D visualization with Pydeck
- Mobile-responsive design
Issue: Map not displaying
- Solution: Ensure internet connection for OpenStreetMap tiles
Issue: Simulation takes too long
- Solution: Reduce time horizon or increase time step
Issue: Memory error on long simulations
- Solution: Results are sampled every 30 minutes; adjust for longer horizons
This project is part of the HackSmart challenge solution.
Digital Twin Development Team
For issues or questions, please refer to the HackSmart documentation.
Built with β€οΈ using Streamlit, Folium, and Plotly