Skip to main content
Back

TrajFlow Generates Fake GPS Trajectories at Country Scale Where Diffusion Fails

A new flow-matching model generates realistic mobile-phone GPS traces across an entire country, beating diffusion baselines with far fewer sampling steps.

Pro

  • TrajFlow is the first flow-matching generative model for GPS trajectories, presented at ICLR 2026.
  • It generates pseudo trajectories at urban, metropolitan, and nationwide scales, unlike prior single-city diffusion models.
  • Trained on millions of real mobile-phone GPS traces across Japan (BW dataset, private).
  • Beats DiffTraj, GAN, and VAE baselines on Density JS, Fréchet, and DTW metrics at every scale.
  • Uses far fewer ODE sampling steps than diffusion, cutting generation cost significantly.
  • Code available at GitHub under CC BY-NC 4.0; no checkpoints or private data included.

Synthetic mobility data has been stuck at city scale. A new model called TrajFlow pushes it to an entire country, using flow matching instead of diffusion to generate pseudo GPS trajectories that hold up at urban, metropolitan, and nationwide scales. It is the first model to apply the flow-matching paradigm to GPS trajectory generation, and the authors argue it is also the first generator that works at nation scale rather than inside a single city.

Why fake GPS data is hard to make

Mobile-phone GPS traces power everything from traffic simulation to disaster response planning, but real trajectories are locked up. The use of real data is often hindered by privacy concerns, limited accessibility, and high acquisition costs, which has pushed the field toward generating synthetic replacements. The state of the art has been diffusion models, and they work well, just not at scale.

The problem shows up as soon as you zoom out. When existing diffusion generators like DiffTraj are asked to produce trajectories over regions larger than a single dense urban core, their quality collapses across every standard metric.

Line graphs showing DiffTraj metric degradation from Central Tokyo to nationwide Japan

The core issues are threefold: recent diffusion-based approaches have achieved strong fidelity but remain limited in spatial scale (small urban areas), transportation-mode diversity, and efficiency (requiring numerous sampling steps). A nationwide dataset mixes walking, driving, and rail, spans wildly different geographies, and needs to be sampled fast enough to be practical, none of which suits a hundred-step denoiser.

From denoising to flowing

Flow matching is the alternative TrajFlow leans on. If you have not touched it before, the intuition is simple. Diffusion learns to reverse a noise process step by step. Flow matching models learn a vector field that directly models the flow of particles from a simple base distribution (e.g., a standard Gaussian) to a complex target data distribution over a time interval from 0 to 1. Training reduces to a plain regression loss on that vector field, and generation reduces to integrating an ODE, which typically needs far fewer steps than diffusion sampling.

That matters here because prior trajectory-generation methods, including recent diffusion-based models, rely on stochastic reverse-time SDE sampling and require tens to hundreds of denoising steps. Cutting that budget is what makes country-scale generation tractable.

What is actually new

Flow matching alone is not the whole story. The authors add two pieces that make it work on messy, real-world GPS:

  • Trajectory harmonization and reconstruction. A normalization and reconstruction pipeline that maps raw GPS into a feature space the flow model can learn cleanly, then decodes samples back into geographic coordinates. This jointly addresses scalability, diversity, and efficiency.
  • A tailored architecture. They introduce a trajectory normalization scheme and a specialized architecture tailored for flow matching, enabling the model to better handle spatial heterogeneity and further improve generation performance. Spatial heterogeneity is the technical way of saying that a trajectory in downtown Tokyo and one crossing rural Hokkaido have very different statistics, and one model has to handle both.
TrajFlow architecture diagram showing harmonization, U-Net backbone, and multi-scale generation

The dataset and the numbers

The main experiments run on a proprietary Japanese mobile-phone GPS dataset (called BW in the code) with millions of trajectories, evaluated at three zoom levels: Central Tokyo, the Tokyo Metropolis, and all of Japan. Baselines include DiffTraj (diffusion), a GAN, and a VAE. Standard fidelity metrics are used: Density Jensen-Shannon divergence for how well population-level spatial coverage matches, plus median Fréchet distance and median Dynamic Time Warping for shape similarity between generated and real trajectories.

The headline result: TrajFlow or its variants consistently outperform diffusion-based and deep generative baselines at urban, metropolitan, and nationwide levels. More concretely, it balances trajectory-shape fidelity, stability, and population-level spatial consistency across scales, and achieves competitive accuracy with substantially fewer ODE steps. The advantage grows as the region grows, which is exactly where diffusion baselines fall apart.

Where it helps, and where it does not

The practical pitch is straightforward. If you are building traffic simulators, testing routing algorithms, running epidemiological or disaster-response models, or need to share mobility data without exposing individuals, a nationwide synthetic generator is genuinely useful. The paper frames the applications as inter-region urban planning, traffic management, and disaster response, all cases where city-only generators have historically been too narrow.

The limits are worth stating clearly. Due to privacy constraints and data-access limitations, the authors focus on GPS trajectory generation and do not use any per-user attributes (e.g., age, gender, home-work identifiers) or persistent pseudonymous IDs, and thus the current model does not capture individual preferences. So TrajFlow is good at population-level realism, not at simulating specific people or personalized behavior. If your use case needs agent-level psychology, this is not that model.

Getting your hands on it

Code is published at github.com/ZeroCSIS/TrajFlow under CC BY-NC 4.0. A few caveats that matter if you want to actually run it:

  • The Japanese BW dataset is commercial and is not shipped with the repo.
  • Open-source support is provided for DiDi Chengdu and Xi'An data to verify that the pipeline works on public-style data, though you have to obtain those datasets yourself.
  • A toy synthetic dataset is included for smoke tests so you can verify the training and generation loop before wiring in real data.
  • No pretrained checkpoints are released, so you will need to train from scratch.

The training and generation entry points are straightforward once the environment is set up:

conda env create -f environment.yml
conda activate flow_matching_py311
python train.py --config ./src/config/config_chengdu.yaml
python generate.py --config ./outputs/run_.../config.yaml \
                   --checkpoint ./outputs/models/.../best_model.pt

The repo uses the public flow_matching library as a dependency rather than vendoring its own copy, so the flow-matching machinery is standard and the novelty sits in the trajectory-specific pieces around it. For anyone already working on mobility data, that makes TrajFlow a reasonable starting point to build on rather than a black box to reproduce.