# GenTrajRec: A Graph-Enhanced Trajectory Recovery Model Based on Signaling Data
## 4 Methodology
### ST-Layer and Trajectory Recovery Layer  
The ST-layer is used to obtain the spatial-temporal features of the output of the last feature fusion. In our model, we decide to use the transformer encoder part [41] to obtain the spatial-temporal features of the trajectory and the target.  
To achieve the task above, first, we need to construct the target embedding of the model, based on the position encoder, time encoder, and feature fusion. Suppose the time we want to recover the real position of the user at \(t_{pre}\), which can be used as the feature of the middle of the trajectory and the features of \(t_{pre}\) as the target time features. The target position features are defined as \(x_{pos}\) for each user u, and the ID and the middle coordinates of its kth coarse trajectory are \((v^{n}_{\iota k},lat^{n}_{u,k},lat^{n}_{u,k})\); to construct our target embedding of user \(u\)'s n-th coarse trajectory, the formulas should be  
\[T_{pre}=\text{Extract}(t_{pre}), \tag{14}\]  
\[x^{u}_{time,i}=\cos(\mathbf{W}_{pre}\mathbf{T}^{u}_{pre}+\mathbf{b}_{pre}), \tag{15}\]  
\[x^{u}_{pos,k}=\text{PosEncoder}(lat^{n}_{u,k},lat^{n}_{u,k}), \tag{16}\]  
\[\mathbf{X}^{u}_{target,k}=\text{FeatureFusion}(\text{FeatureFusion}(\mathbf{x}^{u}_{ pos,k},\mathbf{x}^{u}_{time,k},\text{Embedding}(v^{n}_{u,k}))), \tag{17}\]  
where \(\mathbf{T}^{u}_{pre}\) is the features of the timestamp, while \(\mathbf{W}_{pre}\) and \(\mathbf{b}_{pre}\) are learnable features, \(\mathbf{X}_{tar}\) is the embedding for the target part, and \(\mathbf{X}^{u}_{target,k}\) is the target embedding for user u's kth coarse trajectory embedding when trying to recover the real position at time \(t_{pre}\). \(FeatureFusion\) represents the feature fusion module's function. We use \(\mathbf{X}_{target}\) to represent this sort of feature. The formula for the ST-layer is as follows:  
\[\mathbf{X}_{raw}=\text{Projector}(\mathbf{X}_{fused}||\mathbf{X}_{target}), \tag{18}\]  
\[\mathbf{Z}_{st}=\text{LayerNorm}(\mathbf{X}_{raw}+\text{MultiHead}(\mathbf{X}_{raw})), \tag{19}\]  
\[\mathbf{X}_{st}=\text{LayerNorm}(\mathbf{Z}_{st}+\text{FeedForward}(\mathbf{X}_{raw})), \tag{20}\]  
where \(\mathbf{X}_{st}\) is the output of ST-layer, \(\mathbf{X}_{st}\) is the spatial-temporal features of all the trajectories. \(\mathbf{Z}_{st}\) is the hidden state.  
Figure 3: The structure of the feature fusion part; this part can be used for any two related features. The right figure is the MLP structure we are using in this work.  
Then, we use the trajectory recovery Layer to obtain the recovered point. Supposing the output of the ST-layer for user \(u\) for recovering the location at time \(t\) is represented as \(\mathbf{X}_{st,u}^{t}=(\mathbf{x}_{st,u}^{t})|i\leq k\), the formulation of this layer is as follows:  
\[(x_{u,lat}^{t},y_{u,long}^{t})=\mathbf{W}_{4}(x_{st,u}^{t_{0}}||\mathbf{x}_{st,u}^{t_{1 }}||\dots\mathbf{x}_{st,u}^{t_{k}}+\mathbf{b}_{4}), \tag{21}\]  
where \(\mathbf{x}_{st,u}^{t_{i}}\) is the representation of time step i. \(\mathbf{W}_{4}\) and \(\mathbf{b}_{4}\) are all trainable parameters.