TrafficFlowSim is a Python-based traffic congestion simulation tool that models vehicle movement across roads, simulating real-world congestion and traffic light behavior. This project uses SimPy for event-driven simulation, Pygame for visualization, and Matplotlib for data analysis and reporting.
- Real-Time Traffic Visualization
Vehicles move dynamically, and congestion levels influence vehicle speed. - Traffic Management Algorithms
- Knapsack Approach (Optimized traffic flow)
- Balanced Traffic Distribution
- Graphical User Interface (GUI)
Configure simulation parameters such as peak hours, vehicle rates, and road capacities using Tkinter. - Reporting and Visualization
Generates PDF reports with graphs detailing congestion levels, throughput, and road performance.
- Python
- SimPy (Event-driven simulation)
- Pygame (Visualization)
- Matplotlib (Graphs and charts)
- Tkinter (GUI)
- ReportLab (PDF generation)
- NumPy (Mathematical operations)
- Users configure traffic simulation settings via the GUI.
- The simulation generates random vehicles and distributes them across roads.
- Traffic lights change states, influencing vehicle movement.
- Congestion levels are monitored and visualized in real-time.
- Post-simulation, Matplotlib graphs and PDF reports summarize performance metrics.
- Clone the repository:
git clone <repo-url>
- Navigate to the project directory:
cd TrafficFlowSim
- Install dependencies:
pip install pygame simpy numpy matplotlib reportlab
- Run the simulation:
python traffic_simulator.py
- Adjust parameters through the GUI and start the simulation.
- Visualize real-time traffic and review the PDF report after the simulation.
TrafficFlowSim/
|-- traffic_simulator.py # Main simulation script
|-- README.md # Project documentation
|-- requirements.txt # List of dependencies
|-- traffic_simulation_summary.png # Visualization output
|-- traffic_simulation_report.pdf # PDF report (Generated post-simulation)
- Scenario: Simulate traffic on Mandela and Portmore roads.
- Parameters:
- Time Window: 24 hours
- Peak Hours: 6 AM - 8 AM
- Vehicle Entry Rate: 20 vehicles/hour
Feel free to submit issues or fork the project to add more features. Contributions are welcome!
MIT License