This project provides a reinforcement learning-based framework for optimizing traffic flow at complex urban intersections. A Deep Q-Learning agent is trained to intelligently control traffic signal phases in order to minimize congestion and waiting times, ultimately improving traffic efficiency.
- Algorithm: Q-Learning with a Deep Neural Network
- Objective: Optimize traffic light phases to reduce cumulative waiting time
- Intersection: 4-way, with 4 incoming and outgoing lanes per arm (each 750 meters long)
- Traffic Lights: Dedicated lanes for specific movement directions (left, straight, right)
- Each episode simulates 1000 vehicles
- Traffic patterns vary dynamically across episodes
- State: Discretized vehicle positions on lanes (80-cell binary vector)
- Action: Selection from 4 pre-defined traffic light phases, each lasting 10 seconds
- Reward: Based on the reduction in cumulative vehicle waiting time
- Learning: Q-learning with a neural network to approximate Q-values for state-action pairs
Ensure the following dependencies are installed on your system:
| Tool | Version |
|---|---|
| Python | 3.11 |
| SUMO Simulator | 1.2.0 |
| TensorFlow | 2.16.1 |
| TensorFlow GPU | 2.5.0 (optional) |
| NumPy | 1.19.5 |
| Matplotlib | 3.6.0 |
-
Install Anaconda
Download Anaconda -
Install SUMO
Download SUMO -
Clone the Repository
git clone https://github.com/yourusername/traffic-light-optimization.git
cd traffic-light-optimization- Install Dependencies
pip install -r requirements.txt- Set SUMO Environment Variable
export SUMO_HOME="/path/to/sumo"Start the training process:
python training_main.pyFor testing:
python testing_main.py| Component | Description |
|---|---|
| Model | Defines the neural network architecture |
| Memory | Handles experience replay buffer |
| Simulation | Manages the traffic environment and interaction with SUMO |
| Traffic Generator | Generates vehicle routes for each episode |
| Visualization | Plots performance metrics (reward, delay, queue length) |
| Utils | Manages configuration, file handling, and SUMO setup |
All training and testing parameters are specified in:
training_settings.initesting_settings.ini
These include:
- Simulation duration
- Number of episodes
- Vehicle generation count
- Neural network layers and learning rate
- Traffic light durations (green/yellow)
| Metric | Value |
|---|---|
| Accuracy | 80% |
| Precision | 85.83% |
| Recall | 80% |
| F1 Score | 79.05% |
Visualizations for reward trends, queue lengths, and waiting times are generated and saved automatically during training and testing.
contact KABILASH S -kabilash0108@gmail.com
This project is licensed under the MIT License.