Method for calculating location of material sorting site based on clustering analysis and area method of floyd algorithm
By using the Floyd algorithm based on cluster analysis and area method to determine the location of material delivery points and large sorting sites, the efficiency and safety issues of material distribution during large-scale infectious disease outbreaks were solved, and rapid and efficient material transportation was achieved.
Patent Information
- Application Number
- CN202211715822.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2042-12-29
AI Technical Summary
During a large-scale infectious disease outbreak, how can we scientifically allocate and transport essential supplies such as vegetables to ensure they reach community residents quickly and efficiently, while minimizing human interaction and the risk of infectious disease transmission?
The Floyd algorithm, based on cluster analysis and area method, is adopted to determine the location of suitable material delivery points and large sorting sites by sorting the communities and material delivery points, thereby reducing the amount of computation and optimizing the material transportation route.
This improved the efficiency of sorting and transporting supplies, reduced computational complexity and the need for transport vehicles, ensured that supplies reached community residents on time, and reduced the risk of infectious disease transmission.
Smart Images

Figure CN116028836B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of outdoor space positioning, in particular to a position calculation method of a material sorting site based on clustering analysis and area method Floyd algorithm. BACKGROUND
[0002] According to the comprehensive analysis of relevant data, it is proved that the government has the ability to regulate and transport the living materials needed for people's life during the large-scale epidemic period. Only the way of distributing living materials to community residents is not smooth, so we must develop and manufacture a scientific and reasonable management plan to quickly and efficiently deal with it. The method of using vegetable bags plays a significant role in the effective distribution of living materials for residents during the large-scale epidemic period.
[0003] Vegetable bags are mainly based on fresh vegetables. Because vegetables are food that people need to eat every day, and the shelf life of vegetables is relatively short, the distribution and transportation of vegetables is too frequent, which leads to close interaction between personnel. Although rice, flour, oil and meat are also the most urgent and necessary living materials for residents, because their shelf life is relatively long and they are mainly government resources, their distribution work can be cross-distributed in the vegetable bag distribution process. On the other hand, fruits are also generally needed by most residents, and if they are produced but cannot be sold, it will not be conducive to economic development, so we also need to consider scientifically supplying non-essential foods such as fruits under the condition of not increasing the risk of spreading the epidemic. In view of the fact that vegetables are more prominent in terms of quantity, frequency and impact, this topic is committed to solving how to scientifically supply vegetables. SUMMARY
[0004] The technical problem solved by the present application is to provide a position calculation method of a material sorting site based on clustering analysis and area method Floyd algorithm, which solves the above technical problems.
[0005] The position calculation method of the material sorting site based on clustering analysis and area method Floyd algorithm, characterized in that it comprises the following steps:
[0006] Step 1, K-means clustering of the small cell coordinate points in the urban area, dividing the small cell coordinate points into K clusters, i.e. K areas;
[0007] Step 2, using the "area method" to screen the known intersection coordinates, retaining the intersection coordinates inside the outline of each area;
[0008] Step 3, find the suitable location of the material delivery point by traversing all the reserved intersection coordinates of the district using Floyd algorithm;
[0009] Step 4, perform K-means clustering on the locations of the material delivery points in the city, and divide the locations of the material delivery points into M clusters, i.e., M districts;
[0010] Step 5, use the "area method" to screen the known intersection coordinates, and reserve the intersection coordinates located inside the outline of the material delivery point location in each district;
[0011] Step 6, find the location of the large sorting material center by traversing all the reserved intersection coordinate locations of the district using Floyd algorithm.
[0012] Further, in steps 1 and 4, the elbow method is used to determine the values of K and M in K-means clustering.
[0013] Further, the step 2 specifically includes the following steps:
[0014] Step 2.1, for each sub-district coordinate point (x i , y i ) in the district, draw a scatter plot to find minx i , max x i , min y i , max y i , and cover the district with a smallest rectangular area ABCD, thereby obtaining the preliminary screened intersection coordinate points located in the district, which satisfy the condition:
[0015]
[0016] Step 2.2, find the sub-district edge outline points, sequentially connect the sub-district edge outline points to obtain the sub-district edge outline, and use the "area method" to further screen the preliminary screened intersection coordinates, and reserve the preliminary screened intersection coordinates located inside the sub-district edge outline.
[0017] Further, in step 2.2, the method for finding the sub-district edge outline points is:
[0018] Step 2.2.1, arbitrarily select a sub-district coordinate point point1, find a sub-district coordinate point point2 in the district that is the farthest distance from point1, and the point point2 is one of the boundary points;
[0019] Step 2.2.2, point1 and point2 form a vector v1 (point2-point1), and other points in the region form other vectors, and a vector v2 (point3-point1) with the largest angle with the vector is found from the other vectors (other point coordinates-point1), and the point point3 is one of the cell edge contour points;
[0020] Step 2.2.3, a vector v3 with the largest angle with v2 is found from the other vectors (other point coordinates-point2), and a cell edge contour point is found again, and the process is repeated until the last found vector direction is the vector of point point2, and the found cell edge contour point coordinates are retained.
[0021] Further, in step 2.2, the specific steps of the "area method" are as follows:
[0022] If the sum of the areas of the triangles formed by the intersection coordinate point and all the edges of the cell edge contour polygon is equal to the total area of the cell edge contour polygon, it is determined that the intersection coordinate point is located inside or on the cell edge contour, otherwise it is determined that the intersection coordinate point is located outside the cell edge contour.
[0023] Further, the step 3 specifically comprises the following steps:
[0024] Step 3.1, initialization matrix, write all adjacent intersection coordinate point corresponding distance into the matrix, and initialize the distance corresponding to the non-adjacent intersection coordinate point as inf;
[0025] Step 3.2, after initialization, start triple loop, each layer of loop starts from the first node and traverses until the nth node, and the current node of the outermost loop is i, the current node of the middle layer loop is j, and the current node of the inner layer loop is k, and i≠j≠k, then taking node i as the intermediate point, node j as the starting point and node k as the target point, it is judged whether the distance from the starting point j to the target point k through the intermediate point i is less than the distance from the starting point j to the target point k directly, if less, then the distance value d jk from the starting point j to the target point k is updated as d ji +d ik ;
[0026] Step 3.3, after the triple loop, the path planning is completed.
[0027] Further, in step 5, the edge contour points are found from the positions of each region material supply point, and all the edge contour points are sequentially connected to obtain the position contour of each region material supply point.
[0028] The beneficial effects of the present application are as follows:
[0029] The present application filters the intersection coordinates by clustering and area method, reduces the traversal objects of Floyd algorithm, and further reduces the calculation amount. The transport vehicle for transporting vegetable bags is transported between intersections, so the intersection can be used to approximate the cell, and the most suitable intersection position can be screened as the material drop point position. The material drop point can also be screened to obtain the position of the suitable large sorting station scientifically. BRIEF DESCRIPTION OF DRAWINGS
[0030] Figure 1 The flowchart of the present application is shown in the figure.
[0031] Figure 2 The intuitive judgment diagram of the intersection in the cell is shown in the figure.
[0032] Figure 3 The area method for judging whether the intersection is inside the district contour is shown in the figure (the left figure shows that the intersection is inside the district contour, and the right figure shows that the intersection is outside the district contour).
[0033] Figure 4 The flowchart of Floyd algorithm is shown in the figure.
[0034] Figure 5 The intersection approximates the cell. DETAILED DESCRIPTION
[0035] The principles and characteristics of the present application are described below in combination with the drawings, and the examples are only used to explain the present application, and are not used to limit the scope of the present application.
[0036] The practical problem to be solved by the present application is to provide a position calculation method of a material drop point and a large material sorting site based on clustering analysis and area method.
[0037] As shown in the figure, a position calculation method of a material drop point and a large material sorting site based on clustering analysis and area method. Figure 1 Step 1, K-means clustering is performed on the cell coordinate points in the city, and the cell coordinate points are divided into K clusters, i.e. K districts.
[0038] Step 2, the known intersection coordinates are screened by using the area method, and the intersection coordinates located inside the contour of each district are retained.
[0039] Step 3, Floyd algorithm is used to traverse all the retained intersection coordinates of the districts to find a suitable material drop point position.
[0040] Step 4, K-means clustering is performed on the material drop point positions in the city, and the material drop point positions are divided into M clusters, i.e. M districts.
[0041]
[0042] Step 5, using the "area method" to screen the known intersection coordinates, and keep the intersection coordinates located in the position contour of each district material delivery point;
[0043] Step 6, using Floyd algorithm to traverse all the intersection coordinates of the district to find the position of the large sorting material center.
[0044] Further, the K-means algorithm in step 1 (i.e. K-means clustering algorithm) is a well-known partition clustering segmentation method, and the basic idea of the partition method includes the following steps:
[0045] Given an array of N city block records with horizontal and vertical coordinates and block population, the splitting method will construct K groups, each group representing a district under the city. Obviously, K < N, and the K groups meet the following conditions:
[0046] (1) Each district contains at least one array of data records;
[0047] (2) Each array record belongs to and only belongs to one district.
[0048] For a given group K, the algorithm first gives an initial grouping method, and then changes the grouping through repeated iteration to make the grouping scheme better after each improvement. The so-called better standard is that the closer the arrays in the same group are (converged, repeated iteration to the data in the group almost without difference), and the farther the records in different groups are.
[0049] The working mechanism of K-means algorithm is as follows:
[0050] Step 2.1, first randomly select K points from the data set, each point initially represents the clustering center of each category, then calculate the distance from the remaining data to the clustering center, and assign it to the nearest class.
[0051] Step 2.2, then recalculate the average of each class, and the process is repeated constantly. If there is no significant change between adjacent two adjustments, it means that the data clustering class has converged.
[0052] Step 2.3, recalculate the mean (center object) of each cluster until the cluster center no longer changes. This division makes the following formula minimum:
[0053]
[0054] In the formula, x_i is the position of the i-th sample point; m_j is the position of the j-th cluster center.
[0055] Step 2.4, iterate the previous two steps, and check whether the classification of each array is correct in each iteration until each cluster no longer changes.
[0056] Step 2.5, cluster number determination. Here, the number of classifications directly specified from the actual situation is excluded, and the appropriate K value is found according to the sample distribution. In actual cases, we often use "elbow method" visual analysis, and the following will first briefly describe the principle logic.
[0057] The core idea of "elbow method" is that as the number of clusters K increases, the sample data will be divided more accurately, which will increase the aggregation degree of each classification cluster, thereby causing the clustering effect index SSE((sum of squared errors) to gradually decrease. When the K value is less than the optimal cluster number, the increase of the K value will greatly increase the aggregation degree of each classification cluster, so the decline amplitude of SSE will also be large; when the K value reaches the optimal cluster number, the aggregation degree obtained by increasing the K value will be greatly reduced, and the decline amplitude of SSE will be greatly reduced, and gradually tend to be flat with the continuous increase of K value. This process is reflected in the relationship diagram of K value and index SSE as a shape similar to "elbow", and the K value corresponding to this elbow is the optimal cluster number of sample data, of course, the K value determined by "elbow method" has a certain guiding effect on our classification in the actual process.
[0058] Further, the step 2 comprises the following steps:
[0059] For the cell coordinates of each area obtained in step 1, the intersection coordinates in each area are screened out by using "area method".
[0060] Step 2.1, roughly find the intersection coordinates in each area. For the cell coordinates (x i , y i ) in each area, the scatter plot is shown in the figure, find min x i , max x i , min y i , max y i , and a smallest rectangular area ABCD covers this area, and then the traffic intersection coordinates (x, y) in this area can be obtained, that is, only need to fall into this area, that is, satisfy
[0061]
[0062] A(min x i , max y i ), A(max x i , max y i ), A(min x i , min yi ), D(max x i , min y i )
[0063] scatter diagram as shown in Figure 2 for observation.
[0064] Step 2.2, finding the cell edge contour points is divided into the following steps
[0065] Step 2.2.1, find a point (point1) and find a point (point2) with the farthest distance, which is one of the boundary points.
[0066] Step 2.2.2, the vector v1 (point2-point1) composed of point1 and point2 is found from other vectors (other point coordinates-point1) to find a vector v2 (point3-point1) with the largest angle, which is one of the boundary points.
[0067] Step 2.2.3, repeat: find a vector v3 in v2 with the largest angle.
[0068] Step 2.2.4, until the last found vector direction is the vector of point2, end, find the cell edge contour point coordinates. Connect these coordinates in turn to get the edge contour of each area.
[0069] Step 2.3, optimize using "area method". From the points found above, filter out the intersections in the cell. As shown in Figure 3 , if the area sum of the triangle composed of point P and all the edges of the cell edge contour polygon is equal to the area of the cell edge contour polygon S, it means that the intersection point P is inside or on the edge of the cell, if the area sum of the triangle composed of point M and all the edges of the cell edge contour polygon is not equal to the area of the cell edge contour polygon S, it means that the intersection point M is no longer inside or on the edge of the cell. The area of the polygon can be calculated by the cross product, that is, the 0.5 sum of all vector cross products formed by connecting the coordinate origin and each vertex. However, there will be a certain error in calculating the area, and the error range of the precision needs to be set. As shown in Figure 3 , all intersection coordinates in the cell can be filtered out.
[0070] Further, as shown in Figure 4 , the step 3 includes the following steps:
[0071] Step 3.1, initialize the matrix, write all the corresponding distances of adjacent cells into the matrix, and initialize the distance corresponding to the non-adjacent nodes to inf.
[0072] Step 3.2: After initialization, a triple loop begins. Each loop iterates from the first node until the nth node is reached. Let the current node of the outermost loop be i, the current node of the middle loop be j, and the current node of the inner loop be k, where i ≠ j ≠ k. Then, using node i as the intermediary point, node j as the starting point, and node k as the target point, determine whether the distance from the starting point j to the target point k via the intermediary point i is less than the direct distance from the starting point j to the target point k. If it is less, then the distance d from the starting point j to the target point k is calculated. jk Updated to d ji +d ik After the triple loop completes, the route planning ends. The route map and the starting location of the delivery point are obtained. To facilitate the delivery of vegetable packages by various delivery platforms, we set the delivery point at an intersection near the starting location of the community. The flowchart is as follows: Figure 4 As shown.
[0073] The advantages of the Floyd algorithm are mainly reflected in its simplicity, ease of understanding, and straightforward code writing; it can calculate the shortest distance between any two nodes, an advantage not possessed by many path algorithms. The disadvantages are: due to traversing all nodes, the time complexity is relatively high; for sparse graphs, it generates a sparse matrix, resulting in significant storage waste; even after K-means clustering, the number of cells remains large; and considering that the delivery truck transporting the vegetable packages travels between intersections, intersections can be used to approximate the cells, such as... Figure 5 As shown: Both community A and community B have an approximate intersection F (the intersection closest to the community). Therefore, the materials that need to be transported to community A and community B only need to be transported to intersection F. At this point, the time complexity is reduced when using the Floyd algorithm in step three.
[0074] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for calculating the location of a material sorting site based on a cluster analysis and an area method of the Floyd algorithm, characterized in that, The method comprises the following steps: Step 1, K-means clustering is performed on the cell coordinate points in the urban area, and the cell coordinate points are divided into K clusters, that is, K regions; Step 2, the known intersection coordinates are screened by using the "area method", and the intersection coordinates located inside the outline of each region are retained; The step 2 specifically comprises the following steps: Step 2.1, for each cell coordinate point (x i , y i ) in the zone, draw a scatter plot, find min x i , max x i , min y i , max y i , cover the zone with a minimum rectangular area ABCD, and then get the preliminary screening intersection coordinate points in the zone, which satisfy the condition: Step 2.2, find the cell edge outline points, sequentially connect the cell edge outline points to obtain the cell edge outline, and use the "area method" to further screen the preliminarily screened intersection coordinates, and retain the preliminarily screened intersection coordinates located inside the cell edge outline; Step 3, the Floyd algorithm is used to traverse all the retained intersection coordinates of the regions to find suitable material distribution point positions; Step 4, K-means clustering is performed on the material distribution point positions of the whole city, and the material distribution point positions are divided into M clusters, that is, M regions; Step 5, the known intersection coordinates are screened by using the "area method", and the intersection coordinates located inside the outline of each region are retained; In the step 2.2, the specific steps of the "area method" are as follows: If the area sum of the triangle formed by the intersection coordinate point and all the sides of the cell edge outline polygon is equal to the total area of the cell edge outline polygon, it is determined that the intersection coordinate point is located inside or on the cell edge outline, otherwise, it is determined that the intersection coordinate point is located outside the cell edge outline; Step 6, the Floyd algorithm is used to traverse all the retained intersection coordinate positions of the regions to find the position of the large sorting material center.
2. The method of claim 1, wherein the method is characterized by, In the steps 1 and 4, the elbow method is used to determine the values of K and M in K-means clustering.
3. The method of claim 1, wherein the method is characterized by, In the step 2.2, the method for finding the cell edge outline points is as follows: Step 2.2.1, an arbitrary cell coordinate point point1 is selected, and a cell coordinate point point2 farthest from point1 in the region is found, which is one of the boundary points; Step 2.2.2, point1 and point2 form a vector v1(point2-point1), and other vectors are formed from other cell coordinate points and point1, and a vector v2(point3-point1) having the largest included angle with the other vectors (other point coordinates-point1) is found, and the point point3 is one of the cell edge outline points; Step 2.2.3, a vector v3 having the largest included angle with v2 is found from other vectors (other point coordinates-point2), and a cell edge outline point is found again, and the process is repeated until the last found vector direction is the vector of point2, and the found cell edge outline point coordinates are retained.
4. The method of claim 1, wherein the method is characterized by, The step 3 specifically comprises the following steps: Step 3.1, initialize the matrix, and write the distances corresponding to all adjacent intersection coordinate points into the matrix, and the distances corresponding to non-adjacent intersection coordinate points are initialized as inf; Step 3.2, after initialization, start to perform triple loop, each layer loop from the first node to the n node, set the outermost layer loop current node as i, the middle layer loop current node as j, the inner layer loop current node as k, and i≠j≠k, then take node i as the intermediate point, take node j as the starting point, and take node k as the target point, judge whether the distance from the starting point j to the target point k via the intermediate point i is less than the distance from the starting point j to the target point k directly, if less, then update the distance value d jk from the starting point j to the target point k to d ji +d ik ; Step 3.3, after the triple loop ends, the path planning ends.
5. The method of claim 1, wherein the method is characterized by: In the step 5, the edge outline points are found from the material distribution point positions of each region, all the edge outline points are sequentially connected, and the outline of the material distribution point positions of each region is obtained.
Citation Information
Patent Citations
Clustering algorithm-based logistics network selection method
CN107958298A
Statistical clustering-based road intersection position identification method in trajectory data
CN110909788A