3.1.1. Construction of Dynamic Time–Space Service Network
A transportation service network is designed to determine the transportation service set with the minimum cost or maximum profit under existing transportation resources and limited conditions, and at the same time to meet the transportation requirements of customers [
20]. For station-to-station RLPT, the transport process between two points can be regarded as a kind of transportation service provided by cars. When we abstract this kind of service into an arc, we can use the dynamic service network to study the optimization of RLPTS. The dynamic time–space service network can flexibly represent the varying transport time and accurately reflect the time–space correlation.
This paper refers to the RLPT service network in the literature [
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49]. As shown in 
Figure 1, for the vertical axis, 
 to 
 are RLPT handling stations. The horizontal axis represents time. The nodes in each row represent the same station at different times, and the nodes in each column represent different stations at the same time. When a car provides RLPT services, a series of arcs will be generated on the network. 
Figure 1 is a simple RLPT service network with two trains. The solid line is a train running arc (TRA), which represents the operation of passenger trains between RLPT handling stations. There are two types of horizontal dotted lines connected with nodes of the same RLPT handling station. The dotted line connecting the same trains from head to tail is a delayed arc (DA), which means that packages stay at the station waiting to be delivered. The dotted line connecting different trains from head to tail is a transit arc (TA), which means that packages are transferred from one train to another at the station. The main field definitions and data types of time– space nodes and arcs in the whole algorithm are shown in 
Table 2 and 
Table 3, and their ID indices start from 0. The indices of different time–space arcs are shown in 
Table 4.
Unlike the station-to-station transport process, when the two parts of door-to-station and station-to-door are included in the research scope, the constraints of transportation organization time and connection time need to be considered. When goods arrive at the sending or terminal station, the loading and unloading should be organized uniformly for a certain period of time, and the train’s stopping time should meet the loading and unloading operation time requirements of the goods. As shown in 
Figure 1, two trains can reach station 
 close to destination 
, but train 2’s departure time is too early, so the goods can only be sent to station 
 at first, and then transported by train 1. In the process of transportation, the goods can be transferred to train 2 and transported to destination 
 within time periods 
 to 
. Through a combination of a series of service arcs in the network, the process of RLPT is described, which can not only simulate the complex time constraints in the process of RLPT and properly calculate the K shortest path of OD, but also ensure timeliness in the process of transportation.
  3.1.3. Preprocessing of Dynamic Time–Space Service Network before Path Search
In the dynamic service network, there are many feasible paths between the start node and the end node of RLPT demand. The problem of the RLPT path is the problem of searching multiple feasible paths with greater timeliness and satisfying existing restrictions on the dynamic service network, which is essentially the K shortest path problem in the shortest paths. The dynamic time–space service network constructed by the method described in 
Section 3.1.1 has multiple start and end nodes. However, in graph theory, the path search can only be carried out in a graph with unique start and end nodes. If we search directly on the dynamic service network, we need to consider combinations of different start and end nodes, which will increase the complexity of the search process. A comparison between the initially constructed and processed dynamic time–space networks is shown in 
Figure 2. 
Figure 2a contains 11 network nodes, where 
 and 
 represent stations 
 and 
, respectively, at different times. When calculating the path of freight flow from station 
 to station 
, considering the time attributes of stations, there will be three start nodes and three end nodes in the network. The existing path search algorithms are not applicable to this network. As shown in 
Figure 2b, this problem can be solved by creating a virtual start arc (VSA) and virtual end arc (VEA) at both ends, with a unique virtual start node (VSN) and virtual end node (VEN). The dotted lines are virtual arcs at both ends, so that the whole network is a closed network with unique VSN and VEN. The specific operation methods are as follows: In the initial network, VSN 
 and VEN 
 with unique attribute identification are created. Since it is impossible to obtain the time when goods are delivered to the sending station, the time attribute of both can be set to 0. The attribute values of VSN and VSN are shown in 
Table 5. We need to screen the network nodes that correspond to the sending station and consider the TRA that is passing through the particular station. If the train departure time corresponding to the node is later than the arrival time of the goods and the stop time of the train meets the loading operation time of the goods, then the node is connected with VSN 
 to form a VSA. Similarly, the VEA connected with VEN 
 can be constructed. The properties of virtual arcs at both ends are shown in 
Table 6. In path search, starting from 
 and ending from 
, we can search feasible paths for demand in dynamic time–space service networks with only start and end nodes. We set the arc weight of both virtual arcs to 0.
  3.1.4. Feasible Path Set Generation Based on Improved A* Algorithm
According to the structure of the dynamic time–space service network and the specific requirements of RLPT organizations, we can solve the K shortest path problem of RLPT by improving the A* algorithm. The existing K shortest path solving methods include double-sweep, A* algorithm, and deviation path algorithm [
50,
51]. The double-sweep algorithm has advantages in solving the path. However, obtaining path data requires reverse search, which is complex and difficult to understand [
52]. In addition, compared with the double-sweep algorithm, the A* algorithm is easier to operate and has higher solution efficiency [
53,
54,
55]. Therefore, the A* algorithm is used to solve the K shortest path in this study. The evaluation function of the A* algorithm is 
, where 
 is the actual cost from the initial node to the network node 
 in the state space, and 
 is the estimated cost of the optimal path from network node 
 to target node. The values of 
 and 
 will change with the change of A* algorithm execution time, but the shortest distance between two nodes is fixed and invariant, reflecting the property of local symmetry. The flowchart of the path search algorithm is shown in 
Figure 3, and the specific solving steps are as follows:
Step 1: Obtain basic dictionaries, such as passenger train schedule, station information, train information, demand set , etc. Determine the basic parameters, such as minimum loading and unloading operation time and minimum transit operation time of each RLPT handling station, and maximum transit number of paths. According to the basic dictionary and basic parameters, construct the dynamic time–space service network of RLPT.
Step 2: Traverse OD demand set , and define a single OD demand as (); one path to  is , and the set of K shortest paths of  is ().
Step 3: Determine whether the element in set  has completed traversal. If the set traversal is complete, go to Step 13. Otherwise, according to the origin and destination information of demand , create VSN  and VEN , then construct the virtual arcs at both ends based on the loading and unloading operation time requirements of each station and demand information to complete the network preprocessing of path search of demand .
Step 4: Reverse arcs in service networks, take  as the source node, use the Dijkstra algorithm to solve the shortest distance from  to all nodes, that is, to find the  value of all nodes.
Step 5: Judge whether or not the  value of  exists. If it does not exist, go to Step 2. Otherwise, go to Step 6.
Step 6: Create new minimum binary heap set Open (nodes in Open set are sorted by  value), insert  into the Open set. The node in Open is the node through which the shortest path may pass.
Step 7: Determine whether the Open set is empty or the  value of the team head node of the Open set does not exist. If yes, output the feasible path set  of demand , go to Step 2. Otherwise, go to Step 8.
Step 8: Delete the node with the smallest  value in the Open set and mark it . Determine if  is . If yes, find a path  of demand , return to the path, and go to Step 9. Otherwise, judge whether set  of nodes connected with node  by arc is empty. If yes, go to Step 7; otherwise, go to Step 12.
Step 9: Determine if  exceeds the limitation of maximum transfer times. If yes, abandon  and go to Step 7; otherwise, go to Step 10.
Step 10: Judge whether  exceeds the limitation of timeliness. If yes, abandon  and go to Step 7; otherwise, go to Step 11.
Step 11: Determine whether the number of  deleted in the set Open exceeds the maximum number of paths. If yes, output the feasible path set  of demand , and go to Step 2. Otherwise,  and go to Step 7.
Step 12: Traverse node  in set  and define  as the parent node of node . If there is no node  in the Open set, calculate the  value of  and insert it into the Open set. If node  exists in the Open set and copy node  is , calculate the  value of  and insert it into the Open set. Go to Step 7.
Step 13: When the traversal of demand set  is completed, feasible paths of all demands have been found and the algorithm ends.
Through the path search algorithm mentioned above, the path set of all demands can be generated. Our proposed RLPTS formulation model is based on the feasible path set of demand, avoiding the allocation of goods flow on the infeasible path. The model aims to maximize the revenue of transportation enterprises and concentrates on the situation where the transportation demand cannot be satisfied due to the limited path capacity and insufficient luggage vehicle capacity. By solving the model, the flow allocated on each path can be obtained.