Path planning method based on graph structure cache
By constructing a path planning method based on graph-structured caching, a data cache index and relationship graph with a specific structure are pre-built to quickly select the optimal path. This solves the problem of low computational efficiency in existing technologies, improves the efficiency of path planning and the system's concurrency capabilities, and reduces hardware resource costs.
Patent Information
- Application Number
- CN202511254049.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-04
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-09-04
AI Technical Summary
Existing path planning algorithms are computationally inefficient when processing large-scale data, leading to system response delays. They are particularly ineffective in modern logistics platforms with large data volumes and high concurrency. Furthermore, existing methods fail to fully utilize the unique information advantages of the original data structure.
By constructing a path planning method based on graph structure caching, a data cache index and relationship graph with a specific structure are pre-built, and a path table is generated using a breadth-first traversal algorithm to quickly select the optimal path, avoiding the need to split the line data into a network structure and reducing data complexity.
It significantly improves the computational efficiency of path planning and the system's concurrent capacity, reduces hardware resource costs, and adapts to the system requirements of large-scale data and high concurrency requests.
Smart Images

Figure CN120740632B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of transportation technology, and in particular to a path planning method based on graph structure caching. Background Technology
[0002] Route planning is a crucial research topic in the transportation field and a fundamental support for multimodal transport systems and platforms. Route planning technology is widely applied in logistics distribution, robot navigation, and drone control and flight. Traditional algorithms primarily rely on deterministic methods such as genetic algorithms, Dijkstra's algorithm, and Floyd algorithm to achieve basic functionality by calculating the shortest path between two points. With technological advancements, existing solutions are beginning to incorporate real-time traffic data to enhance dynamic response capabilities. In specific scenarios, technical solutions have evolved from single-path optimization to complex systems integrating perception and intelligent decision-making.
[0003] While existing technologies are generally applicable in most scenarios, they may suffer from high time complexity and insufficient computational efficiency when processing large-scale data, leading to system response delays. This is particularly unsuitable for the demands of modern logistics platforms with large data volumes and high concurrency. In certain special scenarios, it is necessary to transform specific data structures into mesh structures required by classic algorithms such as Dijkstra's algorithm. This not only fails to leverage the unique information advantages of the original data structure but also exacerbates the computational load after data transformation, resulting in overall system inefficiency. Summary of the Invention
[0004] To address the aforementioned technical problems, in scenarios involving large-scale data and unique original data structures, low computational efficiency makes it difficult to handle the demands of high-concurrency systems. This invention proposes a path planning method based on pre-built, structured cached data for path networks composed of numerous multi-node long-distance connections. This method leverages the inherent advantages of the original data, reduces the time complexity of the path planning system, improves the system's concurrency capacity and overall operating efficiency, thereby reducing the cost of hardware resources required for system operation. This invention provides a path planning method and system based on graph structure caching.
[0005] Path planning methods based on graph structure caching include
[0006] Step 1, Data Cache Construction:
[0007] Step 101: Prepare basic route data, including route name, starting station, stations along the route, ending station, basic station information, and distances between stations; represent a single data point in tuple form, a route consists of multiple data points arranged in sequence, and the data of all routes are aggregated to form the entire dataset S;
[0008] Step 102: Traverse the dataset S and create secondary indexes S1 and S2 for transit stations and all stations respectively; and create indexes S3 and S4 with the route name as the key and the list of transit stations on the route and the list of all stations as the value respectively.
[0009] Step 103: Traverse index S1. For each station s, retrieve its corresponding line list m. Generate combination C(m,2) based on list m. Traverse each pair of elements (a,b) in combination C. Establish a second-level index S5 with a as the first-level key, b as the second-level key, and the intersection of S3[a] and S3[b] as the value. Then, convert S5 into an unweighted undirected graph G with line objects as nodes and the transfer relationship between lines as edges.
[0010] Step 104: Traverse the routes in S4. During the traversal, take the current route as the root node entry and use the breadth-first traversal algorithm to traverse graph G. During the traversal of graph G, generate a table of possible paths to all other routes and finally generate dataset S6.
[0011] Step 2, Path Planning:
[0012] Step 201: When performing path planning, first determine whether the starting point a and the ending point b are collinear based on the cached data. If they are, select the solution with the shortest path distance among the collinear cases and return it; otherwise, proceed to step 202.
[0013] Step 202: Take out the sets S2[a] and S2[b] of routes passing through the starting point a and the ending point b respectively from S2. Take one element from S2[a] and S2[b] respectively and combine them in pairs, denoted as (α,β). Then α and β represent a route passing through the starting point a and the ending point b respectively. Take out the path list S6[α][β] of route α to route β from S6 and set the parameters κ and λ, where κ represents the topκ constraint and λ represents the maximum number of transfers constraint. Select the schemes from S6[α][β] according to the parameters κ and λ to form a set, denoted as P. Then P⊆S6[α][β]. Traverse P, calculate the path distance of each scheme, and select the scheme with the shortest path distance to return.
[0014] Step 203: Compare the path distance calculation results of each scheme in P, and select the scheme with the shortest path distance as the optimal scheme from the starting point a to the ending point b.
[0015] Furthermore, the conversion of S5 into an undirected graph G specifically involves: using the first-level index key of S5 as a node and the corresponding second-level index key list as the neighbor nodes of that node, converting S5 into an unweighted undirected graph G=(V,E) with line objects as nodes and the transition relationships between lines as edges. V represents the set of all nodes, the number of nodes being the number of lines n in S, and E represents the set of all edges, with the number of edges c represented as follows:
[0016] ,
[0017] Among them, V i Let || represent the i-th node, and || represent the number of elements in the set.
[0018] Furthermore, the dataset S6 has a two-level index structure, with both the outer and inner layers having a 1:m relationship.
[0019] Furthermore, the value of the inner index represents all possible transit routes from the outer key to the inner key, arranged in ascending order of transit count. An empty list [] indicates that the transit count is 0, meaning that the two routes intersect and can be directly transited.
[0020] Furthermore, the process of determining whether the starting point a and the ending point b are collinear is as follows: determine the number of elements in the union of S2[a] and S2[b]. If S2[a] & S2[b] ≠ ∅, it indicates that the two points are collinear.
[0021] Furthermore, index S1 is a secondary index with the station name as the primary key, the line name that can be converted through the station as the secondary key, and the line object as the value; index S2 is a secondary index with the station name as the key, the line name that passes through the station as the secondary key, and the line object as the value.
[0022] Furthermore, the structure of index S5 is: {line A: {line B: S3[a]&S3[b], line C: S3[a]&S3[c], ...}, ...}, where S3[a], S3[b] and S3[c] represent the values with key names a, b and c taken from index S3, respectively, and the symbol & represents the union of two sets.
[0023] Furthermore, the process of calculating the path distance for each scheme in step 202 is as follows:
[0024] Let q be a sequence composed of route α, all transfer routes in the proposed scheme, and route β, with length denoted as n. Then, sequentially take the set of transfer points for the preceding and following routes, denoted as ω. ;
[0025] Take the starting point a as the root node, the intermediate points in ω as branch nodes, construct a tree according to the order of the stations along the way, use the distance between the two stations as the weight from the node to the child node, and each branch node participates in the continuation process of the subsequent route, and finally form a tree, denoted as T. Then the path from the root node to each leaf node corresponds to an optional path.
[0026] The tree T is traversed using a preorder traversal algorithm. The total weight of the path from the root node to each leaf node is calculated and the corresponding path is recorded. The path with the smallest weight is selected and returned to obtain the shortest path of this route combination, which is used as the path distance of the solution.
[0027] The beneficial effects of this invention are as follows: By pre-constructing a relationship graph and a corresponding index structure as the data foundation for subsequent path planning, and by rationally retrieving the index and using the route relationship tree to quickly select the optimal path scheme, the computational efficiency of the path is improved. Compared with techniques such as genetic algorithms, Dijkstra's algorithm, and Floyd algorithm, this scheme can effectively leverage the advantages of the original data information in scenarios where a path network is composed of a large number of multi-node long-distance route intersections, avoiding the need to split the route data into a network structure and reducing data complexity. By constructing a data cache with a specific structure and corresponding cache call and scheme selection methods, the overall efficiency of path planning is significantly improved, making it more suitable for systems with large data scale and high concurrent request volume. By reducing computational consumption, hardware resource costs can be reduced. Attached Figure Description
[0028] Figure 1 This is a flowchart of the method of the present invention.
[0029] Figure 2 This is a pseudocode example diagram of the inner processing procedure.
[0030] Figure 3 This is a schematic diagram of the line transfer relationship in the embodiment.
[0031] Figure 4 This is a schematic diagram of the transfer path tree for the route. Detailed Implementation
[0032] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0033] Example 1: Refer to Figure 1 As shown, the path planning method based on graph structure caching in this embodiment of the invention includes a data cache construction step and a path planning step.
[0034] I. Data Cache Construction
[0035] (1) Prepare basic route data, including route name, starting station, stations along the route, ending station, basic station information and distance between stations; represent a single data in tuple form (route name, station name, whether it is a transfer station, distance value). A route is composed of multiple data arranged in order, and the data of all routes are aggregated to form the entire dataset S.
[0036] (2) Traverse the dataset S. For transit stations, establish a secondary index with the station name as the first-level key, the route name that can be converted through the station as the second-level key, and the route object as the value. This index is denoted as S1. The first-level index is a 1:m relationship, and the second-level index is a 1:1 relationship. The overall structure is as follows.
[0037] {
[0038] Site A: {
[0039] Line A: Line object A,
[0040] Line B: Line object B, ... }, ...
[0041] }
[0042] For all stations, create a second-level index, denoted as S2, with the station name as the key, the route name passing through the station as the second-level key, and the route object as the value. The structure is the same as S1. Create an index, denoted as S3, with the route name as the key and the list of transfer stations on the route as the value. Create an index, denoted as S4, with the route name as the key and the list of stations on the route as the value.
[0043] (3) Traverse index S1. For each station s, take out its corresponding route list m. Generate combination C(m,2) based on list m. In programming and mathematics, combination refers to all possible ways of selecting several elements from a set without considering the order. Combination C(m,2) means selecting 2 elements from list m.
[0044] Iterate through each pair of elements (a, b) in combination C, and establish a second-level index S5 with a as the first-level key, b as the second-level key, and the intersection of S3[a] and S3[b] as the value. The first-level index has a 1:m relationship, and the second-level index has a 1:1 relationship. The overall structure is as follows:
[0045] {
[0046] Line A: {
[0047] Line B: S3[A] & S3[B],
[0048] Line C: S3[A] & S3[C], ... }, ...
[0049] }
[0050] Here, S3[a] represents retrieving the value with key name a from index S3, and so on. The symbol & represents finding the union of two sets.
[0051] Using the first-level index key of S5 as the node and the corresponding second-level index key list as the neighbor node of the node, S5 can be transformed into an unweighted undirected graph G=(V,E) with line objects as nodes and the transition relationship between lines as edges. V represents the set of all nodes, the number of nodes is the number of lines n in S, and E represents the set of all edges, the number of edges c can be expressed as:
[0052] ,
[0053] Among them, V i Let || represent the i-th node, and || represent the number of elements in the set.
[0054] (4) Traverse the routes in S4, taking the current route as the root node entry point and using the breadth-first traversal algorithm to traverse graph G. During the traversal of graph G, generate a table of possible paths to all other routes. The final generated dataset is denoted as S6. This dataset has a two-level index structure, with both the outer and inner layers having a 1:m relationship. The overall structure is as follows:
[0055] {
[0056] Line A: {
[0057] Route B: [[], [Route C], ...],
[0058] Line C: [[], [Line B], [Line F, Line E], ...],
[0059] Line D: [[Line B], [Line C], [Line D, Line E], ...], ... }, ...
[0060] }
[0061] The inner index value represents all possible transit routes from the outer key to the inner key, arranged in ascending order of transit count. An empty list [] indicates a transit count of 0, meaning the two routes intersect and can be directly traversed. The pseudocode for the inner processing is as follows: Figure 2 As shown. The data cache is now complete.
[0062] II. Path Planning
[0063] (1) When performing path planning, first determine whether the starting point a and the ending point b are collinear based on the cached data. If they are, select the solution with the shortest path distance among the collinear cases and return it; if not, proceed with the subsequent steps.
[0064] Specifically, there are three cases of collinearity:
[0065] a) If there is only one element in the union set, denoted as δ, then the path between a and b in the list of stations corresponding to the line is directly retrieved and returned according to S4[δ]. The path distance is the absolute value of the difference between the attribute "distance value" of stations a and b on the line.
[0066] b) If the union contains multiple elements, it indicates that there are multiple collinear lines between a and b. Return the solution with the shortest path distance.
[0067] c) If the union is empty, then proceed with the subsequent steps.
[0068] (2) Take out the set of routes passing through the starting point a, S2[a], and the set of routes passing through the ending point b, S2[b] from S2. Take one element from S2[a] and S2[b] respectively and combine them in pairs, denoted as (α, β). Then α and β represent a route passing through the starting point a and the ending point b respectively. Take out the path list from route α to route β from S6, i.e., S6[α][β]. Since S6[α][β] stores all path schemes that pass through different transfer routes, and the schemes are arranged in ascending order of the number of transfers, the parameters κ and λ can be set (according to performance). As required by business needs, here we set κ=5, λ=3), where κ represents the topκ constraint. Since the number of transfers increases and the overall efficiency decreases as the solutions progress, we can only take the first κ for comparison and terminate the traversal in advance to reduce unnecessary performance consumption. λ represents the maximum number of transfers constraint. Based on the parameters κ and λ, we select solutions from S6[α][β] to form a set, denoted as P. Then P⊆S6[α][β]. We traverse P, calculate the path distance of each solution, and select the solution with the shortest path distance to return. The process of calculating the shortest path distance of a single solution is as follows.
[0069] A) Form a sequence q from route α, each transit route in the scheme, and route β, with length n. Sequentially take the transit point sets of the preceding and following routes (there may be multiple transit points for two routes), denoted as ω. ;
[0070] B) Taking the starting point a as the root node and the intermediate points in ω as branch nodes, the transfer relationship diagram is drawn according to the order of the stations along the way (e.g., Figure 3(As shown) Construct a tree, using the distance between two preceding and succeeding stations as the weight from one node to its child nodes. Each branch node participates in the continuation of subsequent routes, ultimately forming a tree denoted as T. The path from the root node to each leaf node corresponds to an optional path, as shown in the structure. Figure 4 As shown;
[0071] C) Use the preorder traversal algorithm to traverse tree T, calculate the total weight of the path from the root node to each leaf node, record the corresponding path, select the path with the smallest weight and return it, and obtain the shortest path of this route combination as the path distance of the scheme.
[0072] (3) Compare the path distance calculation results of each scheme in P, and select the scheme with the shortest path distance as the optimal scheme from the starting point a to the ending point b.
[0073] Compared to techniques such as genetic algorithms, Dijkstra's algorithm, and Floyd's algorithm, this technical solution has the advantage of effectively leveraging the original data information in scenarios where a path network consists of numerous long, multi-node connections. It avoids splitting the line data into a network structure, reducing data complexity. By constructing a data cache with a specific structure and corresponding cache invocation and scheme selection methods, it significantly improves the overall efficiency of path planning. In actual business scenarios, for a path network containing 353 lines and 5027 nodes, the average path planning execution time of this method is only 12.3% of that using a genetic algorithm and 4.8% of that using Dijkstra's algorithm, significantly reducing time complexity. This makes it more suitable for systems with large data scales and high concurrent request volumes, and reducing computational consumption can lower hardware resource costs.
[0074] In the description of embodiments of the present invention, the terms "first," "second," "third," and "fourth" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first," "second," "third," or "fourth" may explicitly or implicitly include one or more of that feature. In the description of the present invention, unless otherwise stated, "a plurality of" means two or more.
[0075] In the description of embodiments of the present invention, the term "and / or" is used only to describe the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Additionally, the character " / " generally indicates that the preceding and following associated objects are in an "or" relationship.
[0076] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A path planning method based on graph structure caching, characterized in that, include: Step 1, data cache construction, specifically: Step 101, Prepare basic line data; A single data point is represented as a tuple. A line consists of multiple data points arranged in sequence. The data from all lines are aggregated to form the entire dataset S. The basic route data includes the route name, starting station, stations along the route, ending station, basic station information, and distances between stations. Step 102: Traverse the dataset S and create secondary indexes S1 and S2 for transit stations and all stations respectively; and create indexes S3 and S4 with the route name as the key and the list of transit stations and the list of all stations on the route as the value respectively. Step 103: Traverse index S1. For each station s, retrieve its corresponding line list m. Generate combination C(m,2) based on list m. Traverse each pair of elements (a,b) in combination C. Establish a second-level index S5 with a as the first-level key, b as the second-level key, and the intersection of S3[a] and S3[b] as the value. Then, convert S5 into an unweighted undirected graph G with line objects as nodes and the transfer relationship between lines as edges. Step 104: Traverse the routes in S4. During the traversal, take the current route as the root node entry and use the breadth-first traversal algorithm to traverse graph G. During the traversal of graph G, generate a table of possible paths to all other routes and finally generate dataset S6. Step 2, path planning, specifically: Step 201: When performing path planning, first determine whether the starting point a and the ending point b are collinear based on the cached data. If they are, select the solution with the shortest path distance among the collinear cases and return it; otherwise, proceed to step 202. Step 202: Extract the sets S2[a] and S2[b] of routes passing through the starting point a and the ending point b from S2 respectively. Take one element from each of S2[a] and S2[b] and combine them in pairs, denoted as (α,β). Extract the path list S6[α][β] from S6 and set the parameters κ and λ, where κ represents the maximum number of comparisons constraint and λ represents the maximum number of transfers constraint. Select a set of schemes from S6[α][β] according to the parameters κ and λ, denoted as P. Iterate through P, calculate the path distance of each scheme, and return the scheme with the shortest path distance. Step 203: Compare the path distance calculation results of each scheme in P, and select the scheme with the shortest path distance as the optimal scheme from the starting point a to the ending point b.
2. The path planning method based on graph structure caching according to claim 1, characterized in that, The tuple form of a single data entry is: tuple = (route name, station name, whether it is a transfer station, distance value).
3. The path planning method based on graph structure caching according to claim 1, characterized in that, The specific steps for converting S5 into an undirected graph G are as follows: using the first-level index key of S5 as a node and the corresponding second-level index key list as the neighbor nodes of that node, S5 is converted into an unweighted undirected graph G=(V,E) with line objects as nodes and the transition relationships between lines as edges. V represents the set of all nodes, the number of nodes is the same as the number of lines n in S, and E represents the set of all edges, the number of edges c is expressed as: , Among them, V i Let || represent the i-th node, and || represent the number of elements in the set.
4. The path planning method based on graph structure caching according to claim 1, characterized in that, The dataset S6 has a two-level index structure.
5. The path planning method based on graph structure caching according to claim 4, characterized in that, The value of the inner index represents all possible transit routes from the outer key to the inner key, arranged in ascending order of transit count. An empty list indicates that the transit count is 0, meaning that the two routes intersect and can be directly transited.
6. The path planning method based on graph structure caching according to claim 1, characterized in that, The process of determining whether the starting point a and the ending point b are collinear is as follows: determine the number of elements in the union of S2[a] and S2[b]. If S2[a] & S2[b] ≠ ∅, it indicates that the two points are collinear.
7. The path planning method based on graph structure caching according to claim 1, characterized in that, Index S1 is a secondary index with the station name as the primary key, the line name that can be converted through the station as the secondary key, and the line object as the value; Index S2 is a secondary index with the station name as the key, the line name that passes through the station as the secondary key, and the line object as the value.
8. The path planning method based on graph structure caching according to claim 1, characterized in that, The process of calculating the path distance of each scheme in step 202 is as follows: Let q be a sequence composed of route α, all transfer routes in the proposed scheme, and route β, with length denoted as n. Then, sequentially take the set of transfer points for the preceding and following routes, denoted as ω. Where i = 0, 1, ..., n-1; Take the starting point a as the root node, the intermediate points in ω as branch nodes, construct a tree according to the order of the stations along the way, use the distance between the two stations as the weight from the node to the child node, and each branch node participates in the continuation process of the subsequent route, and finally form a tree, denoted as T. Then the path from the root node to each leaf node corresponds to an optional path. The tree T is traversed using a preorder traversal algorithm. The total weight of the path from the root node to each leaf node is calculated and the corresponding path is recorded. The path with the smallest weight is selected and returned to obtain the shortest path of this route combination, which is used as the path distance of the solution.
Citation Information
Patent Citations
Timing sequence road network shortest path query method based on tree decomposition
CN116028682A
Method and an Apparatus for Searching or Comparing Sites Using Routes or Route Lengths Between Sites and Places Within a Transportation System
US20190259082A1