FuzzyLight is an intelligent traffic signal control system that combines fuzzy logic for phase selection with deep reinforcement learning (DDPG) for optimizing action duration. The system is designed to reduce traffic congestion and improve intersection efficiency.
This project implements a novel traffic light control algorithm that uses:
- Fuzzy Logic: For intelligent phase selection based on traffic flow patterns
- Deep Reinforcement Learning (DDPG): For optimizing signal duration timing
- Multi-Head Attention: For enhanced lane feature embedding and phase representation
- CityFlow Simulator: For realistic traffic simulation and evaluation
- Supports multiple city road networks (Hangzhou, Jinan, New York)
- Adaptive signal timing based on real-time traffic conditions
- Multi-intersection coordination support
- Configurable traffic scenarios and road networks
- Comprehensive performance evaluation and visualization
FuzzyLight/
├── models/ # Neural network models
│ ├── fuzzy_light.py # Main FuzzyLight agent (with attention)
│ ├── fuzzy_light_with_no_attention.py # Variant without attention
│ ├── agent.py # Base agent class
│ └── network_agent.py # Network agent implementation
├── utils/ # Utility functions and tools
│ ├── config.py # Configuration settings
│ ├── pipeline.py # Training pipeline
│ ├── cityflow_env.py # CityFlow environment wrapper
│ └── ... # Other utilities
├── data/ # Traffic data and road networks
│ ├── Hangzhou/ # Hangzhou traffic scenarios
│ ├── Jinan/ # Jinan traffic scenarios
│ └── newyork_28_7/ # New York traffic scenarios
├── run_fuzzylight.py # Main execution script
└── video.mp4 # Comparison video
- Python 3.x
- TensorFlow/Keras
- NumPy
- CityFlow (traffic simulator)
Run the FuzzyLight algorithm with default settings:
python run_fuzzylight.pyThe script supports various command-line arguments:
python run_fuzzylight.py \
-memo <memo_name> \ # Experiment name/memo
-mod <model_name> \ # Model name (e.g., "FuzzyLight", "DirectLight")
-gen <num_generators> \ # Number of generators (default: 1)
-multi_process \ # Enable multi-processing
-workers <num_workers> \ # Number of worker processes
-hangzhou \ # Use Hangzhou road network
-jinan \ # Use Jinan road network
-newyork # Use New York road networkRun with Hangzhou road network:
python run_fuzzylight.py -hangzhou -memo fuzzy_light_exp -mod FuzzyLightThe system uses fuzzy logic to select the optimal traffic phase based on lane queue lengths. It aggregates vehicle counts from different directions and selects the phase with the highest traffic demand.
The DDPG (Deep Deterministic Policy Gradient) algorithm is used to learn optimal signal duration:
- Actor Network: Predicts continuous action values (signal duration)
- Critic Network: Evaluates the quality of actions
- Multi-Head Attention: Enhances lane feature representation
- Ornstein-Uhlenbeck Noise: For exploration during training
- Phase Control Policy: Fuzzy logic-based phase selection
- Lane Embedding: Multi-head attention mechanism for lane feature extraction
- Actor-Critic Architecture: DDPG implementation for duration optimization
- Memory Buffer: Experience replay for training stability
Key configuration parameters can be modified in utils/config.py:
NUM_PHASES: Number of traffic phases (default: 4)MAX_LANE: Maximum number of lanes (default: 12)ACTION_DURATION: Valid signal duration optionsDIC_REWARD_INFO: Reward function weights- Learning rates, discount factors, and other hyperparameters
The included video.mp4 compares traffic light operation with and without the FuzzyLight algorithm, demonstrating improvements in traffic flow and reduced queue lengths.
If you use this code in your research, please cite the associated paper.
[Specify license here]
[Add contact information if needed]