## 3 Mathematical Model and Solution Algorithm
### Model Solving Algorithm Design
#### 3.3.2 Algorithm Steps
The simulation step is determined by the shortest time between passenger arrival and train arrival. Time variables and parameters are updated gradually. When the simulation time equals the length of the research period, the process halts, and each parameter is outputted. A train dynamic simulation primarily consists of three stages: departure from the first station, arrival at intermediate stations, and reaching the terminal station with the option to turn back or enter the depot. Passenger dynamic simulation comprises three processes: passenger arrival at the station, passenger alighting from the train, and passenger boarding the train. Through the above steps, the waiting time for all passengers, train mileage, and the count of rolling stocks are determined. Each metric is then multiplied by its corresponding unit cost input, culminating in the model's objective function through weighted summation. Figure 2: Schematic Diagram of Chromosome Coding. Subsequently, the objective function value serves as the fitness function value, enabling the assessment of individual quality within the population. (5) Genetic manipulation  
(1) Selection  
Selection is conducted utilizing the roulette operator, with this study opting for the minimum cost as the objective function. Consequently, the reciprocal of the fitness function  
Figure 3: Simulation Flowchart of Passenger Flow Distribution. value is denoted as \(f(x_{i})\), and the probability, along with the cumulative probability, of each chromosome's selection is computed. The calculation formula is as follows:  
\[p(x_{i})=\frac{f(x_{i})}{\sum_{j=1}^{pop,size}f(x_{i})} \tag{50}\]  
\[q(x_{i})=\sum_{j=1}^{i}p(x_{i}) \tag{51}\]  
A random number, denoted as \(r\), is generated within the interval \((0,1)\). If \(r<q(x_{i})\), chromosome \(x_{i}\) is selected; otherwise, it is eliminated. (2) Crossover  
Using the method of two-point crossover and random numbers, the crossover probability is \(p_{c}\). Initially, we identify the crossover point's location of the gene fragment, specifically regarding the train departure. Subsequently, we intercept it at the corresponding position denoting the train type and departure time, ensuring equivalence in chromosome lengths across the three segments. Figure 4 illustrates the crossover process of up-train gene segments. (3) Mutation  
Utilizing the designated mutation probability, denoted as \(p_{m}\), specific genes on the chromosomes within the population undergo random selection for mutation. The mutation process, illustrated in Figure 5, focuses on the departure time at the first station, with a variation range of \([-90,\,90]\). Post-mutation, chromosome modifications adhere to model constraints, ensuring compliance with departure interval constraints for adjacent trains. (6) Simulated annealing operation  
After the genetic algorithm generates new individuals, a local search optimization proceeds via the simulated annealing algorithm. Randomly select a chromosome in the offspring population to generate its neighborhood solution \(x_{i+1}\). The algorithm then assesses whether the new individual satisfies constraint conditions, computes its fitness function value if applicable, and applies the Metropolis criterion to decide on acceptance. Subsequently, the corresponding fitness function value increment, denoted as  
Figure 4: Crossover Operation. Figure 5: Mutation Operation. \(\Delta f=f(x_{i+1})-f(x_{i})\), is calculated. If \(\Delta f<0\), then \(x_{i}=x_{i+1}\); if \(\Delta f\geq 0\), a random number between 0 and 1 is generated. Acceptance of \(x_{i}\) as the new solution occurs when \(\exp\Delta f/T>\text{random}(0,1)\), signaling completion of an annealing cycle. Iteration termination is determined by evaluating whether the current temperature falls below \(t_{min}\). If so, the loop concludes; otherwise, annealing operations persist. The provided steps outline a single iteration cycle within the algorithm design of this study.