## 5 Timetable Calculation and Adjustment
### The Matching Method
#### 5.2.2. Matching and Adjusting Method
** Mutation operation. The mutation operation is to exchange two adjacent matching relationships. The probability of the mutation operation is 0.1. The schematic diagram of crossover operation and mutation operation is shown in Figure 13.  
As shown in Figure 13, the schemes of the primary train-set circulation plan are the outer frame. For example, the square numbered 1 represents the first scheme in the primary train-set circulation plan. Moreover, scheme A in the square numbered 1 means that scheme A in the stop plan is matched with the first scheme in the primary train-set circulation plan. Then we perform crossover and mutation operations. Firstly, we divided the matching relationship according to the pre divided time period. All of the operations mentioned above are performed within the time period that the matching relationship belongs. Secondly, we cross over these matching relationships like Figure 13 shows, the latter segment of the second solution is exchanged with the former segment of the first solution, and then the former segment of the first solution is exchanged with the latter segment of the second solution. After the cross over operation, we will judge whether each matching relationship will mutate, and if so, exchange it and its subsequent matching relationship. **Step 5. ** Calculate the timetable for new generation by CPLEX according to the safety operation constraints in real life. **Step 6. ** Evaluate all the solutions. We evaluate those solutions by counting the satisfaction of passenger travel demands within the specified time period and the number of trains exceeding the end of the operation. It should be noted that before comparing those solutions, we need to normalize the satisfaction of passenger travel demands and the number of trains. We use the classical normalization method to divide the current value by the maximum value of this parameter in all solutions Then we choose solutions that have better fitness from all the solutions. **Step 7. ** If the number of iterations reaches the upper limit, or the best solution meets all the demands, end the algorithm, otherwise go back to step 3. After calculating the timetable, it is necessary to check whether all train-sets are within the operating hours. Train-sets that are not within the operating hours need to be adjusted. The adjustment steps are as follows:  
**Step 1. ** First, we counted the positions of the train-sets beyond the operating hours when they ended operation. **Step 2. ** Second, we count the positions of these train-sets at the end of their operating time. It is important to note that train-sets need to be stopped at boundary stations. If the train-set is between two boundary stations at the end of the operating time, we terminate the train-set at the first boundary station it passed. **Step 3. ** After step 2, the train-set position may not meet the position constraints. We need to rebalance these train-sets. Because the total number of train-sets is fixed, a lack of train-sets at some stations means that there are more train-sets than needed at some other  
Figure 13: The schematic diagram of crossover and mutation. stations. For the extra train-sets in stations where there are more train-sets than needed, we terminate it at the station where train-sets are still needed. The schematic diagram of each step is shown in Figure 14.  
As shown in Figure 14, we can see that three train-sets are out of operation hours. One of these train-sets ends at station A, one at station E, and one at station G. At the end of the operation time, train-set 1 is closest to station C, train-set 2 is closest to station E, and train-set 3 is closest to station E. Thus, after the execution of step 2, We can see that among all the adjusted train-sets, the number of train-set stopped at station A changed from 1 to 0, in station C the number changed from 0 to 1, in station E the number changed from 1 to 2, and in station G the number changed from 1 to 0.