# Distributed Dynamic Cluster-Head Selection and Clustering for Massive IoT Access in 5G Networks
## 3 System Model
### Algorithm Design  
Perhaps, using different methods of selecting a cluster header device differs the energy consumption in the intra-cluster communication. Additionally, different cluster heads and state of the channel of base stations will exert an impact on the amount of data carried by each unit RB in the communication between them. Therefore, the choice of the cluster head will be closely related to the two links. We regard the selection of the sink node device as a function:  
\[y_{m}=\max_{x_{D_{k}}}\{\frac{1}{N_{m}-1}\sum_{x_{D_{n}}x_{D_{k}}\in G_{m},\mu \
eq k}\left\|x_{D_{n}}-x_{D_{k}}\right\|+w\cdot h_{x_{D_{k}}}^{BS}\} \tag{7}\]  
Taking into account the state of the channel between the cluster header device and the base station, we apply the adaptive K-means algorithm to the cluster set. It is also required to select the cluster head for each cluster so that we can obtain the final location of them. In the equation, the constant \(w\) considers as the weight factor which affects the channel gains. In addition, it will consume the least energy when constant \(w\) equals 1 [19]. The device \(D_{n}\) belongs to the cluster \(m\), the value of \(r_{D_{n}m}\) equals 1, that is, \(D_{n}\in G_{m}\), otherwise equals 0. The variation \(x_{D_{n}}\) represents the position of the device \(D_{n}\) and \(y_{m}\) represents the cluster head position of the \(m_{th}\) cluster. According to the above analysis, the objective algorithm function is described as:  
\[U=\sum_{D_{n}=1}^{N}\sum_{m=1}^{M}r_{D_{n}m}\|x_{D_{n}}-y_{m}\|^{2} \tag{8}\]  
In the same random access time slot, according to their density, the activated devices are clustered in a way such that the adjacent allocates in one cluster. When multiple active devices are included in a different cluster, the center coordinates are taken as the result of clustering, and the number of clusters is the required value. After that, to get clustered sets, we bring the values into the K-means algorithm. Table 2 shows the pseudo-code. The clustering preprocessing is mainly to obtain the two parameters required for the K-means algorithm \(k\) and the initial clustering center \(C=\{c_{m}|m=1,2,\ldots,M\}\). Here we use the simplified Density-Based Spatial Clustering of Applications with Noise (DBSCAN) algorithm for clustering preprocessing. To get the parameters \(k\) and the initial clustering center \(C=\{c_{m}|m=1,2,\ldots,M\}\) of the K-means algorithm. We process the small-area selection part by referring to the basic idea of the DBSCAN clustering algorithm, and the BSs according to its density clustering, the adjacent distance is divided into a cluster, the cluster contains multiple BSs, taking the center coordinates as the result of clustering, the number of groups is the desired value. Steps 1-16 of the Table 2 algorithm are the detailed procedures of DBSCAN. MinP \begin{table}
\begin{tabular}{c c} \hline
**Parameter** & **Notation** \\ \hline Bandwidth & \(B_{D}\) \\ Channel gain & \(h_{D_{n}}^{c_{n}}\) \\ Normal Device & \(D_{n}(n=1,\ldots N)\) \\ The cluster set & \(G_{m}\) \\ The cluster head of the \(m_{th}\) cluster & \(c_{m}\) \\ Number of devices in the cell & \(C=\{c_{m}|m=1,2,\ldots,M\}\) \\ The transmission power of the Machine Type Communications (MTC) device \(D_{n}\) & \(p_{D_{n}}\) \\ The transmission power of the cluster header device \(c_{m}\) on \(l_{th}\) Resource Block (RB) & \(p_{c_{m}J}\) \\ The number of bits of the device \(D_{n}\) data packet & \(S_{n}\) \\ The total amount of data received by the cluster header device \(c_{m}\) in the cluster and & \(D_{c_{m}J}\) \\ transmitted by the \(l_{th}\) RB & \\ The link data rates of the device and the cluster header device & \(r_{D_{n}}^{c_{n}}\) \\ The link data rates of the cluster header device and the base station & \(r_{c_{m}J}\) \\ The total energy consumption & \(EC_{sys}\) \\ \hline \end{tabular}
\end{table} 
Table 1: Notations introduced in system model. represents the minimum number of points in the adjacent domain of the core object, and \(Eps\) represents the radius of the field.