# Dynamic Graph Representation Learning for Passenger Behavior Prediction
## 4 Methodology
### Parameter Optimization Algorithm  
In our approach, the model training process begins with the construction of a neighbor sampler. For each training iteration, we first set a random seed to randomize the parameters and then load the model and start training. For each batch, we first calculate the most recent first-order neighbors for all passengers and stations in the batch. Next, we pad the extended first-order interaction sequences to generate historical interaction sequences of the same length. We then calculate the correlation of the sequences and use an MLP to capture the temporal characteristics between the sequences. Finally, we estimate the probability of creating new links between passengers and stations and update the parameters using the gradient descent method. The complete algorithm workflow is outlined in Algorithm 1. ```
Input :Collection of passenger \(\mathcal{U}\) and collection of stations \(\mathcal{S}\), a sequence of historical interaction events \(\mathcal{G}^{t}=\{c_{1},\ldots,c_{k}\}\) with \(0\leq t_{1}\leq\ldots\leq t_{k}\leq t\), maximum number of training epochs \(MaxEpoch\); Output : The model parameters \(\Theta\) after training;
1 Initialize the parameters in DyGPP with random weights \(\Theta\) and set \(Epochs\gets 1\);
2 whilenot converged and \(Epochs\leq MaxEpoch\)do
3 forebatch\(B_{b}\in\mathcal{B}\)do
4\(\mathcal{N}_{u_{i}}^{t}\leftarrow\) Sample latest one-hop neighbors of \(u_{i}^{t}\in\mathcal{U}\);
5\(\mathcal{N}_{s_{i}}^{t}\leftarrow\) Sample latest one-hop neighbors of \(s_{i}^{t}\in\mathcal{S}\);
6\(\mathcal{S}_{u,i}^{t}\leftarrow\) Create the interactions of passengers' neighbor set \(\mathcal{N}_{u_{i}}^{t}\);
7\(\mathcal{Q}_{s_{i}}^{t}\leftarrow\) Create the interactions of stations' neighbor set \(\mathcal{U}_{s_{i}}^{t}\);
8\(\mathcal{Q}_{u_{i},pad}^{t}\), \(\mathcal{Q}_{s,j,pad}^{t}\leftarrow\) Pad sequences to a regular size;
9\(\mathbf{x}_{u_{i},Co},\mathbf{x}_{s_{i},Co}^{t}\leftarrow\) Calculate correlations between \(\mathcal{Q}_{u_{i},pad}^{t}\) and \(\mathcal{Q}_{s,j,pad}^{t}\);
10\(\mathbf{x}_{s_{i},N}^{t}\mathbf{x}_{s_{i},E}^{t}\mathbf{x}_{s_{i},T}^{t}\leftarrow\) Get raw feature embedding from the origin input;
11\(\mathbf{X}_{s_{i}}^{t}\leftarrow\) Generate co-occurrence feature through projection layer;
12\(\mathbf{Z}_{s,j}^{t}\leftarrow\) Encode passenger embedding and station embedding via MLP network;
13\(\hat{p}_{u,s}^{t}\leftarrow\) Compute the probabilities by fusing sequence embedding \(\mathbf{Z}_{u,i}^{t},\mathbf{Z}_{s,j}^{t}\) Optimize the model parameters \(\theta\) by back propagation;
14\(Epochs\gets Epochs+1\);
```  
**Algorithm 1**Training process of DyGPP  
Batch partitioning is an important method to enhance the parallel training capability of a model and shorten the training time. It should be noted that our approach to batch partitioning differs from commonly used methods. Traditional methods usually determine the batch size based on the number of nodes in each batch, which often works well for time-insensitive data. In our model, the interactions between passengers and stations are strongly time-correlated. Factors such as commuting times and daily traffic flow cycles cause interactions to often concentrate during specific hours of the day. To ensure that the time intervals between data points in each batch are consistent, we adopted a method of partitioning batches based on time intervals. Formally, given a dynamic graph \(\mathcal{G}^{t}\), batches can be partitioned as \(\mathcal{G}^{t}=\{\mathcal{B}_{1},\ldots,\mathcal{B}_{n}\}\), \(\mathcal{B}_{i}=\{(u_{i,1},s_{i,1},l_{i,1},t_{i,1}),\ldots,(u_{i,k},s_{i,k},l_{ i,k},t_{i,k})\mid t_{i,1}\leq\ldots\leq t_{i,k},t_{i,k}-t_{i,1}\leq\delta t\}\), where \(\delta t\) is a hyperparameter partitioned to represent the maximum time interval of interactions within a batch. This means that the length of each batch may vary.