Path problem planning method and device, equipment and storage medium
Patent Information
- Application Number
- CN202411672460.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-11
AI Technical Summary
When the prior art generates closed paths at one time, it is difficult to meet the actual needs, and once the node connection is incorrect, it will affect the subsequent paths and lead to deviations from the actual needs.
By obtaining all nodes to build an initial closed path, destroy part of the edges of the initial path to produce orphan nodes and open loop paths, connect orphan nodes and endpoints to reconstruct the path, forming a target path that meets access needs.
Dynamic reconstruction of paths is realized, which can better meet actual access needs, avoid the defect of generating paths at one time, and improve the flexibility and accuracy of path planning.
Smart Images

Figure CN119599232A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of using neural networks to solve path planning problems in artificial intelligence, and in particular to a path problem planning method, device, equipment and storage medium. Background Art
[0002] The path planning problem refers to planning the order of visiting these nodes in sequence given the information of several nodes that need to be visited, so as to make the path as short as possible while satisfying certain constraints. In the field of artificial intelligence, the existing technology of using neural networks to solve path planning problems is to input node coordinates and other additional information into the model, and select a node as the starting node. The model then predicts the node connected to the starting node and uses the node as the tail node. The node connected to the tail node is then predicted from the remaining nodes. Repeat the above operation, update the tail node, and connect the selected node to the tail node each time until all nodes are connected to form a closed path. Since it is a one-time generated closed path, once one of the nodes is connected incorrectly, it will affect the subsequent formed path, causing the final closed path to deviate from the actual demand.
[0003] In summary, the path planned once by the existing technology is difficult to meet actual needs.
[0004] Therefore, the prior art still needs to be improved and enhanced. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a path problem planning method, device, equipment and storage medium, which solves the problem that the path planned once in the prior art is difficult to meet actual needs.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] In a first aspect, the present invention provides a path problem planning method, which includes:
[0008] Get all the nodes that need to be visited and use all the nodes to build a closed initial path;
[0009] Destroying some of the edges included in the initial path to obtain isolated nodes, and obtaining an open-loop path consisting of continuous nodes, and determining endpoints of the open-loop path;
[0010] The isolated node and the endpoint are connected to obtain a closed, simplified reconstructed path, and a target path that meets the access requirement is obtained based on the open-loop path and the reconstructed path.
[0011] In one implementation, constructing a closed initial path using all nodes includes:
[0012] Randomly select two nodes to form a closed loop, then continue to randomly select nodes from unvisited nodes, and insert the selected nodes into the closed loop. The insertion position minimizes the increase in the length of the closed loop after the new node is inserted. Repeat the process of selecting nodes from unvisited nodes and inserting them into the closed loop until all unvisited nodes are inserted into the closed loop, and an initial path is obtained, wherein the unvisited nodes are all nodes except the selected nodes.
[0013] In one implementation, destroying some of the edges included in the initial path to obtain isolated nodes and an open-loop path consisting of continuous nodes includes:
[0014] A ring area is randomly selected, nodes inside the ring area are taken as isolated nodes, and a subpath formed by nodes outside the ring in the initial path is taken as an open-loop path.
[0015] In one implementation, the connecting the isolated node and the endpoint to obtain a closed simplified reconstructed path includes:
[0016] Acquire the attribute information of the isolated node, and determine the characteristic information of the isolated node according to the attribute information of the isolated node;
[0017] Acquire the attribute information of the endpoint and the attribute information of the nodes in the open loop path, and determine the characteristic information of the endpoint according to the attribute information of the endpoint and the attribute information of the nodes in the open loop path;
[0018] Marking a starting node and a current node from the isolated nodes and the endpoints, and marking unvisited nodes, wherein the unvisited nodes are nodes among the isolated nodes and the endpoints except the starting node, the current node and the visited nodes;
[0019] According to the characteristic information of the current node, the characteristic information of the unvisited nodes and the characteristic information of the starting node, a node is selected from the unvisited nodes as the next node to be visited, and the current node is updated with the selected node;
[0020] The starting node and the current node as well as the current node after each iterative update are sequentially connected to obtain a closed reconstructed path.
[0021] In one implementation, selecting a node from the unvisited nodes as the next node to be visited based on the feature information of the current node and the feature information of the unvisited nodes, and updating the current node with the selected node, includes:
[0022] Applying a probability prediction model to the feature information of the current node, the feature information of the unvisited nodes, and the feature information of the starting node to obtain a prediction probability corresponding to each of the unvisited nodes, wherein the probability prediction model needs to undergo supervised training to learn the connection order of nodes in the path that meets the access requirements;
[0023] According to the predicted probability corresponding to each of the unvisited nodes, a node is selected from the unvisited nodes as the next node to be visited, and the current node is updated with the selected node.
[0024] In one implementation, the probability prediction model includes an encoder and a decoder connected in sequence, and the decoder includes a linear attention module, a linear projection layer, and a normalization layer connected in sequence;
[0025] The encoder is used to input the feature information of the current node and the feature information of the unvisited nodes into the probability prediction model, and the normalization is used to output the predicted probability.
[0026] In one implementation, the training method of the probability prediction model includes:
[0027] Obtaining each training sample closed path, and obtaining the sample node group contained in each training sample closed path;
[0028] A node is randomly selected from each of the sample node groups, and nodes are destroyed outwards from the node until the number of destroyed nodes reaches a set number, so as to obtain the training isolated nodes and training endpoints corresponding to each of the training sample closed paths after the closed paths are destroyed, the edges connected to the training isolated nodes are destroyed, and the training endpoints are connected to the training isolated nodes before being destroyed;
[0029] The probability prediction model is trained using the training isolated nodes and the training endpoints.
[0030] In a second aspect, an embodiment of the present invention further provides a path problem planning device, wherein the device includes the following components:
[0031] The initial path construction module is used to obtain all nodes to be visited and use all nodes to construct a closed initial path;
[0032] A destroying module, used for destroying some of the edges included in the initial path, obtaining isolated nodes, obtaining an open-loop path consisting of continuous nodes, and determining endpoints of the open-loop path;
[0033] The target path construction module is used to connect the isolated node and the endpoint to obtain a closed simplified reconstructed path, and obtain a target path that meets the access requirements based on the open-loop path and the reconstructed path.
[0034] In a third aspect, an embodiment of the present invention further provides a terminal device, wherein the terminal device includes a memory, a processor, and a path problem planning program stored in the memory and executable on the processor, and when the processor executes the path problem planning program, the steps of the path problem planning method described above are implemented.
[0035] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a path problem planning program is stored. When the path problem planning program is executed by a processor, the steps of the path problem planning method described above are implemented.
[0036] Beneficial effect: The present invention first constructs all nodes into a closed initial path, and then destroys some edges on the initial path to generate isolated nodes and open-loop paths. The nodes at both ends of the open-loop path are endpoints. The isolated nodes and endpoints are used to re-form a closed reconstructed path, which is connected to the open-loop path. The original initial path can be adjusted to obtain the target path. From the above analysis, it can be seen that the target path of the present invention is not generated once, but the path is continuously reconstructed so that the target path can better meet the actual access needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is the overall flow chart of the present invention;
[0038] Figure 2 is a probability prediction flow chart in an embodiment of the present invention;
[0039] Figure 3 It is a schematic diagram of destruction and restoration in an embodiment of the present invention;
[0040] Figure 4 : is a structural diagram of a linear attention module in an embodiment of the present invention;
[0041] Figure 5 A schematic diagram of a newly added node in a hypergraph in an example of the present invention;
[0042] Figure 6 A schematic diagram of node connection and newly added nodes in an example of the present invention;
[0043] Figure 7 A structural diagram of a path problem planning device provided by the present invention;
[0044] Figure 8 This is a block diagram of the internal structure principle of the terminal device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0045] The following is a clear and complete description of the technical solution of the present invention in combination with the embodiments and the accompanying drawings. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] The path planning problem refers to planning the order of visiting these nodes in sequence given the information of several nodes that need to be visited, so as to make the path as short as possible while satisfying certain constraints. Research has found that in the field of artificial intelligence, the existing technology of using neural networks to solve path planning problems is to input node coordinates and other additional information into the model, and select a node as the starting node. The model then predicts the node connected to the starting node and uses the node as the tail node. The node connected to the tail node is then predicted from the remaining nodes. Repeat the above operation, update the tail node, and connect the selected node to the tail node each time until all nodes are connected to form a closed path. Since it is a one-time generated closed path, once one of the nodes is connected incorrectly, it will affect the subsequent formed path, causing the final closed path to deviate from the actual demand.
[0047] In order to solve the above technical problems, the present invention provides a path problem planning method, device, equipment and storage medium, which solves the problem that the path planned once in the prior art is difficult to meet the actual needs. In specific implementation, first obtain all the nodes to be visited, and use all the nodes to build a closed initial path; then destroy some of the edges included in the initial path to obtain isolated nodes, and obtain an open-loop path composed of continuous nodes, and determine the endpoints of the open-loop path; finally, connect the isolated nodes and the endpoints to obtain a closed reconstructed path, and obtain the target path that meets the access requirements based on the open-loop path and the reconstructed path.
[0048] For example, Figure 2 As shown, nodes 1 to 13 are all the nodes that need to be visited, and a simple heuristic method can be used to generate a closed initial path (that is, Figure 2 The initial path is node 1-node 2-node 3-node 4-node 5-node 6-node 7-node 8-node 9-node 10-node 11-node 12-node 13-node 1, and then destroy some of the edges contained in the initial path, such as Figure 2As shown, the edge between node 2 and node 3, the edge between node 3 and node 4, the edge between node 9 and node 10, the edge between node 10 and node 11, and the edge between node 11 and node 12 can be destroyed. Then node 3, node 10, and node 11 are isolated nodes, and all edges connected to isolated nodes are destroyed. Node 2 and node 12 are located at the two ends of the open loop path of node 12-node 13-node 1-node 2, so node 2 and node 12 are endpoints. Similarly, node 4 and node 9 are also located at the two ends of the open loop path of node 4-node 5-node 6-node 7-node 8-node 9. Therefore, node 2 and node 12 and node 4 and node 9 are endpoints. Some of the edges connected to the endpoints have been destroyed, while others have not.
[0049] For the Traveling Salesman Problem (TSP), the characteristic information of node 2 is determined according to the attribute information (coordinates, node category) of node 2 (endpoint) and the attribute information (coordinates, node category) of node 12 (endpoint); the characteristic information of node 3 is determined according to the attribute information (coordinates, node category) of node 3 (isolated node) (the characteristic information can be represented by r2); the characteristic information of node 4 is determined according to the attribute information of node 4 (endpoint) and the attribute information of node 9 (endpoint) as well as the node information inside the open loop path (the characteristic information can be represented by r3); similarly, the characteristic information of node 9 is determined according to the attribute information of node 9 (endpoint) and the attribute information of node 4 (endpoint) as well as the node information inside the open loop path (the characteristic information can be represented by r4); and so on, the characteristic information r5 of node 10, the characteristic information r6 of node 11, and the characteristic information r7 of node 12 are obtained.
[0050] A node is randomly selected from node 3, node 10, node 11, node 2, node 12, node 4, and node 9 as the current node. For example, if the current node is node 3, then r1, r2, r3, r4, r5, r6, and r7 are input into the probability prediction model. The encoder in the probability prediction model encodes the feature information, and the decoder of the probability prediction model uses the initial node encoding, the current node encoding, and the encoding of the unvisited node to repeatedly predict the probability of selecting the next node. That is, predict the probability of node 10, node 11, node 2, node 12, node 4, and node 9 (node 10, node 11, node 2, node 12, node 4, and node 9 are all unvisited nodes at present) as the next selected node, and then screen out the node with the maximum probability. If the node with the highest probability is node 11 (isolated node), then the current node (that is, node 3) is connected to node 11, and node 11 is used as the next current node; and node 11 is removed from the unvisited nodes, and the decoder repeatedly selects the node with the maximum probability from the unvisited nodes until node 3, node 10, node 11, node 2, node 12, node 4, and node 9 are connected into a closed reconstructed path, and the reconstructed path is combined with the two open-loop paths to form the target path.
[0051] If the maximum probability is not node 11 (isolated node) but node 4 (endpoint), since node 4 and node 9 are located on the same open-loop path, node 9 (endpoint) is used as the next current node.
[0052] According to the above scheme, the target path is calculated. For nodes 1 to 13 that need to be visited, these 13 nodes are visited along the target path to make the total path shortest (the shortest total path is the access demand). For the Capacitated Vehicle Routing Problem (CVRP), nodes 1 to 13 are customers and warehouses that need to unload goods. According to the attribute information (coordinates, node category, cargo demand) of node 2 (endpoint) and the attribute information (coordinates, node category, cargo demand) of node 12 (endpoint), as well as the information (cargo demand) of the nodes inside the open loop path (the connected edges are not destroyed), the characteristic information of node 2 is determined (the characteristic information can be represented by r1); according to the attribute information (coordinates, node category, cargo demand) of node 3 (isolated node), the characteristic information of node 3 is determined (the characteristic information can be represented by r2). The characteristic information of other nodes is obtained by analogy. The same scheme as above can be used to calculate the target path, visit the 13 nodes along the target path to make the total path shortest, and meet the customer's cargo volume requirements while not overloading the vehicle (the total path is shortest, meeting the customer's cargo volume requirements and no overloading are the access requirements). The path problem planning method of this embodiment can be applied to a terminal device, which can be a terminal product with a video playback function, such as a television, a computer, etc. In this embodiment, if Figure 1 As shown in , the path problem planning method specifically includes the following steps:
[0053] S100, obtaining all nodes to be visited, and constructing a closed initial path using all nodes;
[0054] S200, destroying some of the edges included in the initial path to obtain isolated nodes, and obtaining an open-loop path consisting of continuous nodes, and determining endpoints of the open-loop path;
[0055] S300, connecting the isolated node and the endpoint to obtain a closed, simplified reconstructed path, and obtaining a target path that meets the access requirement based on the open-loop path and the reconstructed path.
[0056] like Figure 3 As shown, first connect all nodes in sequence (nodes are the locations that users need to visit) to form a closed initial path (initial path is Figure 3 The current solution in the ), and then destroy the current solution to obtain isolated nodes and several open loop paths, and then Figure 3The hypergraph form in the algorithm represents hyperedges and isolated nodes. During the reconstruction process, the hyperedges remain fixed. The probability prediction model learns how to connect isolated nodes and fixed hyperedges to obtain a simplified solution, which is then restored to a complete solution. Thanks to the simplified form of the hypergraph (which consists of isolated nodes and hyperedges), the input scale of the model depends on the degree of destruction, not the scale of the original problem. This reduces computational complexity and enables iteration on large-scale problems.
[0057] Embodiment 1. In this embodiment, step S100 includes the following specific steps: randomly selecting two nodes to connect into a closed loop, and then continuing to randomly select nodes from unvisited nodes, and inserting the selected nodes into the closed loop, the insertion position makes the increase in the length of the closed loop after the new node is inserted into the new node minimal, and repeatedly selecting nodes from unvisited nodes and inserting them into the closed loop until all unvisited nodes are inserted into the closed loop to obtain an initial path, wherein the unvisited nodes are all nodes except the selected nodes.
[0058] For example, there are five nodes, A, B, C, D, and E. A node is randomly selected as the current node. For example, if the current node is node B, then the node closest to B is selected from A, C, D, and E. If the node closest to node B is node D, then node B is connected to node D; then node A closest to node D is selected from A, C, and E, and node D is connected to node A; then node E closest to node A is selected from nodes C and E, and node A is connected to node E. Finally, node E is connected to node C, and node C is connected to node B, which is a closed initial path: node B-node D-node A-node E-node C-node B.
[0059] Embodiment 2 is based on embodiment 1. In this embodiment, step S200 includes the following specific steps: randomly selecting a ring area, treating the nodes inside the ring area as isolated nodes, and treating the sub-path formed by the nodes outside the ring in the initial path as an open-loop path.
[0060] like Figure 2 As shown, all nodes on the initial path include node 1, node 2, node 3, node 4, node 5, node 6, node 7, node 8, node 9, node 10, node 11, node 12, and node 13. A circular area (the circle is also a ring) is randomly selected from the area surrounded by these 13 nodes. The nodes inside the circle are isolated nodes, that is, node 3, node 10, and node 11 are isolated nodes, and the subpath composed of node 12-node 13-node 1-node 2 is an open loop path, and the subpath composed of node 4-node 5-node 6-node 7-node 8-node 9 is also an open loop path. For the CVRP problem, the warehouse node must be an isolated node.
[0061] Embodiment 3, based on embodiment 1 or embodiment 2, in this embodiment, step S300 includes the following specific steps S301 to S306:
[0062] S301, obtaining attribute information of the isolated node, and determining characteristic information r of the isolated node according to the attribute information of the isolated node i .
[0063] For the TSP problem, the isolated node attribute information is the coordinates of the isolated node (x i ,y i ), node class 0. (x i ,y i ), x i is the horizontal coordinate of the ith isolated node, y i is the ordinate of the ith isolated node. (The definitions of the abscissa and ordinate will not be repeated below).
[0064] r i =(x i ,y i ,x i ,y i ,0)
[0065] For the CVRP problem: the isolated node attribute information is the coordinates of the isolated node (x i ,y i ), the amount of cargo required by isolated nodes Node class 0.
[0066]
[0067] S302, acquiring attribute information of the endpoint and attribute information of the nodes in the open loop path, and determining characteristic information r of the endpoint according to the attribute information of the endpoint and the attribute information of the nodes in the open loop path. j .
[0068] For the TSP problem, the attribute information of the endpoint is the coordinates of the endpoint (x j ,y j ), node category 1. The attribute information of a node in an open loop path is the coordinates (x j ′,y j ′). j = ( x j ,y j ,x j ′,y j ′,1 )
[0069] For example, Figure 2 As shown, endpoint 2 and endpoint 12 are located on the same hyperedge. Then, when calculating the feature information r2 of endpoint 2, (x j ,y j ) is the coordinate of endpoint 2, (x j ′,y j ′) is the coordinate of endpoint 12.
[0070] For the CVRP problem, the attribute information of the endpoint is the coordinates of the endpoint (x j ,y j ), node category 1. The attribute information of a node in an open loop path is the coordinates (x j ′,y j ′), the total amount of goods required by all nodes on the open loop path where the jth endpoint is located
[0071]
[0072] S303, marking a starting node and a current node from the isolated nodes and the endpoints, and marking unvisited nodes, wherein the unvisited nodes are nodes among the isolated nodes and the endpoints except the starting node, the current node and the visited nodes.
[0073] The first iteration is when the current node and the starting node are the same node. Figure 2 For example, if the first iteration selects node 3, an isolated node, as the current node, then node 3 is also the starting node, and the unvisited nodes are node 10 (isolated node), node 11 (isolated node), node 2 (endpoint), node 12 (endpoint), node 4 (endpoint), and node 9 (endpoint).
[0074] S304, applying a probability prediction model to the feature information of the current node, the feature information of the unvisited nodes, and the feature information of the starting node to obtain a predicted probability corresponding to each of the unvisited nodes. The probability prediction model needs to undergo supervised learning in order to correctly predict which of the unvisited nodes should be the next node.
[0075] S305: According to the predicted probability p corresponding to each of the unvisited nodes, i″ (p i″ is the i″th unvisited node), select a node from the unvisited nodes as the next node to be visited, and update the current node with the selected node.
[0076] That is, the feature information of node 3 (in the first iteration, node 3 is both the current node and the starting node) and the feature information of the six unvisited nodes, node 10, node 11, node 2, node 12, node 4, and node 9, are input into the probability prediction model. The probability prediction model will output the probability corresponding to each unvisited node. Since the probability prediction model of this embodiment has learned how to connect nodes so that the path formed by connecting the nodes meets the access requirements, the probability prediction model can be used to select which unvisited node to be the next current node. For example, if the probability of node 11 is the largest, then node 11 will be the next current node, and node 3 will still be the starting node. Node 3 will be connected to node 11, and in the next iteration, the feature information of the starting node (that is, node 3), the feature information of node 11, and the feature information of the five unvisited nodes, node 10, node 4, node 2, node 12, and node 9, will be input into the probability prediction model. If the probability of node 10 is the largest in this iteration, then node 10 will be used as the current node for the next iteration. In the next iteration, the feature information of the starting node (that is, node 3) and the feature information of node 10 (current node) and the four unvisited nodes, node 4, node 2, node 12, and node 9, will be input into the probability prediction model, and then the probability of each unvisited node will be predicted, and the iteration will be repeated.
[0077] S306 , sequentially connecting the starting node and the current node as well as the current node after each iterative update to obtain a closed reconstructed path.
[0078] like Figure 2 As shown, the closed reconstruction path includes nodes 2, 12, 4 and 9, and nodes 2, 12, 4 and 9 are located on the open loop path. Therefore, a closed reconstruction path is obtained, and a closed target path that can meet user access requirements is also obtained.
[0079] Embodiment 4, based on embodiment 3, the probability prediction model in embodiment 3 includes an encoder and a decoder connected in sequence, and the decoder includes a linear attention module, a linear projection layer and a normalization layer connected in sequence.
[0080] The encoder consists of only one linear projection layer, which is used to transform r i and r j Convert to Encoding Where d is the embedding dimension.
[0081] The encoder will encode The code that will be divided into the starting node The encoding of the current node Encoding of unvisited nodes and will and as well as Input to the decoder, and then the decoder iteratively updates the predicted probability of each unvisited node. For example, for the tth iteration prediction, the decoder predicts as well as Predict the probability of each of these unvisited nodes 1,2,...,mt.
[0082] The decoder body of this embodiment consists of L linear attention modules, such as Figure 4 As shown in Figure 1, each linear attention module consists of an aggregation attention layer and a broadcast attention layer. The aggregation layer aggregates information to the representative node, and then the broadcast layer distributes this information to all nodes. The initial representative node is generated by the starting node and the current node:
[0083]
[0084] Where [·,·] represents the concatenation operation, Respectively and Augmented to d×r f Weihe d×r c dimensional, and then reshaped into a d-dimensional vector by reshape(), so that r = r f +r c Representative nodes:
[0085]
[0086] In the classic attention module, queries, keys, and values are denoted as X respectively. Q ∈R q×d , X K ∈R k×d , X V ∈R v×d ,have:
[0087]
[0088] Where W Q , W K , W V ∈R d×d are all model parameters.
[0089] In the linear attention module, the aggregate attention layer takes the representative nodes as queries and aggregates the information of all nodes:
[0090]
[0091] in Represents the encoding of all points output by the (l-1)th linear attention module.
[0092] The broadcast attention layer uses the aggregated information as keys and values for all nodes to query:
[0093]
[0094] The resulting Brd (l) ∈R (r+m-t)×d , can be split into the encoding representing the node and the encoding of the remaining unvisited nodes After L linear attention modules, Input a linear layer, then pass through the softmax (normalization layer) to get the node selection probability:
[0095]
[0096] in is the encoding of the characteristic information of the i″th unvisited node, W o is the learnable parameter of softmax, φ is the activation function of softmax, yes One of the values in For all The sum of all additions.
[0097] In this embodiment, the training method of the probability prediction model includes the following specific steps: obtaining each training sample closed path, and obtaining the sample node group contained in each of the training sample closed paths; randomly selecting a node from each of the sample node groups, and destroying nodes outward from the node until the number of destroyed nodes reaches a set number, thereby obtaining the training isolated nodes and training endpoints corresponding to each of the training sample closed paths after being destroyed, wherein the edges connected to the training isolated nodes are destroyed, and the training endpoints are the endpoints of the open-loop paths generated by the destruction; the training isolated nodes and the training endpoints are used to train the probability prediction model, wherein the model learns the connection order of the training isolated nodes and the training endpoints on the training sample closed paths during the training process to predict which of the unvisited nodes should be the next node.
[0098] In this embodiment, supervised learning (SL) is used to train the model. Since the optimal edge usually appears between adjacent nodes, a cluster-destroying strategy is adopted. In addition, the node coordinates in the simplified hypergraph are normalized to the interval [0,1] to improve the consistency of the distribution.
[0099] For fixed hyperedges, under the constraint, after any endpoint is selected, the next node must be the other endpoint. Therefore, a mask is added to prevent this part of the gradient from propagating. In addition, in a batch, the destruction by the k-nearest neighbor method will result in different numbers of fragments for different samples, resulting in different numbers of nodes in the hypergraph, which in turn affects the training stability. To solve this problem, a special destruction scheme is designed to ensure a fixed-size hypergraph, called sample alignment.
[0100] Sample alignment is used to pre-calculate the size of the hypergraph before performing the destruction. To do this, the order in which the nodes are destroyed needs to be pre-defined. In cluster destruction, starting from a central node, the nodes closer to the center are destroyed earlier. Whenever a new node is destroyed, the number of new nodes added to the hypergraph depends on whether the edges connecting the node and its neighboring nodes (including first-order and second-order neighboring nodes) have been destroyed. Figure 5 As shown in the figure, the destroyed new node (node 3) is connected to four neighbor nodes (two first-order and two second-order neighbor nodes). For node 3, nodes 2 and 4 are first-order nodes, and nodes 1 and 5 are second-order nodes. After destroying the node, three new nodes appear in the hypergraph, namely, node 2, node 3, and node 4.
[0101] For cluster destruction, whether the destroyed new node is connected to a neighbor depends on whether the neighbor is closer to the cluster center. Figure 6 The article summarizes all the node connection situations and the corresponding newly added node results in cluster destruction.
[0102] In this embodiment, the algorithm for sample alignment is as follows:
[0103] Input: node coordinates X and initial solution S under batch, cluster center c = (x c ,y c ), the hypergraph target size k
[0104] Output: mask matrix M, indicating which nodes need to be destroyed;
[0105] Symbol: cumsum(): Calculates the cumulative sum of a tensor along a certain dimension;
[0106] dist(): calculates the distance between nodes;
[0107] sort(): Sorts a tensor in ascending order along a dimension;
[0108] Calculate the distance matrix D = dist(X, c) from each node to the cluster center and sort it: π = sort;
[0109] For all nodes and their first-order neighbors 1 A ,1B and second-order neighbors 2 A ,2 B , comparing the distances between them to determine if they were connected before the node was destroyed:
[0110]
[0111] and
[0112] and
[0113] Combination Figure 6 , calculate the number of nodes N added to the hypergraph at each step when the current solution is destroyed by sequence π;
[0114] Calculate the size of the hypergraph at each step when destroying the current solution with sequence π, H = cumsum(N);
[0115] Calculate the mask matrix M = (H ≤ k).
[0116] In this embodiment, the embedding dimension of the encoder is set to 128. The decoder consists of 6 linear attention modules, each with 8 attention heads and 16 representative starting nodes. The hidden dimension of the feedforward layer is set to 512.
[0117] For the TSP problem, the model is trained on 1,000,000 TSP100 instances for 100 epochs and fine-tuned on 10,000 TSP1000 instances for 20 epochs to adapt to large-scale problems. For the CVRP problem, the model is trained on 1,000,000 CVRP100 instances for 100 epochs. The batch size used is 1024, and the hypergraph size of the training samples is between [20,0.8n], where n is the size of the original problem. Since sample alignment discards a small number of samples, the actual batch size is about 800. The cross entropy loss function and Adam optimizer are used. The initial learning rate is 1e-4, and the decay rate for each epoch is 0.97. The model is trained and tested on an NVIDIA GeForce RTX 3090 GPU with 24GB of video memory.
[0118] In summary, this paper proposes a new hypergraph-based destroy-reconstruct framework (DRHG) for solving path planning problems. For the problem after destruction, hypergraph simplification is performed, which effectively reduces the learning burden of the model and limits the scale of the model input to the destruction range. A large number of experimental comparisons show that DRHG outperforms other representative neural combinatorial optimization (NCO) methods in different problem scales and distributions in both synthetic data and real-world examples.
[0119] This embodiment also provides a path problem planning device, such as Figure 7 As shown, the device comprises the following components:
[0120] The initial path construction module 01 is used to obtain all nodes to be visited and construct a closed initial path with all nodes;
[0121] A destroying module 02, used to destroy some of the edges included in the initial path, obtain isolated nodes, obtain an open-loop path consisting of continuous nodes, and determine the endpoints of the open-loop path;
[0122] The target path construction module 03 is used to connect the isolated node and the endpoint to obtain a closed simplified reconstructed path, and obtain a target path that meets the access requirement based on the open-loop path and the reconstructed path.
[0123] Based on the above embodiments, the present invention further provides a terminal device, whose principle block diagram can be shown as follows: Figure 8 As shown. The terminal device includes a processor, a memory, a network interface, and a display screen connected via a system bus. Among them, the processor of the terminal device is used to provide computing and control capabilities. The memory of the terminal device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the terminal device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a path problem planning method is implemented. The display screen of the terminal device can be a liquid crystal display screen or an electronic ink display screen.
[0124] Those skilled in the art will understand that Figure 8 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the terminal device to which the scheme of the present invention is applied. The specific terminal device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0125] In one embodiment, a terminal device is provided. The terminal device includes a memory, a processor, and a path problem planning program stored in the memory and executable on the processor. When the processor executes the path problem planning program, the following operation instructions are implemented:
[0126] Get all the nodes that need to be visited and use all the nodes to build a closed initial path;
[0127] Destroying some of the edges included in the initial path to obtain isolated nodes, and obtaining an open-loop path consisting of continuous nodes, and determining endpoints of the open-loop path;
[0128] The isolated node and the endpoint are connected to obtain a closed, simplified reconstructed path, and a target path that meets the access requirement is obtained based on the open-loop path and the reconstructed path.
[0129] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0130] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A path problem planning method, characterized in that: include: Get all the nodes that need to be visited and use all the nodes to build a closed initial path; Destroying some of the edges included in the initial path to obtain isolated nodes, and obtaining an open-loop path consisting of continuous nodes, and determining endpoints of the open-loop path; The isolated node and the endpoint are connected to obtain a closed, simplified reconstructed path, and a target path that meets the access requirement is obtained based on the open-loop path and the reconstructed path.
2. The path problem planning method according to claim 1, characterized in that: The method of constructing a closed initial path using all nodes includes: Randomly select two nodes to form a closed loop, then continue to randomly select nodes from unvisited nodes, and insert the selected nodes into the closed loop. The insertion position makes the increase in the length of the closed loop after the new node is inserted into the new node minimal. Repeat the process of selecting nodes from unvisited nodes and inserting them into the closed loop until all unvisited nodes are inserted into the closed loop, and obtain the initial path, where the unvisited nodes are all nodes except the selected nodes.
3. The path problem planning method according to claim 1, characterized in that: The destroying of some of the edges included in the initial path to obtain isolated nodes and an open-loop path consisting of continuous nodes includes: A ring area is randomly selected, nodes inside the ring area are taken as isolated nodes, and a subpath formed by nodes outside the ring in the initial path is taken as an open-loop path.
4. The path problem planning method according to claim 1, characterized in that: The connecting the isolated node and the endpoint to obtain a closed simplified reconstructed path includes: Acquire the attribute information of the isolated node, and determine the characteristic information of the isolated node according to the attribute information of the isolated node; Acquire the attribute information of the endpoint and the attribute information of the nodes in the open loop path, and determine the characteristic information of the endpoint according to the attribute information of the endpoint and the attribute information of the nodes in the open loop path; Marking a starting node and a current node from the isolated nodes and the endpoints, and marking unvisited nodes, wherein the unvisited nodes are nodes among the isolated nodes and the endpoints except the starting node, the current node and the visited nodes; According to the characteristic information of the current node, the characteristic information of the unvisited nodes and the characteristic information of the starting node, a node is selected from the unvisited nodes as the next node to be visited, and the current node is updated with the selected node; Connect the starting node and the nodes visited at each step in sequence to obtain a closed reconstructed path.
5. The path problem planning method according to claim 4, characterized in that: The step of selecting a node from the unvisited nodes as the next node to be visited based on the feature information of the current node, the feature information of the unvisited nodes, and the feature information of the starting node, and updating the current node with the selected node, comprises: Applying a probability prediction model to the feature information of the current node, the feature information of the unvisited nodes, and the feature information of the starting node to obtain a predicted probability of each of the unvisited nodes being selected as the next visited node, wherein the probability prediction model needs to undergo supervised training to learn the connection order of nodes in the path that meets the access requirements; According to the predicted probability corresponding to each of the unvisited nodes, a node is selected from the unvisited nodes as the next node to be visited, and the current node is updated with the selected node.
6. The path problem planning method according to claim 5, characterized in that: The probability prediction model includes an encoder and a decoder connected in sequence, and the decoder includes a linear attention module, a linear projection layer and a normalization layer connected in sequence; The encoder is used to input the feature information of the current node and the feature information of the unvisited nodes into the probability prediction model, and the normalization is used to output the predicted probability.
7. The path problem planning method according to claim 5 or 6, characterized in that: The training method of the probability prediction model includes: Obtaining each training sample closed path, and obtaining the sample node group contained in each training sample closed path; A node is randomly selected from each of the sample node groups, and nodes are destroyed outwards from the node until the number of destroyed nodes reaches a set number, so as to obtain the training isolated nodes and training endpoints corresponding to each of the training sample closed paths after the closed paths are destroyed, the edges connected to the training isolated nodes are destroyed, and the training endpoints are connected to the training isolated nodes before being destroyed; The probability prediction model is trained using the training isolated nodes and the training endpoints.
8. A path problem planning device, characterized in that: The device comprises the following components: The initial path construction module is used to obtain all nodes to be visited and use all nodes to construct a closed initial path; A destroying module, used for destroying some of the edges included in the initial path, obtaining isolated nodes, obtaining an open-loop path consisting of continuous nodes, and determining endpoints of the open-loop path; The target path construction module is used to connect the isolated node and the endpoint to obtain a closed simplified reconstructed path, and obtain a target path that meets the access requirement based on the open-loop path and the reconstructed path.
9. A terminal device, characterized in that: The terminal device includes a memory, a processor, and a path problem planning program stored in the memory and executable on the processor. When the processor executes the path problem planning program, the steps of the path problem planning method as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a path problem planning program, and when the path problem planning program is executed by the processor, the steps of the path problem planning method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Method and device for planning touring route
CN120445207A