# Step 12: Compile the grid search model: compile_model(grid_search_model)
## 3 Results and Discussion
### Clustering Demand Points and Distribution Center Locations  
According to Table 1, there were a total of 38 demand points following the disaster. The coordinates of these points were collected and used as input for the K-means technique.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Demand Point** & **Latitude** & **Longitude** & **Demand** \\ \hline \(N_{I}\) & 3.071 & 98.250 & 2805 \\ \(N_{2}\) & 3.137 & 98.301 & 715 \\ \(N_{3}\) & 3.142 & 98.301 & 366 \\ \(N_{4}\) &  
Four initial centroids were randomly selected to represent the distribution of demand points. These centroids were derived from four shelter posts.  
The K-means algorithm was applied to calculate the distance between each query point and the initial centroid. Based on this distance calculation, each point was assigned to the cluster that was closest to it. This process was repeated for each new cluster formed. To refine the clusters further, each existing cluster was divided into two by utilizing the two most distant demand points within it. This led to the creation of new clusters.  
Figure 5 illustrates the results of the grouping process, showcasing the clusters formed based on the assigned distribution center \(i\). Through 1000 iterations of optimization, the algorithm determined the optimal location of the distribution center and the grouping of demand points based on this center. The resulting coordinates of the new cluster centroid can be found in Table 2.  
An analysis of the number of clusters (\(k\)) was conducted using the elbow method to determine the optimal number of clusters based on the location data of 38 demand points. This analysis aims to identify the most suitable number of clusters, which will serve as potential candidates for opening distribution centers.  
The elbow method was employed to determine the optimal number of clusters based on the location data of 38 demand points. This method helps identify the most suitable number of clusters for opening distribution centers. Figure 6 depicts the graphical representation of the sum of squared distances for different numbers of clusters, highlighting the points of significant bends or decreases. This point indicates the optimal number of clusters to be considered for distribution center openings.  
In K-means clustering, determining the optimal number of groups \(K\) is an important consideration. The elbow method is a popular approach for assisting in this determination.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Distribution Center** & **Latitude** & **Longitude** & **Demand Point** \\ \hline DC\({}_{1}\) & 98.232 & 3.129 & N\({}_{6}\), N\({}_{8}\), N\({}_{9}\), N\({}_{10}\), N\({}_{11}\), N\({}_{12}\), N\({}_{13}\), N\({}_{14}\), N\({}_{16}\), N\({}_{17}\), N\({}_{18}\), \\  & & N\({}_{19}\), N\({}_{20}\), N\({}_{21}\), N\({}_{22}\), N\({}_{23}\), N\({}_{30}\), N\({}_{36}\), N\({}_{37}\), and N\({}_{38}\) \\ DC\({}_{2}\) & 98.493 & 3.103 & N\({}_{1}\), N\({}_{2}\), N\({}_{3}\), N\({}_{4}\), N\({}_{7}\), N\({}_{15}\), and N\({}_{33}\) \\ DC\({}_{3}\) & 98.492 & 3.137 & N\({}_{24}\), N\({}_{25}\), N\({}_{26}\), N\({}_{27}\), N\({}_{28}\), N\({}_{29}\), N\({}_{31}\), N\({}_{32}\), N\({}_{34}\), and N\({}_{35}\) \\ \hline \hline \end{tabular}
\end{table}
Table 2: Optimal distribution center and demand point grouping.  
Figure 5: Demand point locations.  
It utilizes the total within sum of squares (WSS) as a criterion for identifying the optimal \(K\). Figure 7 demonstrates this method, showing a sharp change in the line resembling an elbow near the minimum value when \(K=3\). Hence, according to the elbow method, the optimal \(K\) is achieved at \(K=3\).  
Figure 6: Grouping demand points into clusters (distribution centers) using geographic coordinates (latitude, longitude).  
Figure 7: Elbow graphic.