Dynamic Graph Learning Based on Hierarchical Memory for Origin-Destination Demand Prediction

Ruixing Zhang, Liangzhe Han, Boyi Liu, Jiayuan Zeng, Leilei Sun

Abstract

Recent years have witnessed a rapid growth of applying deep spatiotemporal methods in traffic forecasting. However, the prediction of origin-destination (OD) demands is still a challenging problem since the number of OD pairs is usually quadratic to the number of stations. In this case, most of the existing spatiotemporal methods fail to handle spatial relations on such a large scale. To address this problem, this paper provides a dynamic graph representation learning framework for OD demands prediction. In particular, a hierarchical memory updater is first proposed to maintain a time-aware representation for each node, and the representations are updated according to the most recently observed OD trips in continuous-time and multiple discrete-time ways. Second, a spatiotemporal propagation mechanism is provided to aggregate representations of neighbor nodes along a random spatiotemporal route which treats origin and destination as two different semantic entities. Last, an objective function is designed to derive the future OD demands according to the most recent node representations, and also to tackle the data sparsity problem in OD prediction. Extensive experiments have been conducted on two real-world datasets, and the experimental results demonstrate the superiority of the proposed method.

Introduction

Predicting Origin-Destination (OD) demand—the volume of traffic between specific pairs of locations—is a cornerstone of Intelligent Transportation Systems (ITS). Despite its importance, OD prediction faces three significant challenges. First is quadratic complexity: a network with $N$ stations involves $N^2$ potential pairs, making traditional spatial models computationally prohibitive. Second is the time granularity dilemma: while traffic events occur continuously, models often discretize time into fixed slices, losing either fine-grained detail or becoming overwhelmed by noise. Third is semantic confusion: stations often play distinct roles as origins or destinations (e.g., a residential area in the morning vs. evening), yet many models treat them identically.

Methodology

The proposed Hierarchical Memory Origin-Destination (HMOD) framework addresses these issues through a multi-faceted approach that integrates continuous-time updates with multi-level discrete-time memories.

The overall HMOD architecture, illustrating the integration of random walk sampling, hierarchical memory updates, and the final prediction layer.

Hierarchical Memory Updater

HMOD maintains a hierarchy of node memories ($H^0, H^1, \dots, H^D$). $H^0$ captures continuous-time updates triggered by individual trips, while $H^1$ through $H^D$ track macro-states over increasing discrete intervals (e.g., 30 and 60 minutes).

Detailed view of the Message Fusion and Memory Updater components within the hierarchical memory system.

A Message Fusion mechanism enables information sharing across these layers, allowing the model to reconcile immediate traffic spikes with long-term periodic patterns. This ensures that the node representations are both time-aware and contextually rich.

Role-Aware Node Embedding

To manage spatial relations efficiently, HMOD employs spatiotemporal random walks. Unlike standard graph neural networks, it distinguishes between node roles using separate transformation matrices ($W^O$ and $W^D$) for origins and destinations. This "role-aware" approach allows the model to capture functional similarities between stations that serve similar purposes at specific times of day.

Sparsity-Aware Objective Function

OD demand data is notoriously sparse, with many pairs showing zero demand. Standard Mean Squared Error (MSE) loss can lead to instability or overfitting to these zeros. HMOD introduces a specialized loss function that relaxes the penalty for "no-demand" pairs, improving training stability and predictive accuracy.

Evaluation

The model was evaluated on two massive, real-world datasets: Beijing Metro (containing over 200 million timestamped trips across 268 stations) and New York Taxi (containing over 38 million trips across 63 regions).

HMOD consistently outperformed all baselines, including traditional statistical models, gradient boosting (XGBoost), and state-of-the-art graph neural networks (GEML, TGN). On the Beijing Metro dataset, HMOD reduced the Root Mean Squared Error (RMSE) to 3.7686, a significant improvement over the next best model, GEML (4.6143). The Pearson Correlation Coefficient (PCC) reached 0.8861, indicating a very high alignment between predicted and actual demand.

Conclusion

HMOD demonstrates that combining continuous and discrete time scales with role-based embeddings significantly improves OD demand prediction. By utilizing random walks for neighbor aggregation, the framework remains computationally feasible for large-scale city networks. Future research directions include integrating external factors like weather and events, as well as optimizing neighbor discovery in extremely dense networks.

Summary updated

BibTeX
@inproceedings{zhang2022dynamic,
  author = {Ruixing Zhang and Liangzhe Han and Boyi Liu and Jiayuan Zeng and Leilei Sun},
  title = {{Dynamic Graph Learning Based on Hierarchical Memory for Origin-Destination Demand Prediction}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2022},
  url = {https://openreview.net/forum?id=AeInMRutI2},
}
Figure