# CQFormer: Cyclic Quasi-Dynamic Transformers for Hourly Origin-Destination Estimation
## 1 Introduction  
The origin-destination matrix (OD matrix) reflects the expected movement intensity of road users, where each element is the number of trips between the two traffic analysis zones (TAZs). It can represent the traffic demand over different time scales, from hours to years, corresponding to the dynamic and static OD inference problem, respectively. In the short term, it can be applied both as the initial input to the simulator and to boost the precision of short-term traffic flow forecasts. In the long term, the OD matrix provides the details on the average daily mobility needs of city's inhabitants and can help assess the urban layout's rationality and plan future infrastructure development. The primary challenge in obtaining OD matrices lies in the inherent difficulties of directly observing traffic demand, and the inverse engineering of traffic assignment is aviable option, since OD estimation and traffic assignment are a pair of endogenous and inseparable processes [1]. The OD estimation issue has been receiving continuous attention due to its significance. In the era of Intelligent Transportation Systems (ITS), the greater variety of data sources and advanced algorithms provides new opportunities for resolving this age-old problem more accurately and efficiently. The data for OD estimation can be derived from traffic counts [2], automatic vehicle identification [3; 4; 5], cellphone signaling [6; 7], and floating vehicle tracks [8; 9; 10]. With these data, numerous novel and practical methods have been devised such as Probabilistic Tensor Factorization [11], Hierarchical Flow Network [12], Res3D [5], Path/Subpath-based Model [13; 14], etc. However, these multi-source data are not readily available in any scenario, and traffic count data remain among the most accessible data in the transportation domain. They refer to the number of vehicles that pass each road during a specific period, which can come from manual counting, loop detection, and video recognition. With these data, there were generally three branches of methods developed: Constrained Optimization, Iterative State Estimation (Kalman Filter), and Gradient-based Estimation (Simultaneous Perturbation Stochastic Approximation, Neural Networks). Despite relentless progress, estimating the OD matrix from traffic count remains an interesting but challenging task. The uncertainty of traffic demand patterns, path selection, and traffic dynamics makes the OD estimation an under-determined problem, where unknown variables outnumber the recognized ones. To address this, the quasi-dynamic assumption has been proposed, which implies that the OD matrix remains stable for a short period, and the relatively changing demand structure can be estimated by more frequent observations of traffic counts [15; 16; 17]. Attempts have also been made to determine the basic demand structures by introducing prior matrices or additional assumptions. However, since the traffic demand patterns/structures in reality are diverse [18], the prior distribution from a handful of prior matrices or prior assumptions is inevitably different from the real one, called distribution shift. The distribution shift makes the well-calibrated model not necessarily generalize well to inferring OD matrices with different demand structures. Machine learning provides an excellent way to establish probabilistic mapping from traffic count to OD matrices with various traffic demand structures [12; 19; 20], but distribution shift still exists between the data distribution in the training set and in the test set, which may further lead to overfitting and degrade performance of OD estimation. In this article, we apply prior OD matrices with multiple demand structures and calibration algorithms to generate diverse OD matrices, then use the calibrated simulation-based dynamic traffic assignment (DTA) model to generate traffic count-OD paired data. With these data, we further propose cyclic quasi-dynamic transformers (CQDFormer) for hourly OD estimation using traffic count data.