# Distributed Dynamic Cluster-Head Selection and Clustering for Massive IoT Access in 5G Networks
## 4 Numerical Results  
### Platform Analysis  
In order to reflect the effect of the improved k-means algorithm of the proposed adaptive clustering on the energy efficiency, we first built an access simulation platform based on Matlab. The platform adopts the event-driven mechanism and object-oriented programming method, which makes the system structure clear, easy to organize and understand, maintainable, and can easily add new function modules and algorithms.  
The access simulation platform is mainly divided into the initialization module, a simulation module, and an output module. The initialization module mainly includes the initialization of some simulation architecture such as scheduler, calendar table, and some real simulation entity. The simulation module is primarily based on the channel access and the packet transmission process  
\begin{table}
\begin{tabular}{l} \hline
1: Input: MinPts \(=2\)\(Eps\)\(X\)\(M\)\(=1\)\(r_{nm}\)\(=0\)\(\epsilon\) (\(\epsilon\) is arbitrarily small) \\
2: Mark all objects in data set \(X\) as unprocessed \\
3: for (each object \(p\) in data set \(X\)) do \\
4: if (\(p\) is clustered or marked as noise) \\
5: continue; \\
6: else if (\(N_{Eps}(p)<MinPts\)) \\
7: Mark object \(p\) as the border point; \\
8: else \\
9: Mark object \(p\) as the core point, Create a cluster \(C_{m}\), Add all the object s in the \(N_{Eps}(p)\) to \(C\), \(M++\); \\
10: for (Unprocessed object \(q\) in the \(N_{Eps}(p)\)) \\
11: if (\(N_{Eps}(q)<MinPts\)) \\
12: Add all the Objects in the \(N_{Eps}(p)\) which do not belong to any cluster to \(C\); \\
13: end for \\
14: end if \\
15: end if \\
16: end for \\
17: Get the position of the center of the initial cluster \(C=\{c_{m}|m=1,2,\ldots,M\}\); \\
18: Calculate \(y_{m}\) by the formula (7); \\
19: Calculate \(U\) by the formula (8), \(U\) mark as \(U_{old}\)\(\forall m,n,g,1\leq m\leq M,1\leq n\leq N,1\leq g\leq M\); \\
20: if (\(\|x_{n}-y_{m}\|\leq\|x_{n}-y_{g}\|\)) \\
21: \(r_{nm}=1\), the new value \(U\) mark as \(U_{new}\); \\
22: if (\(|U_{new}-U_{old}|\leq\epsilon\)) \\
23: return step 26; \\
24: else \\
25: return step 18; \\
26: if (\(\|x_{n}-y_{m}\|>R_{0}\)) \\
27: move the object \(n\) out of the cluster \(m\), \(M++\), \(c_{M}=D_{n}\); \\
28: else \\
29: end the algorithm; \\
30: end if \\
31: end if \\
32: end if \\
33: Output \(B=\{B_{m}|m=1,2,\ldots,M\}\), \(C=\{c_{m}|m=1,2,\ldots,M\}\) \\ \hline \end{tabular}
\end{table}
Table 2: The pseudo-code of adaptive K-means algorithm.  
of the LTE standard. The output module mainly includes the preservation, analysis and drawing operation of each simulation data.  
As mentioned above, the simulation is based on event-driven and each event corresponds to the transmission of a message, which can be a signaling transmission or data transfer process during a random access process. All data are listed in the virtual queue and sorted according to the transmission time. In each emulation step, we remove the next message from the virtual line and handle the appropriate event. Events fall into two main categories. One category is the event that the device that does not connect to the base station initiates the access, then carries on the signaling transmission simulation action of the random access process. The other category is the device that has been connected to the base station. Then the event will upload data. This type of device performs data transmission simulation actions.