Rapid path planning method and system based on improved kruskal
Through the improved Kruskal algorithm, an undirected graph is constructed and the edge with the smallest weight is selected for path planning, which solves the problem of long path planning time for classic genetic algorithms and achieves more efficient path planning.
Patent Information
- Application Number
- CN202510042734.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-10
- Publication Date
- 2025-05-13
AI Technical Summary
Classical genetic algorithms have a problem of long local iteration time in path planning, and the correction scheme is complex and non-universal.
Using the improved Kruskal algorithm, path planning is completed by constructing an undirected graph, sorting edge weights in ascending order, and selecting the edge with the smallest weights until the number of selected edges is one less than the number of nodes. And during the selection process, discard edges that may cause node degree to be greater than 2 or loop formation.
It significantly reduces the time of path planning, avoids the problems of large nodes and loop formation, and improves the efficiency of path planning.
Smart Images

Figure CN119990488A_ABST
Abstract
Description
Technical Field
[0001] The present invention specifically relates to a fast path planning method and system based on improved Kruskal. Background Art
[0002] There have been a lot of planning algorithms and research on the problem of shortest path planning. Nowadays, genetic algorithm has become a very popular path planning algorithm, widely used in combinatorial optimization, automatic control, image processing, machine learning and other fields.
[0003] Since genetic algorithms have high performance and various correction schemes are complex and non-universal, classical genetic algorithms are almost the mainstream in the application field. However, genetic algorithms still have many problems, such as long local iteration time. Summary of the invention
[0004] The present invention provides a fast path planning method and system based on improved Kruskal to solve the above-mentioned technical problems, and specifically adopts the following technical solutions:
[0005] A fast path planning method based on improved Kruskal, comprising:
[0006] Construct an undirected graph based on the actual task;
[0007] Sort the edges in the undirected graph in ascending order according to their weights;
[0008] Select the edge with the smallest weight among all the current edges and add it to the path. Repeat the selection process until the number of selected edges is one less than the number of nodes, and the path planning is completed.
[0009] Furthermore, in the process of sequentially selecting the edge with the smallest weight among all the current edges to be added to the path, if the addition of the currently selected edge will cause the degree of a certain node to be greater than 2, the edge is deemed to be an unqualified edge and is discarded.
[0010] Furthermore, in the process of sequentially selecting the edge with the smallest weight among all the current edges to add to the path, if the nodes corresponding to the two endpoints of the currently selected edge are both nodes of the previously selected edge, the edge is deemed to be an unqualified edge and is discarded.
[0011] Furthermore, the specific method of constructing an undirected graph according to the actual task is:
[0012] Get all working points;
[0013] Determine the distance between two working points;
[0014] An undirected graph is constructed with the working points as nodes and the distance between two working points as the edges of the corresponding two nodes.
[0015] Furthermore, the specific method for determining the distance between any two working points is:
[0016] Get the coordinate information of each working point;
[0017] The Euclidean distance between two working points is calculated based on the coordinate information as the distance between the two working points.
[0018] A fast path planning system based on improved Kruskal, comprising:
[0019] The building module is used to construct undirected graphs according to actual tasks;
[0020] The sorting module is used to sort the edges in the undirected graph in ascending order according to the weight of the edge;
[0021] The planning module selects the edge with the smallest weight among all the current edges and adds it to the path. The selection process is repeated until the number of selected edges is one less than the number of nodes, and the path planning is completed.
[0022] Furthermore, when the planning module sequentially selects the edge with the smallest weight among all the current edges to add to the path, if the addition of the currently selected edge will cause the degree of a node to be greater than 2, the edge is deemed to be an unqualified edge and is discarded.
[0023] Furthermore, when the planning module sequentially selects the edge with the smallest weight among all the current edges to add to the path, if the nodes corresponding to the two endpoints of the currently selected edge are both nodes of the previously selected edge, the edge is deemed to be an unqualified edge and is discarded.
[0024] Furthermore, the building blocks include:
[0025] An acquisition unit, used to acquire all working points;
[0026] A determination unit, used to determine the distance between any two working points;
[0027] The construction unit is used to construct an undirected graph with the working points as nodes and the distance between two working points as the edge of the corresponding two nodes.
[0028] Furthermore, the construction unit comprises:
[0029] An acquisition subunit is used to acquire the coordinate information of each working point;
[0030] The calculation subunit is used to calculate the Euclidean distance between two working points according to the coordinate information and use it as the distance between the two working points.
[0031] The invention is beneficial in that it provides a fast path planning method and system based on improved Kruskal, which greatly reduces the time of path planning. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0033] Figure 1 It is a schematic diagram of a fast path planning method based on improved Kruskal of the present invention;
[0034] Figure 2 It is a schematic diagram of an undirected graph;
[0035] Figure 3 Yes Figure 2 Schematic diagram of the minimum spanning tree of the undirected graph in;
[0036] Figure 4 It is a schematic diagram of the path planning process of an undirected graph;
[0037] Figure 5 It is a schematic diagram of a circular local loop that appears during the path planning process of an undirected graph;
[0038] Figure 6 It is a schematic diagram of a fast path planning system based on improved Kruskal of the present invention. DETAILED DESCRIPTION
[0039] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0040] like Figure 1The present application shows a fast path planning method based on the improved Kruskal algorithm, comprising: S1: constructing an undirected graph according to the actual task. S2: sorting the edges in the undirected graph in ascending order according to the weights of the edges. S3: selecting the edges with the smallest weights among all the current edges in turn and adding them to the path, repeating the selection process until the number of selected edges is one less than the number of nodes, and then completing the path planning. The path planning method of the present application, based on the improved Kruskal algorithm, can quickly complete the path planning task. The above steps are described in detail below.
[0041] For step S1: construct an undirected graph according to the actual task.
[0042] In the implementation manner of the present application, the specific method for constructing an undirected graph according to the actual task is:
[0043] Get all working points.
[0044] Determine the distance between two working points.
[0045] An undirected graph is constructed with the working points as nodes and the distance between two working points as the edges of the corresponding two nodes.
[0046] Among them, the specific method for determining the distance between two working points is:
[0047] Get the coordinate information of each working point.
[0048] The Euclidean distance between two working points is calculated based on the coordinate information as the distance between the two working points.
[0049] For step S2: sort the edges in the undirected graph in ascending order according to the weights of the edges.
[0050] For step S3: select the edge with the smallest weight among all the current edges in turn and add it to the path, repeat the selection process until the number of selected edges is one less than the number of nodes, then the path planning is completed.
[0051] The Kruskal algorithm first arranges all edges in ascending order according to the size of the weight, and then selects the edges with the smallest weight in the sequence in turn until the number of selected edges is one less than the number of nodes, that is, after all nodes are added to the path, the algorithm process ends.
[0052] In some cases, such as Figure 2 The undirected graph shown in the figure has the following result after the above algorithm: Figure 3 As shown. The final result is a minimum spanning tree, not a linear sequential path. That is, starting from any point with degree 1 in the minimum spanning tree, it is impossible to traverse all other vertices without repetition. In the figure, the degree of node E is 3, which is greater than 2.
[0053] To avoid this situation, in the implementation of the present application, when selecting the edge with the smallest weight among all the current edges to add to the path, if the addition of the currently selected edge will cause the degree of a node to be greater than 2, the edge is considered to be an unqualified edge and is discarded. This ensures that the degree of any node in the final path is <= 2, thus avoiding Figure 3 The situation of node E in .
[0054] like Figure 4 and Figure 5 As shown, in some cases, if another edge is added, a local loop will appear in the generated path. To avoid such a situation, in the implementation of the present application, when selecting the edge with the smallest weight among all the current edges to add to the path, if the nodes corresponding to the two endpoints of the currently selected edge are both nodes of the previously selected edge, the edge is considered to be an unqualified edge and is discarded.
[0055] This application designs a function kuruskal:
[0056] This function requires one parameter, the two-dimensional coordinates of all working points: data[3,y1,z1,y2,z2,y 3 ,z 3 ].
[0057] Then we can know that the total number of working points n is: data[0] = 3;
[0058] The coordinates of work point ① are [data[1], data[2]], that is, [y1, z1]; the coordinates of work point ② are [[data[3], data[4]], that is, [y2, z2]; the coordinates of work point ③ are [data[5], data[6]], that is, [y 3 ,z 3 ]. Then calculate:
[0059] The weight (distance) of the edge between ① and ②:
[0060] The weight (distance) of the edge between ①-③:
[0061] The weight (distance) of the edge between ② and ③ is:
[0062] Then create a triple to store the starting point and end point of the edge obtained above and the weight of the edge.
[0063] Then sort the data in the triplet from small to large according to the weight of the edge (assuming weight 23 >weight 12>weight 13 ).
[0064] Next, take edges from the sorted triplets and add them to the path one by one: at this time, the edge with the smallest weight is ②-③, so add ②-③ to the path.
[0065] Then continue to look for the edge ①-② with the smallest weight from the remaining edges except ②-③, and add the edge ①-② to the path.
[0066] When it is detected that the nodes in the path contain all the working points, that is, the number of path nodes = the number of working points, the algorithm ends. The path is: ①-②-③ or ③-②-①.
[0067] The following experiments verify the efficiency of the method of the present application. First, determine the real coordinates of 17 working points: {3322,1985}, {3144,1710, {3846,1435}, {4530,1435}, {4709,1435, {2623,1160}, {3144,885}, {3322,885}, {4010,885}. The total cost of the shortest path obtained by the method of the present application is 8374.954920, which takes 0.1 seconds. For the same 17 working points, the genetic algorithm is used for iteration, and finally 10 iterations are performed. The cost of finding the path is 8374.94mm, and the running time is 30.77s. The legacy algorithm only takes about 31 seconds for 10 iterations, while our algorithm has an average running time of 0.1 seconds, which greatly reduces the running time.
[0068] like Figure 6 As shown, the present application also discloses a fast path planning system based on improved Kruskal, which is used to implement the aforementioned fast path planning method based on improved Kruskal. The fast path planning system based on improved Kruskal includes: a building module, a sorting module and a planning module.
[0069] Specifically, the construction module is used to construct an undirected graph according to the actual task. The sorting module is used to sort the edges in the undirected graph in ascending order according to the edge weights. The planning module selects the edge with the smallest weight among all the current edges and adds it to the path. The selection process is repeated until the number of selected edges is one less than the number of nodes, and the path planning is completed.
[0070] In an implementation manner of the present application, when the planning module sequentially selects the edge with the smallest weight among all the current edges to add to the path, if the addition of the currently selected edge will cause the degree of a node to be greater than 2, the edge is deemed to be an unqualified edge and is discarded.
[0071] In an implementation manner of the present application, when the planning module sequentially selects the edge with the smallest weight among all the current edges to add to the path, if the nodes corresponding to the two endpoints of the currently selected edge are both nodes of the previously selected edge, the edge is deemed to be an unqualified edge and is discarded.
[0072] In the implementation of the present application, the construction module includes: an acquisition unit, a determination unit and a construction unit. The acquisition unit is used to acquire all working points. The determination unit is used to determine the distance between two working points. The construction unit is used to construct an undirected graph with the working points as nodes and the distance between two working points as the edge of the corresponding two nodes.
[0073] The construction unit includes: an acquisition subunit and a calculation subunit. The acquisition subunit is used to acquire the coordinate information of each work point. The calculation subunit is used to calculate the Euclidean distance between two work points according to the coordinate information and use it as the distance between the two work points.
[0074] The specific technical details of the fast path planning system based on the improved Kruskal refer to the aforementioned fast path planning method based on the improved Kruskal, which will not be repeated here.
[0075] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the above embodiments do not limit the present invention in any form, and any technical solution obtained by equivalent replacement or equivalent transformation falls within the protection scope of the present invention.
Claims
1. A fast path planning method based on improved Kruskal, characterized in that: Include: Construct an undirected graph based on the actual task; Sort the edges in the undirected graph in ascending order according to their weights; Select the edge with the smallest weight among all the current edges and add it to the path. Repeat the selection process until the number of selected edges is one less than the number of nodes, and the path planning is completed.
2. The fast path planning method based on improved Kruskal according to claim 1, characterized in that: In the process of sequentially selecting the edge with the smallest weight among all the current edges to be added to the path, if the addition of the currently selected edge will cause the degree of a certain node to be greater than 2, the edge is deemed to be an unqualified edge and is discarded.
3. The fast path planning method based on improved Kruskal according to claim 2, characterized in that: In the process of sequentially selecting the edge with the smallest weight among all the current edges to add to the path, if the nodes corresponding to the two endpoints of the currently selected edge are both nodes of the previously selected edge, the edge is determined to be an unqualified edge and is discarded.
4. The fast path planning method based on improved Kruskal according to claim 1, characterized in that: The specific method of constructing an undirected graph according to the actual task is: Get all working points; Determine the distance between two working points; An undirected graph is constructed with the working points as nodes and the distance between two working points as the edges of the corresponding two nodes.
5. The fast path planning method based on improved Kruskal according to claim 4, characterized in that: The specific method for determining the distance between two working points is: Get the coordinate information of each working point; The Euclidean distance between two working points is calculated based on the coordinate information as the distance between the two working points.
6. A fast path planning system based on improved Kruskal, characterized in that: Include: The building module is used to construct undirected graphs according to actual tasks; The sorting module is used to sort the edges in the undirected graph in ascending order according to the weight of the edge; The planning module selects the edge with the smallest weight among all the current edges and adds it to the path. The selection process is repeated until the number of selected edges is one less than the number of nodes, and the path planning is completed.
7. The fast path planning system based on improved Kruskal according to claim 6, characterized in that: In the process of sequentially selecting the edge with the smallest weight among all the current edges to add to the path, if the addition of the currently selected edge will cause the degree of a node to be greater than 2, the edge is deemed to be an unqualified edge and is discarded.
8. The fast path planning system based on improved Kruskal according to claim 7, characterized in that: In the process of sequentially selecting the edge with the smallest weight among all the current edges to add to the path, if the nodes corresponding to the two endpoints of the currently selected edge are both nodes of the previously selected edge, the edge is deemed to be an unqualified edge and is discarded.
9. The fast path planning system based on improved Kruskal according to claim 1, characterized in that: The building blocks include: An acquisition unit, used to acquire all working points; A determination unit, used to determine the distance between any two working points; The construction unit is used to construct an undirected graph with the working points as nodes and the distance between two working points as the edge of the corresponding two nodes.
10. The fast path planning method based on improved Kruskal according to claim 9, characterized in that: The building block comprises: An acquisition subunit is used to acquire the coordinate information of each working point; The calculation subunit is used to calculate the Euclidean distance between two working points according to the coordinate information and use it as the distance between the two working points.