An improved minimum path set search method, device and equipment
Through preprocessing and sub-thread parallel search, combined with closure structure judgment, the inefficiency problem of the existing minimum path set search algorithm in complex networks is solved, and a more efficient minimum path set search is achieved.
Patent Information
- Application Number
- CN202210096099.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-26
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-01-26
AI Technical Summary
The existing minimum path set search algorithm has low operating efficiency when the network scale increases. The time complexity of the backtracking condition is high and the surrounding relationship of nodes is not considered, resulting in low search efficiency.
Through the preprocessing network, sub-thread parallel search and closure structure judgment are used to reduce unnecessary node visits, reduce the time complexity of backtracking conditions, and introduce a parallel mechanism to improve the minimum path set search efficiency.
It improves the efficiency of minimum path set search, reduces the time complexity of backtracking conditions, reduces the search volume of nodes, and is suitable for multi-state systems of complex networks.
Smart Images

Figure CN114491887B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to an improved minimum path set search method, device, computer equipment and storage medium. Background Art
[0002] Today's society is a highly networked society. Various technical networks (such as transportation and logistics networks, communication networks, computer networks, power supply (gas, water) networks, etc.) support the safe and stable operation of social production and life, and have become an integral part of urban infrastructure. However, as the scale of these technical networks becomes larger and larger and the structure becomes more and more complex, the entire network is more susceptible to internal failures or external uncertainties, becoming the main threat to network security and stable operation. Evaluating the service quality of the network in an uncertain environment is of great practical significance for ensuring the normal operation of the network and maintaining the healthy development of the social economy. Due to the influence of internal or external uncertainties, the network and its components generally show a variety of different performance levels during operation. Such a network is called a multi-state network. Minimum path sets play an important role in the reliability analysis of multi-state network systems and are the basis for the reliability evaluation of multi-state networks based on minimum path sets. Searching for all minimum path sets in a network is an NP-hard problem.
[0003] However, the current direct search algorithm uses the depth-first search (DFS) mechanism to search for all minimum path sets, which is a simple and effective method. The current effective DFS algorithm is based on backtracking and adjacency lists. However, the existing method is a single-threaded sequential calculation process, and there is room for improvement in operation efficiency. In addition, the time complexity of the backtracking condition in the existing method will increase with the increase of the network scale, and there is room for improvement in the backtracking condition. Moreover, the existing method does not consider the encirclement relationship of nodes in the network. Summary of the invention
[0004] Based on this, it is necessary to provide an improved minimum path set search method, device, computer equipment and storage medium that can improve the minimum path set search efficiency in response to the above technical problems.
[0005] An improved minimum path set search method, the method comprising:
[0006] Obtain a network to be searched; the network to be searched includes multiple nodes;
[0007] Preprocess the search network to obtain the initial minimum path set and the distance from each node to the sink;
[0008] Traverse from the starting point of the network to be searched to obtain a current node with at least two unvisited neighbor nodes; the starting point is any node in the network to be searched;
[0009] Create multiple sub-threads according to the number of unvisited neighbor nodes of the current node, and traverse the neighbor nodes in the sub-threads respectively to obtain at least one unvisited neighbor node;
[0010] Perform sink judgment on the unvisited neighbor nodes, update the initial minimum path set according to the judgment result, and obtain the candidate minimum path set;
[0011] Check the neighbor node. If the neighbor node is not included in the candidate minimum path set, obtain the distance from the neighbor node to the sink.
[0012] The distance from the neighbor node to the sink is used to judge the access status of other nodes in the child thread. Based on the judgment result and the point-in-polygon algorithm, the closure structure between the neighbor node and the forked node and the position of the neighbor node in the closure structure are checked to obtain the access status of the neighbor node.
[0013] According to the visited status of neighbor nodes and the node properties of neighbor nodes, neighbor nodes are added to the minimum path, and the minimum path is used to update the candidate minimum path set to obtain the final minimum path set.
[0014] In one embodiment, if the current node is a sink, then stop traversing other nodes in the sub-thread; if all neighboring nodes of the current node have been visited, then determine whether the current node is the root node in the sub-thread, and stop traversing other nodes in the sub-thread or backtrack to the previous node based on the determination result.
[0015] In one of the embodiments, a sink is determined for an unvisited neighbor node. If the neighbor node is a sink, the sink is used to update the initial minimum path set, and a candidate minimum path set is obtained and outputted.
[0016] In one of the embodiments, the nodes in the network to be searched are initialized, the minimum path of the network to be searched is set to an empty set and a double-ended queue is used to represent the minimum path to obtain an initial minimum path set; the network to be searched is represented by a node-based adjacency list to obtain the distance from each node to the sink.
[0017] In one embodiment, before determining the access status of other nodes in the child thread by using the distance from the neighbor node to the sink, and checking whether a closure structure is included between the neighbor node and the forked node and the position of the neighbor node in the closure structure according to the determination result and the point-in-polygon algorithm, and obtaining the access status of the neighbor node, the method further includes:
[0018] Determine whether the neighbor node is a neighbor node of the forked node. If the neighbor node is a neighbor node of the forked node and the distance from the neighbor node to the forked node is greater than 3, then determine that the path from the neighbor node to the forked node contains a closure structure.
[0019] In one embodiment, the distance from the neighbor node to the sink is used to judge the access status of other nodes in the child thread, and according to the judgment result and the point-in-polygon algorithm, whether the neighbor node and the forked node contain a closure structure and the position of the neighbor node in the closure structure are checked to obtain the access status of the neighbor node, including:
[0020] If the distance from the neighbor node to the sink is k, the nodes at a distance k-1 from the sink have not all been visited, and the neighbor node is a neighbor node of the fork node, then it is determined that a closure structure is contained between the neighbor node and the fork node;
[0021] According to the algorithm of the point in the polygon, the position of the neighbor node in the closure structure is checked to obtain the visited status of the neighbor node.
[0022] In one embodiment, the position of the neighbor node in the closure structure is checked according to the point-in-polygon algorithm to obtain the visited status of the neighbor node, including:
[0023] According to the algorithm of the point in the polygon, the neighbor node is checked to be within the closure structure, and the visited state of the neighbor node is that it does not need to be visited.
[0024] In one of the embodiments, according to the visited state of the neighbor node and the node properties of the neighbor node, the neighbor node is added to the minimum path, and the candidate minimum path set is updated using the minimum path to obtain the final minimum path set, including: if the visited state of the neighbor node is that it needs to be visited and the neighbor node is not a neighbor node of the fork node, the neighbor node is added to the minimum path, and the candidate minimum path set is updated using the minimum path to obtain the final minimum path set.
[0025] An improved minimum path set search device, the device comprising:
[0026] A preprocessing module is used to obtain a network to be searched; the network to be searched includes multiple nodes;
[0027] Preprocess the search network to obtain the initial minimum path set and the distance from each node to the sink;
[0028] A traversal module is used to traverse from the starting point of the network to be searched to obtain a current node with at least two unvisited neighbor nodes; the starting point is any node in the network to be searched; a plurality of sub-threads are created corresponding to the number of unvisited neighbor nodes of the current node, and the neighbor nodes are traversed in the sub-threads respectively to obtain at least one unvisited neighbor node;
[0029] The initial minimum path set update module is used to judge the sink of the unvisited neighbor nodes, and update the initial minimum path set according to the judgment result to obtain the candidate minimum path set;
[0030] The closure structure judgment module is used to detect neighbor nodes. If the neighbor node is not included in the candidate minimum path set, the distance from the neighbor node to the sink is obtained, and the access status of other nodes in the child thread is judged by using the distance from the neighbor node to the sink. According to the judgment result and the point-in-polygon algorithm, whether the closure structure is contained between the neighbor node and the fork node and the position of the neighbor node in the closure structure are checked to obtain the access status of the neighbor node;
[0031] The module for obtaining the final minimum path set is used to add neighbor nodes to the minimum path according to the visited status of the neighbor nodes and the node properties of the neighbor nodes, and use the minimum path to update the candidate minimum path set to obtain the final minimum path set.
[0032] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0033] Obtain a network to be searched; the network to be searched includes multiple nodes;
[0034] Preprocess the search network to obtain the initial minimum path set and the distance from each node to the sink;
[0035] Traverse from the starting point of the network to be searched to obtain a current node with at least two unvisited neighbor nodes; the starting point is any node in the network to be searched;
[0036] Create multiple sub-threads according to the number of unvisited neighbor nodes of the current node, and traverse the neighbor nodes in the sub-threads respectively to obtain at least one unvisited neighbor node;
[0037] Perform sink judgment on the unvisited neighbor nodes, update the initial minimum path set according to the judgment result, and obtain the candidate minimum path set;
[0038] Check the neighbor node. If the neighbor node is not included in the candidate minimum path set, obtain the distance from the neighbor node to the sink.
[0039] The distance from the neighbor node to the sink is used to judge the access status of other nodes in the child thread. Based on the judgment result and the point-in-polygon algorithm, the closure structure between the neighbor node and the forked node and the position of the neighbor node in the closure structure are checked to obtain the access status of the neighbor node.
[0040] According to the visited status of neighbor nodes and the node properties of neighbor nodes, neighbor nodes are added to the minimum path, and the minimum path is used to update the candidate minimum path set to obtain the final minimum path set.
[0041] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0042] Obtain a network to be searched; the network to be searched includes multiple nodes;
[0043] Preprocess the search network to obtain the initial minimum path set and the distance from each node to the sink;
[0044] Traverse from the starting point of the network to be searched to obtain a current node with at least two unvisited neighbor nodes; the starting point is any node in the network to be searched;
[0045] Create multiple sub-threads according to the number of unvisited neighbor nodes of the current node, and traverse the neighbor nodes in the sub-threads respectively to obtain at least one unvisited neighbor node;
[0046] Perform sink judgment on the unvisited neighbor nodes, update the initial minimum path set according to the judgment result, and obtain the candidate minimum path set;
[0047] Check the neighbor node. If the neighbor node is not included in the candidate minimum path set, obtain the distance from the neighbor node to the sink.
[0048] The distance from the neighbor node to the sink is used to judge the access status of other nodes in the child thread. Based on the judgment result and the point-in-polygon algorithm, the closure structure between the neighbor node and the forked node and the position of the neighbor node in the closure structure are checked to obtain the access status of the neighbor node.
[0049] According to the visited status of neighbor nodes and the node properties of neighbor nodes, neighbor nodes are added to the minimum path, and the minimum path is used to update the candidate minimum path set to obtain the final minimum path set.
[0050] The above-mentioned improved minimum path set search method, device, computer equipment and storage medium, the present application proposes a new backtracking condition based on the closure structure, uses the distance from the neighbor node to the sink to judge the access status of other nodes in the child thread during the minimum path set search, and checks whether the closure structure is contained between the neighbor node and the fork node and the position of the neighbor node in the closure structure based on the judgment result and the algorithm of the point in the polygon to obtain the access status of the neighbor node. By reducing the access to unnecessary access nodes in the search network, the time complexity of the backtracking condition is reduced, the search amount of nodes is reduced, and the efficiency of the minimum path set search is improved. In addition, a parallel mechanism is introduced into the minimum path set search, and multiple path sets are searched at the same time, thereby improving the efficiency of the minimum path set search. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A schematic diagram of a flow chart of an improved minimum path set search method in an embodiment;
[0052] Figure 2 is a schematic diagram of a network with coordinates in one embodiment;
[0053] Figure 3 is a schematic diagram of a typical grid network in one embodiment;
[0054] Figure 4 is a schematic diagram of ratios on networks of different sizes according to another embodiment;
[0055] Figure 5 is a schematic diagram of a Benchmark network in one embodiment;
[0056] Figure 6 A schematic diagram of a 6*6 grid network in one embodiment;
[0057] Figure 7 is a schematic diagram of a single-source-multiple-sink network in one embodiment;
[0058] Figure 8 A schematic diagram of the ratio of a single-source-multiple-sink network in one embodiment;
[0059] Fig. 9 A schematic diagram of ratio changes on a multi-source single-sink network in one embodiment;
[0060] Fig.10 A schematic diagram of a single-source multi-sink network in another embodiment;
[0061] Fig.11 is a schematic diagram of a multi-source multi-sink network in one embodiment;
[0062] Fig.12is a structural block diagram of an improved minimum path set searching device in an embodiment;
[0063] Fig.13 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0065] In one embodiment, Figure 1 As shown, an improved minimum path set search method is provided, comprising the following steps:
[0066] Step 102, obtaining a network to be searched; the network to be searched includes a plurality of nodes; preprocessing the network to be searched to obtain an initial minimum path set and a distance from each node to a sink.
[0067] The network to be searched can be a transportation network for transporting materials. Taking the transportation network as an example, the transfer stations in the transportation network for transporting materials are nodes in the network to be searched. Finding the minimum path set in the transportation network for transporting materials can find all the minimum paths in the transportation network, provide multiple feasible solutions for path planning, and improve the efficiency of material transportation. Preprocessing the network to be searched includes rasterizing the network, obtaining the horizontal and vertical coordinates of the nodes in the network, representing the network with a node-based adjacency list, and calculating the distance from each node to the sink.
[0068] Step 104, traverse from the starting point of the network to be searched to obtain a current node with at least two unvisited neighbor nodes; the starting point is any node in the network to be searched; create multiple sub-threads according to the number of unvisited neighbor nodes of the current node, and traverse the neighbor nodes in the sub-threads respectively to obtain at least one unvisited neighbor node.
[0069] Start traversing from the starting point of the network to be searched, traversing the current node to be visited Until it has two or more unvisited neighbor nodes, update the distance check list S, s i =s i +1, The number of u's neighbor nodes is denoted as N. The neighbor nodes that u has not visited are denoted as u a0 ,u a1 ,…,u aN,Create multiple sub-threads according to the number of neighbor nodes. Create N sub-threads, thread-1, thread-2, ..., thread-N. According to the thread label j = 1, 2, ... N, S, P, flag, u aj is passed to each thread, u aj It is the root node of this thread. By creating multiple parallel sub-threads to search for the minimum path set at the same time, the search efficiency of the minimum path set is improved.
[0070] Step 106, performing sink determination on the unvisited neighbor nodes, and updating the initial minimum path set according to the determination result to obtain a candidate minimum path set.
[0071] A neighbor node refers to a node that is adjacent to the current node and is traversed. A sink is determined for unvisited neighbor nodes. A sink refers to the end point of a path. If a neighbor node is a sink, a minimum path has been found, that is, the path from the current node to the sink is a minimum path. The initial minimum path set is updated based on the minimum path, and then the previous node of the neighbor node is traced back to re-traverse the other nodes in the sub-thread.
[0072] Step 108, detect the neighbor node, if the neighbor node is not included in the candidate minimum path set, obtain the distance from the neighbor node to the sink; use the distance from the neighbor node to the sink to judge the access status of other nodes in the child thread, and check whether the closure structure is contained between the neighbor node and the fork node and the position of the neighbor node in the closure structure based on the judgment result and the algorithm of the point in the polygon to obtain the access status of the neighbor node.
[0073] The neighbor nodes are checked. If the neighbor nodes are not included in the current minimum path of the candidate minimum path set, the distance from the neighbor nodes to the sink is obtained. The position of the neighbor node in the closure structure refers to whether the neighbor node is included in the closure structure. If so, the access status of the neighbor node is judged as not needing to be visited. If not, it is judged whether the neighbor node is a neighbor node of the forked node, and the candidate minimum path set is updated according to the judgment result. By introducing the closure structure to judge the nodes in the search network, the nodes that are unnecessary to visit are found, the number of nodes visited and the time complexity of the backtracking condition are reduced, and the search efficiency of the minimum path set is improved.
[0074] Step 110, according to the visited state of the neighbor node and the node property of the neighbor node, the neighbor node is added to the minimum path, and the candidate minimum path set is updated using the minimum path to obtain the final minimum path set.
[0075] A fork node refers to a node with multiple exit branches. The node property of a neighbor node refers to which node the neighbor node is a neighbor of. If the visited state of the neighbor node is that it needs to be visited and the neighbor node is not a neighbor node of the fork node, the neighbor node is added to the candidate minimum path set to obtain the final minimum path set.
[0076] In the above-mentioned improved minimum path set search method, the present application proposes a new backtracking condition based on the closure structure. When searching the minimum path set, the distance from the neighbor node to the sink is used to judge the visited status of other nodes in the child thread. According to the judgment result and the algorithm of the point in the polygon, whether the closure structure is contained between the neighbor node and the fork node and the position of the neighbor node in the closure structure are checked to obtain the visited status of the neighbor node. By reducing the access to unnecessary visited nodes in the search network, the time complexity of the backtracking condition is reduced, the search amount of nodes is reduced, and the efficiency of the minimum path set search is improved. In addition, a parallel mechanism is introduced into the minimum path set search, and multiple path sets are searched at the same time, thereby improving the efficiency of the minimum path set search.
[0077] In one of the embodiments, the nodes in the network to be searched are initialized, the minimum path set of the network to be searched is set to an empty set and the minimum path set is represented by a double-ended queue to obtain an initial minimum path set; the network to be searched is represented by a node-based adjacency list to obtain the distance from each node to the sink.
[0078] Preprocessing the search network includes rasterizing the network, obtaining the horizontal and vertical coordinates of the nodes in the network, representing the network with a node-based adjacency list, and calculating the distance from each node to the sink, denoted as L. d , calculate the set of points with the same distance from the sink, denoted as d max is max(L d ), initialize the current node u, the set of minimum path sets Use a double-ended queue to represent P. The advantage of a double-ended queue is that you can add elements from the head of the queue or from the tail of the queue. If you start searching from the source, add elements from the head of the queue. If you start searching from the sink, add elements from the tail of the queue. Initialize the distance check list. All elements in S are set to 0, s i =0,1,…d max is the number of points with a distance i from the sink. Initialize flag = false. Flag represents whether a closure structure is formed. False means that no closure structure is formed. Then initialize C represents a closure structure.
[0079] In one embodiment, if the current node is a sink, then stop traversing other nodes in the sub-thread; if all neighboring nodes of the current node have been visited, then determine whether the current node is the root node in the sub-thread, and stop traversing other nodes in the sub-thread or backtrack to the previous node based on the determination result.
[0080] In each thread, if u aj is a sink, then this thread ends and stops traversing the nodes in the child thread, otherwise set u = u aj ,Update the distance check list S,s i =s i +1,i=L d (u), and update the minimum path set P at the same time, P = P∪u.
[0081] If all neighbor nodes of the current node have been visited, check the following conditions: If u = u aj , then stop traversing other nodes in the child thread, if u≠u aj Then backtrack to the previous node and traverse the nodes again. The previous node refers to the previous node of the current node in the network to be searched. The backtracking condition is: if the distance between the node v to be visited and the sink is d, and all nodes with a distance of d-1 from the sink have been visited, then node v is unnecessary to visit.
[0082] In one of the embodiments, a sink is determined for an unvisited neighbor node. If the neighbor node is a sink, the sink is used to update the initial minimum path set, and a candidate minimum path set is obtained and outputted.
[0083] The sink point of the unvisited neighbor node is judged. If the neighbor node is a sink point, a minimum path has been found. The initial minimum path set is updated according to the minimum path, and then backtracking to the previous node of the neighbor node is retraversed until all nodes in the sub-thread are traversed.
[0084] In one embodiment, before determining the access status of other nodes in the child thread by using the distance from the neighbor node to the sink, and checking whether a closure structure is included between the neighbor node and the forked node and the position of the neighbor node in the closure structure according to the determination result and the point-in-polygon algorithm, and obtaining the access status of the neighbor node, the method further includes:
[0085] Determine whether the neighbor node is a neighbor node of the forked node. If the neighbor node is a neighbor node of the forked node and the distance from the neighbor node to the forked node is greater than 3, then determine that the path from the neighbor node to the forked node contains a closure structure.
[0086] In one embodiment, the distance from the neighbor node to the sink is used to judge the access status of other nodes in the child thread, and according to the judgment result and the point-in-polygon algorithm, whether the neighbor node and the forked node contain a closure structure and the position of the neighbor node in the closure structure are checked to obtain the access status of the neighbor node, including:
[0087] If the distance from the neighbor node to the sink is k, the nodes at a distance k-1 from the sink have not all been visited, and the neighbor node is a neighbor node of the fork node, then it is determined that a closure structure is contained between the neighbor node and the fork node;
[0088] According to the algorithm of the point in the polygon, the position of the neighbor node in the closure structure is checked to obtain the visited status of the neighbor node.
[0089] If the distance from the neighbor node to the sink is k, and the nodes at a distance k-1 from the sink have been visited, then backtrack to the previous node of the neighbor node being visited and revisit it.
[0090] In one embodiment, the position of the neighbor node in the closure structure is checked according to the point-in-polygon algorithm to obtain the visited status of the neighbor node, including:
[0091] According to the algorithm of the point in the polygon, the neighbor node is checked to be within the closure structure, and the visited state of the neighbor node is that it does not need to be visited.
[0092] If flag = true, it means that the candidate minimum path set contains a closure structure. According to the algorithm of the point in the polygon, check the neighbor nodes Is it in the closure structure C. If In an irregular polygon, It is unnecessary to visit. In addition, if all neighbor nodes of u have been visited, set flag = false. If u = u aj , then stop traversing the nodes in the child thread, if u≠u aj Then go back to the previous node and traverse the nodes again.
[0093] In one of the embodiments, according to the visited state of the neighbor node and the node properties of the neighbor node, the neighbor node is added to the minimum path, and the candidate minimum path set is updated using the minimum path to obtain the final minimum path set, including: if the visited state of the neighbor node is that it needs to be visited and the neighbor node is not a neighbor node of the fork node, the neighbor node is added to the minimum path, and the candidate minimum path set is updated using the minimum path to obtain the final minimum path set.
[0094] if is u bf Neighbor nodes of (fork node), The length is greater than 3, indicating It forms a closure structure. flag=true, if Neighbor nodes that are not forked nodes will Add to the path set P, Get the final minimum path set. Update the check list S, set s i =s i +1,
[0095] In one embodiment, Figure 2 As shown, let n0 be the starting point, n 19 The process of searching for the minimum path set using the method proposed by the present invention is as follows:
[0096] Step 1: Obtain a network to be searched; the network to be searched includes multiple nodes; and preprocess the network to be searched;
[0097] Step 1.1: Grid the network to be searched and obtain the horizontal and vertical coordinates of the nodes. Network L = {[n1,n4], [n0,n2,n5], ... [n 15 ,n 18 ]}, each node contains three attributes, such as They represent the horizontal coordinate, vertical coordinate and number of the node respectively.
[0098] Step 1.2: Calculate the distance from each node to the sink, which is L d ={6,5,4,3,5,4…1,0}, and then calculate the number of points with the same distance to the sink.
[0099] Step 1.3: Initialize the starting point and current point u=n0, the initial minimum path set Initial distance check list S = {0,0,0,0,0,0,0}, flag = false,
[0100] Step 2: Since n0 has two neighbor nodes n1 and n4, u bf =u=n0. Update S, s6=s6+1=0+1=1,P=P∪n0={n0}. Then create two sub-threads to search for MPs, thread-1, thread-2, and then pass n1, n4, P, S, flag, C to each sub-thread respectively.
[0101] The following process is thread-1.
[0102] Step 3: because Then update P = {n0, n1}. Update S, s5 = s5 + 1 = 0 + 1 = 1, S = {0, 0, 0, 0, 1, 1}. Then set
[0103] Step 4: Select a neighbor node of the current node u that has not been visited
[0104] Step 5: Because and S[3]=0!=Q[3]=4,flag=false,n2 is not u bf Neighbor nodes, then add To P, P = {n0, n1, n2}, update S, s4=s4+1=0+1=1,S={0,0,0,0,1,1,1}, then let
[0105] Then add n6, n5, n9 to the path set in the same way and update S,u,flag.
[0106] Step 4: Select an unselected neighbor node of the current node u.
[0107] Step 5: Because S[3]=2!=Q[3]=4,flag=false,n8 is not u bf Neighbor nodes, then add To P, P = {n0, n1, n2, n6, n5, n9, n8}, update S, s3=s3+1=0+1=1,S={0,0,0,2,3,1,1}, then let
[0108] Step 4: Select the current node u as an unselected node
[0109] Step 5. Because (S[4]=3)=(Q[4]=3), so n4 is unnecessary to access.
[0110] The following search process is the search process of process 2.
[0111] Step 3: Because Then P = {n0, n4}. Update S, s5=s5+1=0+1=1,S={0,0,0,0,0,1,1}. Then set
[0112] Step 4: Select a neighbor node that is not selected by the current node u
[0113] Step 5: Because S[3]=0!=Q[3]=4,flag=false,n8 is u bf Neighbor nodes of To the path set P, P = {n0, n4, n8}. Update S, s4=s4+1=0+1=1,S={0,0,0,0,1,1,1}, let
[0114] Then the path set is added in the same way n9,n 10 ,n6,Update S,u,flag.
[0115] Step 4: Select a neighbor node that is not selected by the current node u
[0116] Step 5: Because S[3]=2!=Q[3]=4,flag=false,n2 is not u bf Therefore, add node n2 to P, P={n0,n4,n8,n9,n 10 ,n6,n2}. Update S, s4=s4+1=1+1=2,S={0,0,1,2,2,1,1}. Then set
[0117] Step 4: Select a neighbor node that is not selected by the current node u
[0118] Step 5: Because S[4] = 4! = Q[4] = 2, flag = false, then add To the path set P, P={n0,n4,n8,n9,n 10 ,n6,n2,n1}. Update S, s5=s5+1=1+1=2,S={0,0,1,2,2,2,1}. Because n1 is u bf The length of C is greater than 3, so set flag = true. Then set
[0119] Step 4: Select a neighbor node that is not selected by the current node u
[0120] Step 5: Because S[3]=4! =Q[3]=2,flag=true,C={n0,n4,n8,n9,n 10 ,n6,n2,n1}, we can get n5 is in C according to the algorithm of the midpoint in the polygon in part 1. Therefore, n5 is unnecessary to visit.
[0121] The search process continues until all MPs are found. The minimum number of paths found is 976.
[0122] In order to verify the technical effect of the present invention, it is specifically described from the following two aspects:
[0123] 1. Complexity analysis:
[0124] Let V represent the set of nodes. The space complexity of the method proposed in the present invention is O(4(|V|-1)), including an input list L with a length of (|V|-1), a distance check list Q with a length of (|V|-1) in the worst case, a closure structure C with a length of (|V|-1) in the worst case, and a distance check list S with a length of (|V|-1).
[0125] For the time complexity, η represents the average number of nodes in a path set, and π represents the number of minimum path sets MPs. represents the number of cycles detected in the proposed algorithm. The time complexity of Bai's backtracking condition is O(n), where n is the length of the set Q of points with the same distance from the sink. Q will grow as the size of the network grows. Every time a new node is visited, the algorithm checks whether the backtracking condition is met. The time complexity of Bai's algorithm is The time complexity of the backtracking condition proposed by the present invention is only O(1). At the same time, there are also some points surrounded by the closure structure. The present invention reduces the search of these points, which are recorded as In addition, the MPs obtained on different branches from a forked node are completely different, so the search for the minimum path set can be divided into several independent sub-problems. Let s represent the number of sub-problems, that is, the number of sub-threads. The complexity of the sub-problem is 1 / s of the original problem. Therefore, the time complexity of the proposed method is The time complexity of the method proposed in the present invention is lower than that of the Bai algorithm.
[0126] 2. Efficiency comparison
[0127] The efficiency of the method proposed in the present invention in two-terminal networks and multi-source and multi-sink networks. For efficiency, people are most concerned about time. This section compares the time efficiency of the proposed method and Bai's algorithm. The computer used is a personal computer with an I7, 2.60GHz CPU, 8 cores and 32GB of RAM. The algorithm is coded in Python. The recorded indicator is a ratio, which is defined as the ratio of the time consumed by the Bai algorithm to the time consumed by the proposed method. This indicator shows the advantage of the proposed method over Bai's algorithm. In addition, this method can be extended to multi-source and multi-sink networks. The coordinates of the acquired points are obtained through a plane network layout algorithm to obtain a typical grid network, such as Figure 3 The time consumed by the proposed method is shown in Table 1.
[0128] Table 1
[0129]
[0130]
[0131] It can be seen that the time consumed by the method proposed in the present invention is less than the time consumed by Bai's algorithm. Figure 4 The ratio changes with the network size. It can be seen that the rate change trend shows a linear trend, that is, the method proposed in the present invention becomes more advantageous as the network size increases. Then consider a network such as Figure 5 As shown in the figure, the total number of MPs obtained by the proposed algorithm is 780, which is consistent with the number of MPs obtained by the Bai algorithm. The CPU time consumed by the Bai algorithm is 0.0469s, and the time consumed by the method of the present invention is 0.0252s. The ratio is 1.86, and the method proposed by the present invention has more advantages.
[0132] In the real network, there are many source-multiple-sink networks, including single-source-multiple-sink networks, multi-source-single-sink networks, and multi-source-multiple-sink networks. The present invention searches for path sets by adding virtual source points, sinks, and edges to the multi-source-multiple-sink network. Figure 6 As shown in Figure 1, a 6*6 grid network is used as the experimental object to compare the efficiency of the method proposed by the present invention and the Bai algorithm. First, consider a network with multiple source points and a single sink point as shown in Figure 7 For this type of network, add a virtual starting point and then add a virtual edge between the virtual starting point and the source point. For example, let s1 and s2 be the starting points and t1 be the end point. Add a virtual starting point s v , and then respectively in s vAdd virtual edges between s1 and s2. The time consumed by the method proposed in the present invention and the time consumed by Bai's algorithm are shown in Table 2. It can be seen that the time consumed by the algorithm proposed in the present invention is less than the time consumed by Bai's algorithm. Figure 8 and Fig. 9 It can be seen that as the number of source points increases, the ratio shows a linear change trend. This phenomenon can be explained by the fact that as the number of source points increases, the number of sub-threads executing the path set search task will also increase, so the efficiency will change linearly with the change of source points.
[0133] Table 2
[0134]
[0135]
[0136] like Fig.10 The figure shows a single-source multi-sink network. For this type of network, add a virtual sink and then add virtual edges between the virtual sinks. For example, let t1 and t2 be sinks, the source be s1, and add a virtual sink t v Then at t1, t2 and t v For this type of network, search from the sink to the starting point, and change the order of adding elements to the path set P. Because P is a double-ended queue, you can add elements to the head of the queue or to the tail of the queue. Because the structure of the network is symmetrical, the CPU time consumed by the algorithm is proportional to Fig. 9 Consistent.
[0137] like Fig.11 The figure shows a multi-source multi-sink network. For this type of network, add a virtual starting point s v , then in s v Next, add a virtual sink t v Then at t v Add virtual edges between the source and sink. Add a pair of source and sink at a time. Before the search starts, compare the number of source points and the number of sinks. If the number of source points is greater than the number of sinks, start the search from the starting point, otherwise start the search from the sink.
[0138] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0139] In one embodiment, Fig.12 As shown, an improved minimum path set search device is provided, comprising: a preprocessing module 202, a traversal module 204, an initial minimum path set update module 206, a closure structure judgment module 208 and a final minimum path set acquisition module 210, wherein:
[0140] The preprocessing module 202 is used to obtain a network to be searched; the network to be searched includes multiple nodes; the network to be searched is preprocessed to obtain an initial minimum path set and a distance from each node to a sink;
[0141] The traversal module 204 is used to traverse from the starting point of the network to be searched to obtain a current node with at least two unvisited neighbor nodes; the starting point is any node in the network to be searched; a plurality of sub-threads are created according to the number of unvisited neighbor nodes of the current node, and the neighbor nodes are traversed in the sub-threads respectively to obtain at least one unvisited neighbor node;
[0142] The initial minimum path set updating module 206 is used to perform sink point judgment on the unvisited neighbor nodes, and update the initial minimum path set according to the judgment result to obtain a candidate minimum path set;
[0143] The closure structure judgment module 208 is used to detect the neighbor node. If the neighbor node is not included in the candidate minimum path set, the distance from the neighbor node to the sink is obtained; the access status of other nodes in the child thread is judged by the distance from the neighbor node to the sink. According to the judgment result and the algorithm of the point in the polygon, whether the closure structure is included between the neighbor node and the fork node and the position of the neighbor node in the closure structure are checked to obtain the access status of the neighbor node;
[0144] The final minimum path set acquisition module 210 is used to add neighbor nodes to the minimum path according to the access status of the neighbor nodes and the node properties of the neighbor nodes, and use the minimum path to update the candidate minimum path set to obtain the final minimum path set.
[0145] In one embodiment, if the current node is a sink, then stop traversing other nodes in the sub-thread; if all neighboring nodes of the current node have been visited, then determine whether the current node is the root node in the sub-thread, and stop traversing other nodes in the sub-thread or backtrack to the previous node based on the determination result.
[0146] In one embodiment, the initial minimum path set updating module 206 is further used to perform sink point judgment on the neighboring nodes that have not been visited. If the neighboring node is a sink point, the sink point is used to update the initial minimum path set to obtain a candidate minimum path set for output.
[0147] In one embodiment, the preprocessing module 202 is also used to initialize the nodes in the network to be searched, set the minimum path set of the network to be searched to an empty set and represent the minimum path set with a double-ended queue to obtain an initial minimum path set; represent the network to be searched according to a node-based adjacency list to obtain the distance from each node to the sink.
[0148] In one of the embodiments, in one of the embodiments, the access status of other nodes in the child thread is judged by using the distance from the neighbor node to the sink node, and whether a closure structure is contained between the neighbor node and the forked node and the position of the neighbor node in the closure structure are checked according to the judgment result and the algorithm of the point in the polygon, before obtaining the access status of the neighbor node, it also includes: judging whether the neighbor node is a neighbor node of the forked node, if the neighbor node is a neighbor node of the forked node, and the distance from the neighbor node to the forked node is greater than 3, then it is determined that the path from the neighbor node to the forked node contains a closure structure.
[0149] In one of the embodiments, the closure structure judgment module 208 is also used to judge the access status of other nodes in the child thread by using the distance from the neighbor node to the sink point, and check whether the closure structure is contained between the neighbor node and the fork node and the position of the neighbor node in the closure structure according to the judgment result and the point-in-polygon algorithm to obtain the access status of the neighbor node, including: if the distance from the neighbor node to the sink point is k, the nodes at a distance k-1 from the sink point have not all been visited, and the neighbor node is a neighbor node of the fork node, then it is judged that the closure structure is contained between the neighbor node and the fork node; the position of the neighbor node in the closure structure is checked according to the point-in-polygon algorithm to obtain the access status of the neighbor node.
[0150] In one of the embodiments, the closure structure judgment module 208 is also used to check the position of the neighbor node in the closure structure according to the algorithm of the point in the polygon to obtain the access status of the neighbor node, including: checking whether the neighbor node is within the closure structure according to the algorithm of the point in the polygon, then the access status of the neighbor node is that it does not need to be visited.
[0151] In one of the embodiments, the module 210 for obtaining the final minimum path set is also used to add neighbor nodes to the minimum path according to the visited status of the neighbor nodes and the node properties of the neighbor nodes, and use the minimum path to update the candidate minimum path set to obtain the final minimum path set, including: if the visited status of the neighbor node is that it needs to be visited and the neighbor node is not a neighbor node of the fork node, then the neighbor node is added to the minimum path, and the candidate minimum path set is updated using the minimum path to obtain the final minimum path set.
[0152] For the specific definition of an improved minimum path set search device, please refer to the definition of an improved minimum path set search method above, which will not be repeated here. Each module in the above-mentioned improved minimum path set search device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0153] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig.13 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer 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 computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an improved minimum path set search method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0154] Those skilled in the art will understand that Fig.13 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0155] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method in the above embodiment when executing the computer program.
[0156] In one embodiment, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method in the above embodiment are implemented.
[0157] 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 in this application 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).
[0158] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0159] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. An improved minimum path set search method, characterized in that: The method comprises: Acquire a network to be searched; the network to be searched includes a plurality of nodes; the network to be searched is a transportation network for transporting materials, and the transfer stations in the transportation network for transporting materials are nodes in the network to be searched, and finding the minimum path set in the transportation network for transporting materials can find all the minimum paths in the transportation network; Preprocessing the network to be searched to obtain an initial minimum path set and a distance from each node to a sink; Traversing from the starting point of the network to be searched, obtaining a current node having at least two unvisited neighbor nodes; the starting point is any node in the network to be searched; Creating a plurality of sub-threads according to the number of unvisited neighbor nodes of the current node, and traversing the neighbor nodes in the sub-threads respectively to obtain at least one unvisited neighbor node; Performing sink point judgment on the unvisited neighbor nodes, and updating the initial minimum path set according to the judgment result to obtain a candidate minimum path set; Detecting the neighbor node, and if the neighbor node is not included in the candidate minimum path set, obtaining the distance from the neighbor node to the sink; The access status of other nodes in the sub-thread is judged by using the distance from the neighbor node to the sink, and whether a closure structure is contained between the neighbor node and the forked node and the position of the neighbor node in the closure structure are checked according to the judgment result and the algorithm of the point being in the polygon, so as to obtain the access status of the neighbor node; According to the visited state of the neighbor node and the node property of the neighbor node, the neighbor node is added to the minimum path, and the candidate minimum path set is updated by using the minimum path to obtain a final minimum path set.
2. The method according to claim 1, characterized in that The method further comprises: If the current node is a sink, stop traversing other nodes in the subthread; If all neighboring nodes of the current node have been visited, it is determined whether the current node is the root node in the sub-thread, and according to the determination result, the traversal of other nodes in the sub-thread is stopped or backtracked to the previous node.
3. The method according to claim 2, characterized in that Performing a sink judgment on the unvisited neighbor nodes, and updating the initial minimum path set according to the judgment result to obtain a candidate minimum path set, including: A sink point judgment is performed on the unvisited neighbor node. If the neighbor node is a sink point, the initial minimum path set is updated using the sink point to obtain a candidate minimum path set for output.
4. The method according to claim 3, characterized in that Preprocess the network to be searched to obtain an initial minimum path set and a distance from each node to the sink, including: Initialize the nodes in the network to be searched, set the minimum path set of the network to be searched to an empty set and represent the minimum path with a double-ended queue to obtain an initial minimum path set; The network to be searched is represented according to a node-based adjacency list, and the distance from each node to the sink is obtained.
5. The method according to claim 4, characterized in that Before determining the access status of other nodes in the child thread by using the distance from the neighbor node to the sink, and checking whether a closure structure is included between the neighbor node and the forked node and the position of the neighbor node in the closure structure according to the determination result and the point-in-polygon algorithm, and obtaining the access status of the neighbor node, the method further includes: It is determined whether the neighbor node is a neighbor node of the forked node. If the neighbor node is a neighbor node of the forked node and the distance from the neighbor node to the forked node is greater than 3, it is determined that the path from the neighbor node to the forked node contains a closure structure.
6. The method according to claim 5, characterized in that The access status of other nodes in the subthread is judged by using the distance from the neighbor node to the sink, and whether a closure structure is contained between the neighbor node and the forked node and the position of the neighbor node in the closure structure are checked according to the judgment result and the algorithm of the point being in the polygon, to obtain the access status of the neighbor node, including: If the distance from the neighbor node to the sink is k, the nodes at a distance k-1 from the sink have not all been visited, and the neighbor node is a neighbor node of the fork node, then it is determined that a closure structure is contained between the neighbor node and the fork node; The position of the neighbor node in the closure structure is checked according to the point-in-polygon algorithm to obtain the access status of the neighbor node.
7. The method according to claim 6, characterized in that The position of the neighbor node in the closure structure is checked according to the point-in-polygon algorithm to obtain the access status of the neighbor node, including: According to the algorithm of the point in the polygon, it is checked that the neighbor node is in the closure structure, and the visited state of the neighbor node is that it does not need to be visited.
8. The method according to claim 7, characterized in that According to the visited state of the neighbor node and the node property of the neighbor node, the neighbor node is added to the minimum path, and the candidate minimum path set is updated by using the minimum path to obtain the final minimum path set, including: If the visited state of the neighbor node is that it needs to be visited and the neighbor node is not a neighbor node of the fork node, the neighbor node is added to the minimum path, and the candidate minimum path set is updated using the minimum path to obtain a final minimum path set.
9. An improved minimum path set search device, characterized in that: The device comprises: A preprocessing module is used to obtain a network to be searched; the network to be searched includes a plurality of nodes; the network to be searched is a transportation network for transporting materials, and the transfer stations in the transportation network for transporting materials are nodes in the network to be searched. Finding the minimum path set in the transportation network for transporting materials can find all the minimum paths in the transportation network; Preprocessing the network to be searched to obtain an initial minimum path set and a distance from each node to a sink; A traversal module, configured to traverse from a starting point of the network to be searched to obtain a current node having at least two unvisited neighbor nodes; the starting point is any node in the network to be searched; a plurality of sub-threads are created corresponding to the number of unvisited neighbor nodes of the current node, and the neighbor nodes are traversed in the sub-threads respectively to obtain at least one unvisited neighbor node; An initial minimum path set updating module is used to perform a sink judgment on the unvisited neighbor nodes, and update the initial minimum path set according to the judgment result to obtain a candidate minimum path set; A closure structure judgment module is used to detect the neighbor node, and if the neighbor node is not included in the candidate minimum path set, obtain the distance from the neighbor node to the sink; use the distance from the neighbor node to the sink to judge the access status of other nodes in the sub-thread, and check whether the closure structure is included between the neighbor node and the fork node and the position of the neighbor node in the closure structure according to the judgment result and the algorithm of the point in the polygon, so as to obtain the access status of the neighbor node; The module for obtaining the final minimum path set is used to add the neighbor nodes to the minimum path according to the access status of the neighbor nodes and the node properties of the neighbor nodes, and use the minimum path to update the candidate minimum path set to obtain the final minimum path set.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Multi-state network minimum path set vector repetition-free search algorithm for all requirements
CN111726254A
Process for analyzing the reliability of technical systems with the help of physical models
DE102007042752A1
