DeepMobility
The official implementation of the manuscript Learning the complexity of urban mobility with deep generative collaboration network.
Install / Use
/learn @tsinghua-fib-lab/DeepMobilityREADME
DeepMobility
This is the official implementation of the manuscript Learning the complexity of urban mobility with deep generative collaboration network.
In this project, we introduce DeepMobility, a powerful deep generative collaboration network to bridge the heterogeneous behaviors of individuals and collective behaviors emerging from the entire population. Our model excels in learning the intricate data distribution and successfully reproduces the existing universal scaling laws that characterize human mobility behaviors at both the individual and population levels. It also exhibits robust generalization capabilities, enabling it to generate realistic trajectories and flows for cities lacking corresponding training data.
Architecture of DeepMobility

Installation
Environment
- Tested OS: Linux
- Python >= 3.7
- PyTorch == 1.7.1
Dependencies
- Install PyTorch with the correct CUDA version.
- Use the
pip install -r requirements. txtcommand to install all of the Python modules and packages used in this project.
Data
We use four datasets to demonstrate the DeepMobility generation framework. The first two datasets (DS1, DS2) use the anonymized location record of about 1.8 million users in Beijing, China and 0.32 million users in Shenzhen, China, respectively. The third dataset (DS3) covering Shanghai (China) consists of around 1.9 million anonymized users of China’s major telecom company. The fourth dataset (DS4) of Senegal is based on anonymized call detail records (CDRs) from about 0.3 million users during a two-week period with a temporal resolution of 10 min. We provide the processed data of all four scenarios used in our paper, including Beijing, Shanghai, Shenzhen, and Senegal. For each case, we provide the following data:
data.json: the individual trjaectoriesloc2region.json: the transformation from location index to region indexregion2loc.json: the transformation from region index to location indexOD_6.npy: dynamic origin-destination flows between regions, where the row index corresponds to the region index of the origin. It is aggregated by six hours, so there are four values for an origin-destination pair in a dayLocIndex2lonlat: the transformation from location index to region longitude and latitudeRegionIndex2lonlat: the transformation from Region index to region longitude and latituderegion_attribute.csv: the attributes of the region, where the attribute name is recorded as the column name
To access the datasets, please refer to data readme.
Model Training
For example, to train a model for the Shanghai city, run:
python main.py --cuda_id 0 --run_name 'model_training' --dataset 'shanghai' --city_param shanghai --lr 1e-4 --disc_lr 1e-4 --no_entropy_decay --actor_high_pretrain_epoch 200 --actor_low_pretrain_epoch 10 --uncertainty 2.0 --with_evaluate --evaluate_batch 20000 --simulate_batch_size 128 --gail_batch_size 1024 --mode training
you can also include some parameters related to the model in Parameters.
Once your model is trained, you will find the logs recording the training process in the ./tensorboard_log directory. The folder will be named as the start timne of the experiments. In the ./ModelSave folder, you will find the trained model named model_<epoch>.pkl and the generated synthetic data.
Data Generation
For example, to generate the mobility data for the Shanghai city with a pre-trained model, run:
python main.py --cuda_id 0 --run_name 'data_generation' --dataset 'shanghai' --city_param shanghai --generate_num 20000 --pretrained_model_path model.pkl --simulate_batch_size 100 --mode generating
The generated mobility data will be saved in ./gen_data/.
Demo to Run the Code
We provide a test demo to illustrate the training process of the model. It only include a samll amount of data with only 1-epoch training. You will see the following logs once you start training our model:
https://github.com/tsinghua-fib-lab/DeepMobility/assets/29177088/8c413354-f30d-4e2a-8361-c60078c7016a
License
Please see the license for further details.
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
best-practices-researcher
The most comprehensive Claude Code skills registry | Web Search: https://skills-registry-web.vercel.app
groundhog
398Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
isf-agent
a repo for an agent that helps researchers apply for isf funding
