# Adaptive Clustering of Users in Power Domain NOMA
## 4 User Clustering Algorithm  
Evolutionary algorithms are commonly used in data streaming in problems where the number of clusters is unknown, no data characteristics are known, and the number of clusters is a dynamic parameter. The issue of clustering users in NOMA networks has these characteristics, although most works address a fixed number of clusters. Therefore, in this work, we propose an algorithm based on the DenStream evolutionary algorithm, defined by [32], to solve the problem of clustering users in NOMA systems. The proposed algorithm can adapt to the arrival of new users, i.e., it creates new clusters without running the algorithm for each new user of the system. The algorithm can be divided into two stages: an online stage, responsible for maintaining its clusters, and an offline stage, responsible for generating the final clusters and defining the power coefficient of each user in response to a BS demand. Every time a user arrives, an attempt to merge with an existing cluster is made. If this is not possible, as it does not meet the requirements of the existing clusters, a new cluster is created for this user as illustrated in Figure 2.  
At each period \(t=T\), where \(t=[0,\infty)\) is the current instant of time, maintenance of the existing clusters is performed as illustrated in Figure 3. The proposed algorithm is sensitive to outliers and changes in the user's channel gain. Unlike the original DenStream, the proposed method does not discard the user when they have a significant channel gain change; they are removed from the cluster and reinserted into the system's input queue. The same happens with users that are detected as outliers to confirm that that the outlier was not mislabeled. Different from the original DenStream, in which clusters are defined by weight (\(W\)), center (\(C\)) and radius (\(Ray\)). The proposed method replaces the center and radius with the channel gain list of each user (\(Lg\)) and the estimation of the gain of each user in time (\(Lg(t)\)). These clusters are classified as potential clusters (p-clusters) and outlier clusters (o-clusters); p-clusters can become final clusters, and o-clusters are treated as noise. A new user \(i\) can join a p-cluster \(j\) if, with its inclusion, the standard deviation (\(\sigma\)) of the cluster is greater than \(\eta\) and less than \(\varphi\), both given in percent, and the cluster satisfies the SIC constraint as defined by:  
\[\left(p_{i}-\sum_{k=1}^{i-1}p_{k}\right)\gamma_{i-1}\geq P_{tol},\forall_{i\in j}, \tag{8}\]  
where \(p_{i}\) is the power of user \(i\), and \(P_{tol}\) is the minimum power difference required to distinguish between the signal to be decoded and the remaining non-decoded message  
Figure 3: Cluster maintenance step. Each cluster is analyzed for outlier detection and channel gain variation in each user. Figure 2: Proposal clustering algorithm. No cluster exists when starting the algorithm, so one is created for the user who arrives on the network. Then, new users arrive and are grouped according to their features. signals. If more than one cluster satisfies the restrictions, priority will be given to the one with the least number of users. If no p-cluster can cluster a new user, the system joins the new user to an o-cluster with the same restriction described above. If the user does not meet the conditions to join any clusters, the system creates a new o-cluster to cluster this user as seen in Algorithm 1. As it is an evolving data stream, the roles of clusters and outliers can change as new users arrive in the communication system because when new users are grouped in an o-cluster, its weight (\(W_{j}\)) increases as defined by:  
\[W_{j,new}=\sum_{m=1}^{M}w_{j,m}f(t)+w_{new}, \tag{9}\]  
where \(f(t)=2^{-\lambda t}\) is called the forgetting function, for \(\lambda>0\). This function controls the speed at which the o-clusters become irrelevant. The higher the value, the faster the weight of o-clusters decreases, decreasing the chances of making it a p-cluster.