## 3 Mathematical Model
### Constraints related to train operation
Similar to the constraints of new passenger volume, we obtain:  
\[v^{r}_{i,j}=v^{r}_{i-1,j}+v^{add}_{i,j}-L^{n}_{i,j},\,i,i-1\in\mathbf{N}^{A}, \,j\in\mathbf{S}^{A}\backslash\mathbf{S}^{A}_{l}. \tag{41}\]  
At the same time, if \(z^{a}_{l,i-1}=0\), for \(i,i-1\in\mathbf{N}^{A}\), \(j\in\mathbf{S}^{A}_{l}\), we obtain:  
\[v^{r}_{i,j}=v^{r}_{i-1,j}+v^{add}_{i,j}-L^{n}_{i,j}. \tag{42}\]  
And for \(j\in\mathbf{S}^{A}_{l}\), if \(z^{a}_{l,i-1}=1\), then we obtain:  
\[v^{r}_{i,j}=v^{r}_{l,j}+v^{add}_{i,j}-L^{n}_{i,j}. \tag{43}\]  
For the cross-line backup train \(l\), the number of stranded passengers \(v^{r}_{i,j}\) when it leaves station \(j\) is also the number of stranded passengers when the previous train leaves the station, plus the number of passengers arriving within the time interval between it and the previous train leaving the station, minus the number of passengers boarding train \(l\) at the station. Thus, for \(i-1\in\mathbf{N}^{A}\), \(j\in\mathbf{S}^{A}_{l}\), if \(z^{a}_{l,i-1}=1\), we obtain:  
\[v^{r}_{l,j}=v^{r}_{i-1,j}+v^{add}_{l,j}-L^{n}_{l,j}. \tag{44}\]  
Figure 5: Time labeling for calculating passenger flow. In terms of the number of alighting passengers, for different trains at station \(j\), the OD (i.e., original and destination) distribution probability matrix \(\mathbf{P}\) is first defined. \[\mathbf{P}= \begin{bmatrix}0&p_{1,2}&p_{1,3}&\cdots&p_{1,|\mathbf{S}|-1}&p_{1,| \mathbf{S}|}\\ 0&0&p_{2,3}&\cdots&p_{2,|\mathbf{S}|-1}&p_{2,|\mathbf{S}|}\\ 0&0&0&\cdots&p_{3,|\mathbf{S}|-1}&p_{3,|\mathbf{S}|}\\ \vdots&\vdots&\vdots&\ldots&\vdots&\vdots\\ 0&0&0&\cdots&0&p_{|\mathbf{S}|-1,|\mathbf{S}|}\\ 0&0&0&\cdots&0&0\end{bmatrix} . \tag{45}\]  
Furthermore, according to the OD distribution probability matrix, the number of alighting passengers from train \(i\) at station \(j\) is  
\[L_{i,j}^{f}=\sum_{k=1}^{j}\left(p_{k,j}\times L_{i,k}^{n}\right),\,i\in \mathbf{N}^{A},\,j\in\mathbf{S}^{A}. \tag{46}\]  
For the backup train, considering that some passengers do not travel to Line B, the number of alighting passengers at station \(j\) is  
\[L_{i,j}^{f}=\left\{ \begin{array}{ll}\sum_{k=\min(\mathbf{S}_{i}^{A})}^{j} \left(p_{k,j}\times L_{i,k}^{n}\right),\qquad j\in\mathbf{S}_{l}^{A}\backslash \left\{\max\left(\mathbf{S}_{l}^{A}\right)\right\}\\ \sum_{j^{\prime}=\max(\mathbf{S}_{i}^{A})}^{|\mathbf{S}^{A}|}\sum_{k=\min( \mathbf{S}_{i}^{A})}^{j}\left(p_{k,j^{\prime}}\times L_{i,k}^{n}\right),\qquad j =\max\left(\mathbf{S}_{l}^{A}\right)\end{array} \right.. \tag{47}\]  
In terms of the number of passengers in train \(i\), when it arrives at the first station, the number of passengers in the train is 0. When it arrives at other stations, the number of passengers in the train is the number of passengers in the train when it arrives at the previous station plus the number of passengers getting on at the previous station, and minus the number of passengers getting off at the previous station. Then, for \(i\in\mathbf{N}^{A}\), we obtain:  
\[L_{i,j}^{c}= \begin{cases}0&j=1\\ L_{i,j-1}^{c}+L_{i,j-1}^{n}-L_{i,j-1}^{f}&j\in\mathbf{S}_{i}^{A}\backslash\left\{ 1\right\}.\end{cases}  \tag{48}\]  
Similarly, for the backup train, the corresponding constraint is:  
\[L_{i,j}^{c}= \begin{cases}0&j=\min(\mathbf{S}_{l}^{A})\\ L_{i,j-1}^{c}+L_{i,j-1}^{n}-L_{i,j-1}^{f}&j\in\mathbf{S}_{i}^{A}\backslash \left\{\min(\mathbf{S}_{l}^{A})\right\}.\end{cases}  \tag{49}\]  
The number of passengers boarding train \(i\) at station \(j\) needs to be explored based on different situations. When the current demand is low and the remaining capacity is sufficient, the demand can all enter the train. The demand includes the number of stranded passengers from the previous train and the new demand.