DOI: 10.3390/ijgi15100437 ISSN: 2220-9964

DSCFormer: A Dynamic Sparse Causal Attention Network for Efficient Traffic Flow Prediction

Xuhai Fan, Linglong Zhu

Traffic flow prediction is a core task in intelligent transportation systems, yet existing Transformer-based models suffer from high computational complexity, weak dynamic spatial modeling, and a lack of strict temporal causality constraints. We propose the dynamic sparse causal attention network (DSCFormer), which jointly models static and dynamic spatial information by combining Laplacian positional encoding with a sliding window-based dynamic adjacency matrix. A sparse causal attention mechanism reduces complexity through neighbor selection and enforces temporal causality via a lower-triangular causal mask, with a controlled accuracy–efficiency trade-off (12-step averaged mean absolute error (MAE) 13.18 at γ=0.20 versus 12.89 for dense attention on PeMS08). A dual-window hierarchical temporal self-attention separately captures short-term fluctuations and long-term periodicities, fused by a data-driven weight. Experiments on six public datasets, including PeMS highway and urban grid-based data, show that DSCFormer achieves 1.6%, 1.4%, and 1.9% lower MAE, root mean squared error (RMSE), and mean absolute percentage error (MAPE) than PDFormer (the strongest baseline), averaged over nine evaluation settings (three PeMS datasets and six grid inflow/outflow tasks), and 5.2%, 6.8%, and 4.7% lower than the mean of all 16 baselines under the same settings, where relative improvement is computed as Δ=(Scorebaseline−ScoreDSCFormer)/Scorebaseline×100%. DSCFormer also reduces inference time by 8.7%, parameter count by 6.7%, and total FLOPs by 8.3% relative to PDFormer on PeMS08.