This repository contains the PyTorch implementation of our paper titled "HAD-Gen: Human-like and Diverse Agent Behavior Modeling for Controllable Scenario Generation".
HAD-Gen can controllably generate human-like and diverse scenarios for autonomous vehicle testing and validation.
Superior Generalization: Compared with baselines, our trained policies demonstrate the strongest generalization ability and can adapt to new real-world scenarios.
Workflow:
- Data Clustering: Driving behavior in the dataset is clustered into Aggressive, Normal, and Cautious categories
- Reward Reconstruction: Each sub-dataset is used to reconstruct a reward function representing human driving behavior
- Policy Training: Reconstructed rewards enable offline RL and MARL to generate driving policies for each cluster
- Scenario Generation: Various driving policies are deployed in simulation using a policy selection strategy
This project uses the AUTOMATUM dataset. Install the Python utility to interface with the data:
pip3 install openautomatumdronedataFollow these steps in order:
-
Clustering Analysis
python riskclustering.py
Generates clustering results saved as JSON files in
scenarios/configs/ -
Feature Extraction
python feature_extraction_irl.py
Extracts feature values from dataset for IRL processing
-
IRL Training
python training_irl.py
Trains MaxEnt IRL and saves weights as
xxxtraining_log.pkl -
Feature Normalization
python feature_normalization.py
Calculates mean and standard deviation for feature normalization
-
Data Preprocessing
python preprocessing.py
Requires:
feature_normalization.pklandXXXtraining_log.pkl
Choose your training approach:
- Offline RL:
python td3bc_automatum.py - SAC (Log-Replay):
python sac/model.py - Online RL (Self-Replay):
python train_multicar.py
/baselines: Implementation of baseline algorithms/evaluation: Metrics, unit tests, scoring, evaluation, and plotting code/simulator: Lightweight simulator and RL environment implementations
evaluation/evaluation_methods.py: Evaluate baseline performancebaselines/bc_baseline.py: Train Behavioral Cloning baselinebaselines/model.py: Train SAC baselinesimulator/lightweight_simulator.py: Run lightweight simulations
Set these parameters in simulator/lightweight_simulator.py:
| Parameter | Description | Options |
|---|---|---|
spawn_method |
Data sampling method | "dataset_one" (micro analysis)"dataset_all" (macro analysis) |
policy_type |
Policy selection | "bc-all-obs-5_pi" (BC)"sac_5_rl" (SAC)"idm" (IDM) |
# Install the 'gym_env' package in development mode
pip install -e simulator/gym_env
# Install PyTorch (from official website)
# Install additional requirements
pip install -r requirements.txtOpenDRIVE Map Issues: If you encounter errors about None header attributes, modify map files:
<!-- Change this line in each map file -->
<OpenDRIVE xmlns="http://www.opendrive.org">
<!-- To this -->
<OpenDRIVE>If you use this code in your research, please cite our paper:
@article{WANG2025108270,
title = {HAD-Gen: Human-like and diverse driving behavior modeling for controllable scenario generation},
journal = {Accident Analysis & Prevention},
volume = {223},
pages = {108270},
year = {2025},
issn = {0001-4575},
doi = {https://doi.org/10.1016/j.aap.2025.108270},
url = {https://www.sciencedirect.com/science/article/pii/S0001457525003586},
author = {Cheng Wang and Lingxin Kong and Massimiliano Tamborski and Stefano V. Albrecht},
}We welcome contributions! Please feel free to submit issues, feature requests, or pull requests.
This project is licensed under the terms specified in the LICENSE file.



