## 3 Mathematical Modeling
### Train Traffic Dynamic Model
\[A_{i}^{s}+A_{i+1}^{s}+A_{i+2}^{s}\geq 2,\forall i\in I\backslash\Big{\{}N^{up} -1,N^{up},N^{down}-1,N^{down}\Big{\}},s\in S \tag{8}\]In Figure 4, the time constraints are more clearly reflected. Considering an example involving three trains across four stations, train \(i\)-1 skips station 3, train \(i\) chooses to stop at all stations, and train \(i+1\) skips station 2. Since the safe operation of trains is very important, the departure time of train \(i\) at station 3 and the arrival time of train \(i+1\) at station 3 should satisfy the \"departure-arrival\" time constraint \(I_{da}\), i.e., the first constraint in Equation (10). The departure time of train \(i\) at station 2 and the arrival time of train \(i+1\) at station 2 should satisfy the \"departure-passing\" time constraint \(I_{dt}\), i.e., the third constraint in Equation (10). The arrival time of train \(i\) at station 3 and the departure time of train \(i-1\) at station 3 should satisfy the \"passing-arrival\" time constraint \(I_{la}\), i.e., the second constraint in Equation (10). \[ \begin{cases}t_{i,s}^{a}-t_{i-1,s}^{d}\geq I_{da},&if\ A_{i}^{s}\cdot A_{i-1}^{ s}=1\\ t_{i,s}^{a}-t_{i-1,s}^{d}\geq I_{la},&if\ A_{i}^{s}=1,A_{i-1}^{s}=0\,\forall i \in I\backslash\{1\},\forall s\in S\\ t_{i,s}^{a}-t_{i-1,s}^{d}\geq I_{dt},&if\ A_{i}^{s}=0,A_{i-1}^{s}=1\end{cases}  \tag{10}\]  
The rolling stock operation constraints are mainly reflected in the train connection relationship and the turnaround operation time. A train can be connected to no more than one other train during its operational cycle:  
\[\left\{ \begin{array}{l}0\leq\sum\limits_{j\in l^{down}}\alpha_{i}^{j}\leq 1,\forall i\in I^{up}\\ 0\leq\sum\limits_{i\in I^{up}}\alpha_{i}^{j}\leq 1,\forall j\in I^{down}\\ 0\leq\sum\limits_{i\in I^{up}}\beta_{j}^{i}\leq 1,\forall j\in I^{down}\\ 0\leq\sum\limits_{j\in l^{down}}\beta_{j}^{i}\leq 1,\forall i\in I^{up} \end{array} \right. \tag{11}\]  
where \(\alpha_{i}^{j}\), \(\beta_{j}^{i}\) are binary variables. If the train \(i\) in the upstream direction produces a rolling stock connection with the train \(j\) in the downstream direction, the \(\alpha_{i}^{j}\) is taken as 1, otherwise the \(\alpha_{i}^{j}\) is taken as 0. If the train \(j\) in the downstream direction produces a rolling stock connection with the train \(i\) in the upstream direction, the \(\beta_{j}^{i}\) is taken as 1, otherwise the \(\beta_{j}^{i}\) is taken as 0. \(I^{up}=\{1,2,\ldots,N^{up}\}\) is the set of train serial numbers in the upstream direction. \(I^{down}=\left\{1,2,\ldots,N^{down}\right\}\) is the set of train serial numbers in the downstream direction. Figure 4: Description of train running status. Two trains can be connected only if the connecting time between trains meets the minimum turnback time \(b_{\min}\) requirement:  
\[ \begin{cases}\alpha_{i}^{j}-(1-\alpha_{i}^{j})M\leq\frac{t_{i,1}^{d_{i}-t_{i,1}^{ d_{i}}}}{b_{\min}},\forall i\in I^{up},\forall j\in I^{down}\\ \beta_{i}^{j}-(1-\beta_{i}^{j})M\leq\frac{t_{i,n}^{d_{i}-t_{i,n}^{d_{i}}}}{b_{ \min}},\forall j\in I^{down},\forall i\in I^{up}\end{cases}  \tag{12}\]  
where \(M\) is a positive maximum value. The rolling stock connection affects the number of times rolling stock exits and enters the depot. The fewer times, the lower the operator's operating costs. \[\left\{ \begin{array}{l}\eta_{i}=\sum\limits_{j\in I^{down}}\alpha_{i}^{j}, \forall i\in I^{up}\\ \gamma_{j}=\sum\limits_{i\in I^{up}}\alpha_{i}^{j},\forall j\in I^{down}\\ \eta_{j}=\sum\limits_{i\in I^{up}}\beta_{j}^{i},\forall j\in I^{down}\\ \gamma_{i}=\sum\limits_{j\in I^{down}}\beta_{j}^{i},\forall i\in I^{up}\end{array} \right. \tag{13}\]  
where \(\eta_{i},\eta_{j},\gamma_{i},\gamma_{j}\) are binary variables. If the rolling stock of the train \(i\) and \(j\) does not enter the depot, \(\eta_{i}\) and \(\eta_{j}\) are 1, otherwise \(\eta_{i}\) and \(\eta_{j}\) are 0. If the rolling stock of trains \(i\) and \(j\) does not come from the depot, \(\gamma_{i}\) and \(\gamma_{j}\) are 1, otherwise \(\gamma_{i}\) and \(\gamma_{j}\) are 0.