An optimization method, device and equipment for the layout of grid area service facilities based on cluster analysis and centroid method
By applying cluster analysis and center of gravity method in the grid area, the layout of service facilities is optimized, and the problems of low facility utilization and unbalanced service resources are solved, and more efficient service resource allocation is achieved.
Patent Information
- Application Number
- CN202410246159.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-05
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2044-03-05
AI Technical Summary
In the prior art, the layout planning of service facilities in the grid area is not perfect enough, resulting in low facility utilization and unbalanced service resources.
Using a method based on clustering analysis and center of gravity method, the boundary points of the grid area are converted into plane coordinates, the grid attribute data and demand index are calculated, and the cluster analysis is performed using the K-means++ algorithm, the objective function is constructed and the facility layout is optimized in combination with the center of gravity method to determine the optimal layout position.
The rational layout of service facilities has been achieved, the utilization rate of facilities and the balance of service resources has been improved, and convenient and high-quality services are provided for each grid.
Smart Images

Figure CN118052327B_ABST
Abstract
Description
Technical Field
[0001] The present invention discloses a method, which relates to the field of data processing, and specifically is a method, device and equipment for optimizing the layout of service facilities in grid areas based on cluster analysis and the centroid method. Background Art
[0002] A grid area is an area obtained by dividing a given area into grids. Grid-based management is a management and service mode that takes grids in the grid area as the basic units for management and service, and can transform traditional, passive, qualitative and decentralized management and service into modern, active, quantitative and systematic management and service, which can significantly improve the level of grass-roots governance.
[0003] However, within the grid area, the layout planning of facilities for providing basic services or specific services is not yet perfect enough, and the rationality needs to be improved in order to improve the utilization rate of service facilities and provide balanced service resources for each grid. Summary of the Invention
[0004] In view of the problems of the prior art, the present invention provides a method for optimizing the layout of service facilities in grid areas based on cluster analysis and the centroid method. In view of the importance of the layout of service facilities, the problem of optimizing the layout of service facilities in grid areas is solved, and it can enable service facilities to provide more convenient and high-quality services for each grid within the grid area on the basis of being fully utilized.
[0005] The specific solution proposed by the present invention is as follows:
[0006] The present invention provides a method for optimizing the layout of service facilities in grid areas based on cluster analysis and the centroid method, including:
[0007] Step 1: Convert the longitude and latitude coordinates of the boundary points of the grid area into plane coordinates, wherein the longitude and latitude coordinates of the boundary points are converted into corresponding plane coordinates by using the Gauss-Kruger projection algorithm to obtain a grid boundary conversion data set composed of the plane coordinates of all boundary points of the grid;
[0008] Step 2: Calculate the attribute data and demand index of each grid within the grid area, including:
[0009] Step 21: Calculate the attribute data of the grid according to the plane coordinates of the boundary points of each grid within the grid area, and the attribute data includes the grid area and the grid centroid coordinates;
[0010] Step 22: Determine the service group according to the service nature and the service content that can be provided by the service facilities, calculate the demand index of the grid according to the service group, and summarize and store the attribute data and the demand index into the grid association data set;
[0011] Step 3: Use the K-means++ algorithm to perform clustering analysis on the grids to complete the rough layout of service facilities, including:
[0012] Step 31: Based on the preset values of the grid centroid coordinates and the number of grid clusters, use the K-means++ algorithm to cluster the grid centroid coordinates, obtain the cluster labels assigned to each grid, and obtain a grid cluster set with the same number as the preset value of the number of grid clusters according to the cluster labels.
[0013] Step 32: Take the layout quantity of service facilities and the service coverage range of service facilities as the rough layout data of service facilities in the grid area, where the preset value of the number of grid clusters is used as the layout quantity of service facilities, and the grid cluster set is used as the service coverage range of service facilities.
[0014] Step 4: Construct the objective function for the layout of service facilities, and determine the optimization principle of the objective function. Specifically, according to the distance between service facilities and grids, as well as the attribute data and demand index of grids, construct the weighted distance sum between the candidate location and all grids within the service coverage range of service facilities as the objective function for the layout of service facilities, and determine the optimization principle as: the candidate location where the objective function obtains the minimum value is the best layout location of service facilities.
[0015] Step 5: Based on the optimization principle of the objective function, combine the centroid method to optimize the objective function to complete the fine layout of service facilities, including:
[0016] Step 51: Based on the rough layout data of service facilities in the grid area, obtain the current service coverage range of service facilities, combine the grid cluster set and grid association dataset corresponding to the current service coverage range of service facilities, and calculate the weighted centroid of the current service coverage range of service facilities.
[0017] Step 52: Take the weighted centroid as the current layout location, combine the grid cluster set and grid association dataset corresponding to the current service coverage range of service facilities, and calculate the objective function value of the current layout location.
[0018] Step 53: Based on the current layout location, calculate the comparison location and the objective function value of the comparison location according to the centroid coordinates of each grid and the weight of each grid in the current service coverage range of service facilities.
[0019] Step 54: Determine whether the objective function value of the current layout location is greater than the objective function value of the comparison location. If it is greater, take the comparison location as the current layout location until the objective function value of the current layout location is not greater than the objective function value of the comparison location, obtain the final current layout location, and convert the plane coordinates of the final current layout location into longitude and latitude coordinates as the best layout location.
[0020] Furthermore, in step 1 of the grid area service facility layout optimization method based on clustering analysis and centroid method, the specific steps include:
[0021] Step 11: Using the corresponding three-degree zone division in the Gauss-Kruger projection algorithm and the longitude range of the current grid area, determine the projection zone corresponding to the current grid area, and then determine the longitude of the central meridian corresponding to the current grid area.
[0022] Step 12: Take the longitude of the central meridian corresponding to the current grid area as the substitution parameter of the Gauss-Kruger projection algorithm, and determine the forward calculation algorithm and inverse calculation algorithm of the Gauss-Kruger projection corresponding to the current grid area.
[0023] Step 13: The longitude and latitude coordinates of all boundary points of each grid in the grid area are arranged in a counterclockwise or clockwise order to form an original grid boundary dataset, and obtain the original grid boundary dataset.
[0024] Step 14: For each grid, use the Gauss-Kruger projection forward calculation algorithm to sequentially convert the longitude and latitude coordinates of the boundary points in the original grid boundary dataset into corresponding plane coordinates according to the original arrangement order, and obtain a grid boundary conversion dataset composed of the plane coordinates of all boundary points of the grid.
[0025] Furthermore, in step 21 of the grid area service facility layout optimization method based on clustering analysis and centroid method, based on the shapely geometric processing library in Python, read the plane coordinates of all boundary points in the grid boundary conversion dataset, and use the area method and centroid method in the geometric processing library to calculate the grid area and grid centroid coordinates respectively.
[0026] Furthermore, in step 22 of the grid area service facility layout optimization method based on clustering analysis and centroid method, according to the characteristic data of the service group, divide the service group to obtain the grouping of the service group, obtain the number of people in each group of the service group in each grid in the grid area, and combine the analytic hierarchy process and entropy weight method to determine the weight of each group of people. Use the weighted method to calculate the product of the number of people in each group of each grid and the weight of the corresponding group of people, and take the sum result of the product data corresponding to each grid as the demand index of each grid.
[0027] Furthermore, in step 31 of the grid area service facility layout optimization method based on clustering analysis and centroid method, it includes: obtaining the preset value of the number of grid clusters.
[0028] If the number of service facilities to be laid out is known, the preset value of the number of grid clusters is the number of service facilities to be laid out.
[0029] If the number of service facilities to be arranged is unknown, determine the upper limit of the number of service facilities to be arranged according to the application situation, and determine the upper limit of the value verification of the number of grid clusters in combination with the arithmetic square root of the number of samples in the grid association dataset. The upper limit of the value verification is the smaller value between the arithmetic square root of the number of samples in the grid association dataset and the upper limit of the number of service facilities to be arranged.
[0030] Select values from the integers less than the upper limit of the value verification one by one in ascending order as the current verified number of clusters, and use the K-means++ algorithm to calculate the SSE value corresponding to the current number of clusters based on the grid centroid coordinates. The SSE value is the sum of the squares of the distances between each grid and the corresponding cluster center.
[0031] Based on the line chart plotted with all current numbers of clusters and their corresponding SSE values, use the elbow method to determine the preset value of the number of grid clusters.
[0032] Furthermore, in step 4 of the method for optimizing the layout of service facilities in grid areas based on cluster analysis and the centroid method, the objective function for constructing the service facility layout is expressed as:
[0033]
[0034] where x and y respectively represent the abscissa and ordinate of the location to be selected; x i , y i respectively represent the abscissa and ordinate of the centroid of the i-th grid in the service coverage area of the service facility; w i is the weight of the i-th grid in the service coverage area of the service facility, and its value is the reciprocal of the demand index density of the i-th grid in the service coverage area. The demand index density is the ratio of the grid demand index to the grid area; the part multiplied by the weight w i is the Euclidean distance between the i-th grid in the service coverage area and the location to be selected.
[0035] Furthermore, in step 51 of the method for optimizing the layout of service facilities in grid areas based on cluster analysis and the centroid method, calculating the weighted centroid of the service coverage area of the current service facility includes: The calculation formula for the abscissa of the weighted centroid is The calculation formula for the ordinate of the weighted centroid is x i , y i respectively represent the abscissa and ordinate of the centroid of the i-th grid in the current service coverage area, and w i is the weight of the i-th grid in the current service coverage area.
[0036] Further, in step 5 of the grid area service facility layout optimization method based on clustering analysis and centroid method, the current layout position is represented as (X c , Y c ), and the corresponding objective function value is f(X c , Y c ). In step 53, the comparison position (X cc , Y cc ) corresponding to the current layout position and the objective function value f(X cc , Y cc ) of the comparison position are calculated. Among them, the calculation formula for the comparison position is:
[0037]
[0038] where x i , y i respectively represent the abscissa and ordinate of the centroid of the i-th grid in the current service coverage range, and w i is the weight of the i-th grid in the current service coverage range.
[0039] The present invention also provides a grid area service facility layout optimization device based on clustering analysis and centroid method, including a coordinate conversion module, a grid data management module, a clustering analysis module, a function optimization module, and an optimized layout module.
[0040] The coordinate conversion module converts the longitude and latitude coordinates of the boundary points of the grid area into plane coordinates. Among them, the longitude and latitude coordinates of the boundary points are converted into corresponding plane coordinates by using the Gauss-Kruger projection algorithm, and a grid boundary conversion data set composed of the plane coordinates of all boundary points of the grid is obtained.
[0041] The grid data management module calculates the attribute data and demand index of each grid in the grid area, including:
[0042] Step 21: Calculate the attribute data of the grid according to the plane coordinates of the boundary points of each grid in the grid area. The attribute data includes the grid area and the grid centroid coordinates.
[0043] Step 22: Determine the service group according to the service nature of the service facility and the service content that can be provided. Calculate the demand index of the grid according to the service group, and summarize and store the attribute data and demand index in the grid association data set.
[0044] The clustering analysis module uses the K-means++ algorithm to perform clustering analysis on the grid to complete the rough layout of the service facility, including:
[0045] Step 31: Based on the preset values of the grid centroid coordinates and the number of grid clusters, use the K-means++ algorithm to cluster the grid centroid coordinates, obtain the cluster labels assigned to each grid, and obtain the same number of grid cluster sets as the preset value of the number of grid clusters according to the cluster labels.
[0046] Step 32: Take the layout quantity of service facilities and the service coverage range of service facilities as the rough layout data of service facilities in the grid area, where the preset value of the number of grid clusters is used as the layout quantity of service facilities, and the grid cluster set is used as the service coverage range of service facilities.
[0047] The function optimization module constructs the objective function for the layout of service facilities and determines the optimization principle of the objective function. Among them, according to the distance between the service facilities and the grids, as well as the attribute data and demand index of the grids, the total weighted distance between the candidate location and all grids within the service coverage range of the service facilities is constructed as the objective function for the layout of service facilities, and the optimization principle is determined as: the candidate location where the objective function obtains the minimum value is the optimal layout location of the service facilities.
[0048] The optimized layout module optimizes the objective function in combination with the centroid method based on the optimization principle of the objective function to complete the fine layout of service facilities, including:
[0049] Step 51: Based on the rough layout data of service facilities in the grid area, obtain the current service coverage range of service facilities, combine the grid cluster set and the grid association data set corresponding to the current service coverage range of service facilities, and calculate the weighted centroid of the current service coverage range of service facilities.
[0050] Step 52: Take the weighted centroid as the current layout location, combine the grid cluster set and the grid association data set corresponding to the current service coverage range of service facilities, and calculate the objective function value of the current layout location.
[0051] Step 53: Based on the current layout location, calculate the comparison location and the objective function value of the comparison location according to the centroid coordinates of each grid and the weight of each grid in the current service coverage range of service facilities.
[0052] Step 54: Determine whether the objective function value of the current layout location is greater than the objective function value of the comparison location. If it is greater, take the comparison location as the current layout location until the objective function value of the current layout location is not greater than the objective function value of the comparison location, obtain the final current layout location, and convert the plane coordinates of the final current layout location into longitude and latitude coordinates as the optimal layout location.
[0053] The present invention also provides an electronic device for optimizing the layout of grid area service facilities based on clustering analysis and the centroid method, which is characterized by including: at least one memory and at least one processor;
[0054] The at least one memory is used for storing machine-readable programs;
[0055] The at least one processor is used for calling the machine-readable program and executing the method for optimizing the layout of grid area service facilities based on clustering analysis and the centroid method.
[0056] The beneficial effects of the present invention are as follows:
[0057] The present invention provides a method, device and equipment for optimizing the layout of grid area service facilities based on clustering analysis and the centroid method. Based on the corresponding attribute data and demand data of the grid, the grid is clustered and grouped through clustering analysis to achieve a rough layout of the grid area service facilities, and further the centroid method is used to optimize the rough layout result to achieve a fine layout of the grid area service facilities, and a reasonable layout of the grid area service facilities is completed, that is, the best layout positions of each service facility and all grids corresponding to the corresponding service coverage range are given. The method of the present invention not only associates a number of important data, but also uses corresponding methods to process the complex relationships existing among the various associations, and can effectively solve the problem of optimizing the layout of grid area service facilities, providing effective technical support and reasonable guidance for the layout planning of service facilities. Description of the Drawings
[0058] Figure 1 is a schematic flowchart of the method of the present invention.
[0059] Figure 2 is a line chart of the SSE corresponding to the number of grid clusters involved in the method of the present invention.
[0060] Figure 3 is a schematic diagram of the distribution of the grid cluster set obtained by grid clustering analysis involved in the method of the present invention.
[0061] Figure 4 is a schematic diagram of the layout result obtained by optimizing with the centroid method involved in the method of the present invention. Detailed Embodiments
[0062] The present invention will be further described below with reference to the drawings and specific embodiments, so that those skilled in the art can better understand the present invention and be able to implement it, but the specific embodiments cited are not intended to limit the present invention.
[0063] In a region containing numerous grid cells, the unreasonable layout of service facilities will lead to low utilization rate of service facilities and imbalance of service resources that grid cells in the region can obtain. To solve the problem of reasonable layout of service facilities in the grid region, the present invention provides an optimization method for layout of service facilities in a grid region based on clustering analysis and centroid method, including:
[0064] Step 1: Convert the longitude and latitude coordinates of the boundary points of the grid region into plane coordinates, wherein the longitude and latitude coordinates of the boundary points are converted into corresponding plane coordinates by using the Gauss-Kruger projection algorithm to obtain a grid boundary conversion data set composed of the plane coordinates of all boundary points of the grid;
[0065] Step 2: Calculate the attribute data and demand index of each grid in the grid region, including:
[0066] Step 21: Calculate the attribute data of the grid according to the plane coordinates of the boundary points of each grid in the grid region, and the attribute data includes the grid area and the grid centroid coordinates.
[0067] Step 22: Determine the service population according to the service nature of the service facilities and the service content that can be provided, calculate the demand index of the grid according to the service population, and summarize and store the attribute data and the demand index into the grid association data set;
[0068] Step 3: Use the K-means++ algorithm to perform clustering analysis on the grid to complete the rough layout of the service facilities, including:
[0069] Step 31: Based on the grid centroid coordinates and the preset value of the number of grid clusters, use the K-means++ algorithm to cluster the grid centroid coordinates, obtain the cluster label assigned to each grid, and obtain the same number of grid cluster sets as the preset value of the number of grid clusters according to the cluster label;
[0070] Step 32: Take the layout quantity of the service facilities and the service coverage range of the service facilities as the rough layout data of the service facilities in the grid region, wherein the preset value of the number of grid clusters is taken as the layout quantity of the service facilities, and the grid cluster set is taken as the service coverage range of the service facilities;
[0071] Step 4: Construct the objective function for the layout of the service facilities, and determine the optimization principle of the objective function. Specifically, according to the distance between the service facilities and the grid and the attribute data and demand index of the grid, construct the weighted distance sum of the candidate location and all grids within the service coverage range of the service facilities as the objective function for the layout of the service facilities, and determine the optimization principle as: the candidate location where the objective function obtains the minimum value is the best layout location of the service facilities;
[0072] Step 5: Based on the optimization principle of the objective function, optimize the objective function in combination with the centroid method to complete the fine layout of service facilities, including:
[0073] Step 51: Based on the rough layout data of service facilities within the grid area, obtain the current service coverage range of the service facilities. Combine the grid clustering set and grid association data set corresponding to the current service coverage range of the service facilities, and calculate the weighted centroid of the current service coverage range of the service facilities.
[0074] Step 52: Take the weighted centroid as the current layout position. Combine the grid clustering set and grid association data set corresponding to the current service coverage range of the service facilities, and calculate the objective function value of the current layout position.
[0075] Step 53: Based on the current layout position, calculate the comparison position and the objective function value of the comparison position according to the centroid coordinates of each grid and the weight of each grid in the current service coverage range of the service facilities.
[0076] Step 54: Determine whether the objective function value of the current layout position is greater than the objective function value of the comparison position. If it is greater, take the comparison position as the current layout position until the objective function value of the current layout position is not greater than the objective function value of the comparison position. Obtain the final current layout position, and convert the plane coordinates of the final current layout position into longitude and latitude coordinates as the optimal layout position.
[0077] The method of the present invention optimizes the layout planning by performing clustering analysis on the grids within the grid area and combining the centroid method, determines the reasonable layout data of service facilities in the grid area, realizes the goal of optimizing the layout of service facilities in the grid area, and provides effective technical support and reasonable guidance for the layout planning of service facilities.
[0078] In specific applications, in some embodiments of the method of the present invention, the following can be referred to:
[0079] Step 1: Convert the longitude and latitude coordinates of the boundary points of the grid area into plane coordinates, where the longitude and latitude coordinates of the boundary points are converted into corresponding plane coordinates by using the Gauss-Kruger projection algorithm to obtain the grid boundary conversion data set composed of the plane coordinates of all grid boundary points.
[0080] In the method of the present invention, according to the characteristics of high precision requirements for service facility layout planning, the Gauss-Kruger projection method is determined as the coordinate projection conversion method, and the three-degree zone division is specifically selected for more suitable large-scale mapping.
[0081] That is, in Step 1, the specific steps can further include:
[0082] Step 11: Determine the projection zone corresponding to the current grid area by using the corresponding three-degree zone division in the Gauss-Kruger projection algorithm and the longitude range where the current grid area is located, and then determine the longitude of the central meridian corresponding to the current grid area.
[0083] Step 12: Use the longitude of the central meridian corresponding to the current grid area as the substitution parameter for the Gauss-Kruger projection algorithm to determine the forward calculation algorithm and inverse calculation algorithm of the Gauss-Kruger projection corresponding to the current grid area.
[0084] Step 13: Arrange the longitude and latitude coordinates of all boundary points of each grid in the grid area in a counterclockwise or clockwise order to form an original dataset of the grid boundary, and obtain the original dataset of the grid boundary.
[0085] Step 14: For each grid, use the Gauss-Kruger projection forward calculation algorithm to sequentially convert the longitude and latitude coordinates of the boundary points in the original dataset of the grid boundary into the corresponding plane coordinates according to the original arrangement order, and obtain a converted dataset of the grid boundary composed of the plane coordinates of all boundary points of the grid.
[0086] Step 2: Calculate the attribute data and demand index of each grid in the grid area, including:
[0087] Step 21: Calculate the attribute data of the grid according to the plane coordinates of the boundary points of each grid in the grid area. The attribute data includes the grid area and the grid centroid coordinates. Among them, based on the shapely geometric processing library in Python, read the plane coordinates of all boundary points in the converted dataset of the grid boundary, and use the area method and centroid method in the geometric processing library to calculate the grid area and the grid centroid coordinates respectively.
[0088] Step 22: Determine the service group according to the service nature and the services that can be provided by the service facilities, calculate the demand index of the grid according to the service group, and summarize and store the attribute data and the demand index in the grid association dataset. Further, according to the characteristic data of the service group, divide the service group to obtain the grouping of the service group, obtain the number of people in each group of the service group in each grid in the grid area, and combine the analytic hierarchy process and the entropy weight method to determine the weight of each group of people. Use the weighted method to calculate the product of the number of people in each group of each grid and the weight of the corresponding group of people, and use the summation result of the product data corresponding to each grid as the demand index of each grid.
[0089] Step 3: Use the K-means++ algorithm to perform clustering analysis on the grid to complete the rough layout of the service facilities, including:
[0090] Step 31: Based on the preset values of grid centroid coordinates and the number of grid clusters, use the K-means++ algorithm to cluster the grid centroid coordinates, obtain the cluster labels assigned to each grid, and obtain the same number of grid cluster sets as the preset value of the number of grid clusters according to the cluster labels. Specifically, based on the scikit-learn machine learning library in Python, after reading the grid centroid coordinate data in the grid attribute dataset and substituting the preset value of the number of clusters, use the KMeans function in the machine learning library to complete the clustering grouping of the grids and obtain all grid cluster sets.
[0091] Among them, step 31 may further include: obtaining the preset value of the number of grid clusters,
[0092] If the number of service facilities to be laid out is known, the preset value of the number of grid clusters is the number of service facilities to be laid out;
[0093] If the number of service facilities to be laid out is unknown, determine the upper limit of the number of service facilities to be laid out according to the application situation, and combine the arithmetic square root of the number of samples in the grid association dataset to determine the upper limit of the value verification of the number of grid clusters. The upper limit of the value verification is the smaller of the arithmetic square root of the number of samples in the grid association dataset and the upper limit of the number of service facilities to be laid out.
[0094] Select values from the integers less than the upper limit of the value verification one by one from small to large as the current verification number of clusters, and use the K-means++ algorithm based on the grid centroid coordinates to calculate the SSE value corresponding to the current number of clusters. The SSE value is the sum of the squares of the distances between each grid and the corresponding cluster center.
[0095] Based on the line chart drawn from all the current numbers of clusters and the corresponding SSE values, that is, reference Figure 2 , use the elbow method to determine the preset value of the number of grid clusters, that is, determine the number of clusters corresponding to the position where the reduction speed of the SSE value slows down by observing the line chart, and use this number of clusters as the preset value of the number of grid clusters.
[0096] Step 32: Take the layout quantity of the service facilities and the service coverage range of the service facilities as the rough layout data of the grid area service facilities, where the preset value of the number of grid clusters is used as the layout quantity of the service facilities, and the grid cluster set is used as the service coverage range of the service facilities.
[0097] For example, for a grid area composed of 44 grids, first, use the elbow method to determine the layout quantity of the service facilities in this area. Figure 2Among them, when the value of the number of grid clusters ranges from 1 to 3, the SSE decreases significantly. When the value of the number of grid clusters exceeds 3, the decrease in SSE tends to level off. In this case, it is reasonable to set the preset value of the number of grid clusters to 3. Then, use the corresponding method to cluster the grids into 3 groups, and each group is used as a grid cluster set. For specific details, please refer to Figure 3 . In summary, the rough layout data of service facilities in the considered grid area can be obtained.
[0098] Step 4: Construct the objective function for the layout of service facilities and determine the optimization principle of the objective function. Among them, according to the distance between the service facilities and the grids, as well as the attribute data and demand index of the grids, the sum of the weighted distances between the candidate location and all grids within the service coverage of the service facilities is constructed as the objective function for the layout of service facilities, and the optimization principle is determined as: the candidate location that makes the objective function obtain the minimum value is the optimal layout location of the service facilities.
[0099] Among them, the construction of the objective function for the layout of service facilities in Step 4 is expressed as:
[0100]
[0101] Among them, x and y respectively represent the abscissa and ordinate of the candidate location; x i , y i respectively represent the abscissa and ordinate of the centroid of the i-th grid in the service coverage of the service facilities; w i is the weight of the i-th grid in the service coverage of the service facilities, and its value is the reciprocal of the demand index density of the i-th grid in the service coverage. The demand index density is the ratio of the grid demand index to the grid area; the part multiplied by the weight w i is the Euclidean distance between the i-th grid in the service coverage and the candidate location.
[0102] According to the actual meaning of the objective function, it can be known that the smaller the value of the objective function, the more reasonable the candidate location. In order to further determine the reasonable location of the service facilities on the basis of the rough layout, the optimization principle of the objective function can be determined as: it is necessary to determine the candidate location that makes the objective function obtain the minimum value, and this location is the optimal layout location of the service facilities.
[0103] Step 5: Based on the optimization principle of the objective function, combine the centroid method to optimize the objective function and complete the fine layout of the service facilities, including:
[0104] Step 51: Based on the rough layout data of service facilities in the grid area, obtain the current service coverage of the service facilities, and combine the grid cluster set and grid association data set corresponding to the current service coverage of the service facilities to calculate the weighted centroid of the current service coverage of the service facilities.
[0105] Among them, calculating the weighted center of gravity of the service coverage range of the current service facility in step 51 includes: the calculation formula for the abscissa of the weighted center of gravity is The calculation formula for the ordinate of the weighted center of gravity is x i , y i respectively represent the abscissa and ordinate of the centroid of the i-th grid in the current service coverage range, and w i is the weight of the i-th grid in the current service coverage range.
[0106] Step 52: Use the weighted center of gravity as the current layout position, and combine the grid clustering set and the grid association data set corresponding to the service coverage range of the current service facility to calculate the objective function value of the current layout position. Represent the current layout position as (X c , Y c ) and the corresponding objective function value is f(X c , Y c ).
[0107] Step 53: Based on the current layout position, calculate the comparison position of the current layout position and the objective function value of the comparison position according to the centroid coordinates of each grid and the weight of each grid in the service coverage range of the current service facility. Among them, calculate the comparison position (X cc , Y cc ) corresponding to the current layout position and the objective function value f(X cc , Y cc ) of the comparison position. Among them, the calculation formula for the comparison position is:
[0108]
[0109] where x i , y i respectively represent the abscissa and ordinate of the centroid of the i-th grid in the current service coverage range, and w i is the weight of the i-th grid in the current service coverage range.
[0110] Step 54: Determine whether the objective function value of the current layout position is greater than the objective function value of the comparison position. If it is greater, use the comparison position as the current layout position until the objective function value of the current layout position is not greater than the objective function value of the comparison position, obtain the final current layout position, and convert the plane coordinates of the final current layout position into longitude and latitude coordinates as the optimal layout position. That is, if the objective function value f(X c , Y c ) of the current layout position is greater than the objective function value f(X cc , Y cc), and taking its corresponding comparison position as the current layout position, repeating the calculation process of the previous step; if the objective function value f(X c , Y c ) at the current layout position is not greater than the objective function value f(X cc , Y cc ) at its corresponding comparison position, obtain the current layout position and end the optimization process.
[0111] Based on the optimization results of the optimization process, the refined layout data of the service facilities in the grid area can be obtained, including the optimal layout positions of the service facilities and their corresponding service coverage ranges. Take the longitude and latitude coordinates obtained by the Gauss-Kruger projection inverse calculation algorithm for the current layout position finally obtained in the optimization process as the optimal layout positions, and take the current service coverage range finally obtained in the optimization process as the service coverage range of the service facilities corresponding to the optimal layout positions.
[0112] Continuing to use the grid area composed of 44 grids in the above example, calculate the weights of each grid and the weighted centroids corresponding to each grid clustering set, and continuously optimize the objective function using the centroid method. The optimal layout positions of the service facilities in the grid area and their respective corresponding service coverage ranges can be obtained.
[0113] The present invention also provides a grid area service facility layout optimization device based on cluster analysis and centroid method, including a coordinate conversion module, a grid data management module, a cluster analysis module, a function optimization module, and an optimized layout module.
[0114] The coordinate conversion module converts the longitude and latitude coordinates of the boundary points of the grid area into plane coordinates, wherein the longitude and latitude coordinates of the boundary points are converted into corresponding plane coordinates by using the Gauss-Kruger projection algorithm to obtain a grid boundary conversion data set composed of the plane coordinates of all the boundary points of the grid.
[0115] The grid data management module calculates the attribute data and demand index of each grid in the grid area, including:
[0116] Step 21: Calculate the attribute data of the grid according to the plane coordinates of the boundary points of each grid in the grid area, and the attribute data includes the grid area and the grid centroid coordinates.
[0117] Step 22: Determine the service group according to the service nature of the service facilities and the services that can be provided, calculate the demand index of the grid according to the service group, and summarize and store the attribute data and demand index in the grid association data set.
[0118] The cluster analysis module uses the K-means++ algorithm to perform cluster analysis on the grid to complete the rough layout of the service facilities, including:
[0119] Step 31: Based on the preset values of the grid centroid coordinates and the number of grid clusters, use the K-means++ algorithm to cluster the grid centroid coordinates, obtain the cluster labels assigned to each grid, and obtain the same number of grid cluster sets as the preset value of the number of grid clusters according to the cluster labels.
[0120] Step 32: Take the layout quantity of the service facilities and the service coverage range of the service facilities as the rough layout data of the service facilities in the grid area, where the preset value of the number of grid clusters is used as the layout quantity of the service facilities, and the grid cluster sets are used as the service coverage range of the service facilities.
[0121] The function optimization module constructs the objective function for the service facility layout, determines the optimization principle of the objective function. Specifically, according to the distance between the service facilities and the grids, as well as the attribute data and demand index of the grids, the total weighted distance between the candidate location and all grids within the service coverage range of the service facilities is constructed as the objective function for the service facility layout, and the optimization principle is determined as: the candidate location where the objective function obtains the minimum value is the optimal layout location of the service facilities.
[0122] The optimized layout module optimizes the objective function in combination with the centroid method based on the optimization principle of the objective function, and completes the fine layout of the service facilities, including:
[0123] Step 51: Based on the rough layout data of the service facilities in the grid area, obtain the current service coverage range of the service facilities, combine the grid cluster sets and grid association data sets corresponding to the current service coverage range of the service facilities, and calculate the weighted centroid of the current service coverage range of the service facilities.
[0124] Step 52: Take the weighted centroid as the current layout location, combine the grid cluster sets and grid association data sets corresponding to the current service coverage range of the service facilities, and calculate the objective function value of the current layout location.
[0125] Step 53: Based on the current layout location, according to the centroid coordinates of each grid and the weight of each grid in the current service coverage range of the service facilities, calculate the comparison location of the current layout location and the objective function value of the comparison location.
[0126] Step 54: Determine whether the objective function value of the current layout location is greater than the objective function value of the comparison location. If it is greater, take the comparison location as the current layout location until the objective function value of the current layout location is not greater than the objective function value of the comparison location, obtain the final current layout location, and convert the plane coordinates of the final current layout location into longitude and latitude coordinates as the optimal layout location.
[0127] For the information interaction, execution process, etc. among the modules in the above device, since they are based on the same concept as the method embodiments of the present invention, the specific content can be referred to the description in the method embodiments of the present invention and will not be elaborated here.
[0128] Similarly, the device of the present invention can be based on the grid corresponding attribute data and demand data, and through cluster analysis, the grids are clustered and grouped to achieve a rough layout of the service facilities in the grid area, and further use the centroid method to optimize the rough layout result to achieve a fine layout of the service facilities in the grid area, complete the reasonable layout of the service facilities in the grid area, that is, give the best layout positions of each service facility and all grids corresponding to the corresponding service coverage range. The device of the present invention not only associates multiple important data, but also uses corresponding methods to process the complex relationships commonly existing among the associations, can effectively solve the problem of optimizing the layout of service facilities in the grid area, and provides effective technical support and reasonable guidance for the layout planning of service facilities.
[0129] It should be noted that not all steps and modules in the above processes and device structures are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted according to needs. The system structures described in the above embodiments can be physical structures or logical structures, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or some components in multiple independent devices can be jointly implemented.
[0130] The present invention also provides an electronic device for optimizing the layout of service facilities in a grid area based on cluster analysis and the centroid method, which is characterized by including: at least one memory and at least one processor;
[0131] The at least one memory is used for storing machine-readable programs;
[0132] The at least one processor is used for calling the machine-readable program and executing the method for optimizing the layout of service facilities in a grid area based on cluster analysis and the centroid method.
[0133] For the information interaction, execution process of the readable program, etc. of the processor in the above electronic device, since they are based on the same concept as the method embodiments of the present invention, the specific content can be referred to the description in the method embodiments of the present invention and will not be elaborated here.
[0134] Similarly, the electronic device of the present invention can, based on the grid corresponding attribute data and requirement data, cluster and group the grids through cluster analysis to achieve a rough layout of service facilities in the grid area, and further use the centroid method to optimize the rough layout result to achieve a fine layout of service facilities in the grid area, complete the reasonable layout of service facilities in the grid area, that is, give the best layout positions of each service facility and all grids corresponding to the corresponding service coverage range. The electronic device of the present invention not only associates a number of important data, but also uses corresponding methods to handle the complex relationships that generally exist among the various associations, can effectively solve the problem of optimizing the layout of service facilities in the grid area, and provides effective technical support and reasonable guidance for the layout planning of service facilities.
[0135] The above-described embodiments are only preferred embodiments given to fully illustrate the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or transformations made by those skilled in the art on the basis of the present invention are all within the protection scope of the present invention. The protection scope of the present invention shall be subject to the claims.
Claims
1. A method for optimizing the layout of grid area service facilities based on cluster analysis and centroid method, characterized in that Including: Step 1: Convert the longitude and latitude coordinates of the boundary points of the grid area into plane coordinates. Specifically, use the Gauss-Kruger projection algorithm to convert the longitude and latitude coordinates of the boundary points into corresponding plane coordinates, obtaining a grid boundary conversion data set composed of the plane coordinates of all boundary points of the grid. Step 2: Calculate the attribute data and demand index of each grid within the grid area, including: Step 21: Calculate the attribute data of the grid according to the plane coordinates of the boundary points of each grid within the grid area. The attribute data includes the grid area and the grid centroid coordinates. Step 22: Determine the service population according to the service nature of the service facility and the service content it can provide. Calculate the demand index of the grid according to the service population, and summarize and store the attribute data and demand index in the grid association data set. Step 3: Use the K-means++ algorithm to perform clustering analysis on the grid to complete the rough layout of the service facility, including: Step 31: Based on the grid centroid coordinates and the preset value of the number of grid clusters, use the K-means++ algorithm to cluster the grid centroid coordinates, obtain the cluster label assigned to each grid, and obtain the same number of grid cluster sets as the preset value of the number of grid clusters according to the cluster label. Step 32: Take the layout quantity of the service facility and the service coverage range of the service facility as the rough layout data of the service facility in the grid area. Specifically, take the preset value of the number of grid clusters as the layout quantity of the service facility, and take the grid cluster set as the service coverage range of the service facility. Step 4: Construct the objective function for the layout of the service facility and determine the optimization principle of the objective function. Specifically, according to the distance between the service facility and the grid, as well as the attribute data and demand index of the grid, construct the weighted distance sum of the candidate location and all grids within the service coverage range of the service facility as the objective function for the layout of the service facility, and determine the optimization principle as: the candidate location where the objective function obtains the minimum value is the optimal layout location of the service facility. Step 5: Based on the optimization principle of the objective function, optimize the objective function in combination with the centroid method to complete the fine layout of the service facility, including: Step 51: Based on the rough layout data of the service facility in the grid area, obtain the current service coverage range of the service facility. Combine the grid cluster set and the grid association data set corresponding to the current service coverage range of the service facility, and calculate the weighted centroid of the current service coverage range of the service facility. Step 52: Take the weighted centroid as the current layout location. Combine the grid cluster set and the grid association data set corresponding to the current service coverage range of the service facility, and calculate the objective function value of the current layout location. Step 53: Based on the current layout location, calculate the comparison location and the objective function value of the comparison location according to the centroid coordinates of each grid and the weight of each grid in the current service coverage range of the service facility. Step 54: Determine whether the objective function value of the current layout position is greater than that of the comparison position. If it is greater, take the comparison position as the current layout position until the objective function value of the current layout position is not greater than that of the comparison position. Obtain the final current layout position, and convert the planar coordinates of the final current layout position into longitude and latitude coordinates as the optimal layout position.
2. The method for optimizing the layout of service facilities in a grid area based on cluster analysis and centroid method according to claim 1, wherein in step 1, the specific steps include: Step 11: Utilize the corresponding three-degree zone division in the Gauss-Kruger projection algorithm and the longitude range of the current grid area to determine the projection zone corresponding to the current grid area, and further determine the longitude of the central meridian corresponding to the current grid area. Step 12: Take the longitude of the central meridian corresponding to the current grid area as the substitution parameter of the Gauss-Kruger projection algorithm to determine the forward calculation algorithm and inverse calculation algorithm of the Gauss-Kruger projection corresponding to the current grid area. Step 13: The longitude and latitude coordinates of all boundary points of each grid in the grid area are arranged in a counterclockwise or clockwise order to form the original grid boundary dataset, and obtain the original grid boundary dataset. Step 14: For each grid, use the Gauss-Kruger projection forward calculation algorithm to sequentially convert the longitude and latitude coordinates of the boundary points in the original grid boundary dataset into the corresponding planar coordinates according to the original arrangement order, and obtain the grid boundary conversion dataset composed of the planar coordinates of all boundary points of the grid.
3. The method for optimizing the layout of service facilities in a grid area based on cluster analysis and centroid method according to claim 1, wherein in step 21, based on the shapely geometric processing library in Python, read the planar coordinates of all boundary points in the grid boundary conversion dataset, and use the area method and centroid method in the geometric processing library to calculate the grid area and the grid centroid coordinates respectively.
4. The method for optimizing the layout of service facilities in a grid area based on cluster analysis and centroid method according to claim 1 or 3, wherein in step 22, according to the characteristic data of the service population, divide the service population to obtain the grouping of the service population, obtain the number of people in each group of the service population in each grid in the grid area, and combine the analytic hierarchy process and the entropy weight method to determine the weight of each group of people. Use the weighting method to calculate the product of the number of people in each group of each grid and the corresponding weight of the group of people, and take the summation result of the product data corresponding to each grid as the demand index of each grid.
5. The optimization method for the layout of grid area service facilities based on clustering analysis and centroid method according to claim 1, characterized in that In step 31, it includes: obtaining the preset value of the number of grid clusters. Wherein if the number of service facilities to be laid out is known, the preset value of the number of grid clusters is the number of service facilities to be laid out. If the number of service facilities to be laid out is unknown, determine the upper limit of the number of service facilities to be laid out according to the application situation, and combine the arithmetic square root of the number of samples in the grid association dataset to determine the upper limit of the value verification of the number of grid clusters. The upper limit of the value verification is the smaller of the arithmetic square root of the number of samples in the grid association dataset and the upper limit of the number of service facilities to be laid out. Select values from the integers smaller than the upper limit of the value verification as the current verified number of clusters in ascending order, and use the K-means++ algorithm to calculate the SSE value corresponding to the current number of clusters based on the grid centroid coordinates. The SSE value is the sum of the squares of the distances between each grid and the corresponding cluster center. Based on the line chart plotted with all the current numbers of clusters and the corresponding SSE values, use the elbow method to determine the preset value of the number of grid clusters.
6. The grid area service facility layout optimization method based on clustering analysis and centroid method according to claim 1, characterized in that The objective function for constructing the service facility layout in step 4 is expressed as: where x and y respectively represent the abscissa and ordinate of the position to be selected; x i , y i respectively represent the abscissa and ordinate of the centroid of the i-th grid in the service coverage area of the service facility; w i It is the weight of the i-th grid in the service coverage range of service facilities, and its value is the reciprocal of the demand index density of the i-th grid in the service coverage range. The demand index density is the ratio of the grid demand index to the grid area; the part multiplied by the weight w i is the Euclidean distance between the i-th grid in the service coverage range and the candidate location.
7. The grid area service facility layout optimization method based on clustering analysis and centroid method according to claim 1 is characterized in that Calculating the weighted centroid of the service coverage range of the current service facility in step 51 includes: The calculation formula for the abscissa of the weighted centroid is , and the calculation formula for the ordinate of the weighted centroid is x i , y i respectively represent the abscissa and ordinate of the centroid of the i-th grid in the current service coverage range, and w i is the weight of the i-th grid in the current service coverage range.
8. An optimization method for the layout of grid area service facilities based on cluster analysis and centroid method according to claim 7, characterized in that in step 5, the current layout position is represented as (X c , Y c ), and the corresponding objective function value is f(X c , Y c ). In step 53, the comparison position (X cc , Y cc ) corresponding to the current layout position and the objective function value f(X cc , Y cc ) of the comparison position are calculated. Among them, The calculation formula for comparing positions is: where x i , y i represent the abscissa and ordinate of the centroid of the i-th grid in the current service coverage area respectively, and w i is the weight of the i-th grid in the current service coverage area.
9. An optimization device for the layout of grid area service facilities based on cluster analysis and centroid method, characterized in that It includes a coordinate conversion module, a grid data management module, a clustering analysis module, a function optimization module, and an optimized layout module. The coordinate conversion module converts the longitude and latitude coordinates of the boundary points of the grid area into plane coordinates. Among them, the Gauss-Kruger projection algorithm is used to convert the longitude and latitude coordinates of the boundary points into the corresponding plane coordinates, and a grid boundary conversion dataset composed of the plane coordinates of all the boundary points of the grid is obtained. The grid data management module calculates the attribute data and demand index of each grid within the grid area, including: Step 21: Calculate the attribute data of the grid according to the plane coordinates of the boundary points of each grid within the grid area. The attribute data includes the grid area and the grid centroid coordinates. Step 22: Determine the service group according to the service nature of the service facilities and the services that can be provided. Calculate the demand index of the grid according to the service group, and summarize and store the attribute data and demand index in the grid association dataset. The clustering analysis module uses the K-means++ algorithm to perform clustering analysis on the grid to complete the rough layout of the service facilities, including: Step 31: Based on the grid centroid coordinates and the preset value of the number of grid clusters, use the K-means++ algorithm to cluster the grid centroid coordinates, obtain the cluster label assigned to each grid, and obtain a grid cluster set with the same number as the preset value of the number of grid clusters according to the cluster label. Step 32: Take the layout quantity of the service facilities and the service coverage range of the service facilities as the rough layout data of the service facilities in the grid area. Among them, take the preset value of the number of grid clusters as the layout quantity of the service facilities, and take the grid cluster set as the service coverage range of the service facilities. The function optimization module constructs the objective function for the service facility layout and determines the optimization principle of the objective function. Among them, according to the distance between the service facilities and the grid, as well as the attribute data and demand index of the grid, construct the weighted distance sum of all the grids within the service coverage range of the service facility at the candidate location as the objective function for the service facility layout, and determine the optimization principle as: the candidate location where the objective function obtains the minimum value is the best layout location of the service facility. Based on the optimization principle of the objective function, the optimization layout module combines the centroid method to optimize the objective function and completes the fine layout of service facilities, including: Step 51: Based on the rough layout data of service facilities within the grid area, obtain the current service coverage range of service facilities, and combine the grid clustering set and grid association data set corresponding to the current service coverage range of service facilities to calculate the weighted centroid of the current service coverage range of service facilities. Step 52: Use the weighted centroid as the current layout position, and combine the grid clustering set and grid association data set corresponding to the current service coverage range of service facilities to calculate the objective function value of the current layout position. Step 53: Based on the current layout position, calculate the comparison position of the current layout position and the objective function value of the comparison position according to the centroid coordinates of each grid and the weight of each grid in the current service coverage range of service facilities. Step 54: Determine whether the objective function value of the current layout position is greater than the objective function value of the comparison position. If it is greater, use the comparison position as the current layout position until the objective function value of the current layout position is not greater than the objective function value of the comparison position. Obtain the final current layout position, and convert the plane coordinates of the final current layout position into longitude and latitude coordinates as the optimal layout position.
10. An electronic device for optimizing the layout of grid area service facilities based on cluster analysis and centroid method, characterized in that Including: At least one memory and at least one processor; The at least one memory is used to store machine-readable programs; The at least one processor is used to call the machine-readable program and execute a method for optimizing the layout of service facilities in a grid area based on clustering analysis and the centroid method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Site selection method and system for electric vehicle charging stations in community and storage medium
CN115640962A
Modular hydrocarbon facility placement planning system
US20230146803A1