# Power Allocation and User Grouping for NOMA Downlink Systems
## 3 Resource Allocation
### Power Allocation
#### 3.2.1 Power Allocation among the Subcarriers  
At present, more and more studies are using the DL algorithm for resource allocation and have achieved good results. The deep neural network (DNN) is one of the most basic and widely used networks in DL [25]. Therefore, in this paper, the DNN is used for power allocation among the subcarriers. Ideally, multi-carrier NOMA systems are orthogonal frequency division multiplexing (OFDM) combined with NOMA. Therefore, the subcarriers are orthogonal and there is no mutual interference, only noise interference. According to the user grouping result in the previous section, the channel gains, \(\left|h_{n,1}\right|^{2}\) and \(\left|h_{n,2}\right|^{2}\), of two users on the subcarrier \(n\) are compared, and the largest is selected as the equivalent channel gain, \(\left|h_{n}\right|^{2}\). For power allocation among the subcarriers, the optimization problem can be expressed as follows:  
\[\text{max: }B\sum_{n=1}^{N}\log_{2}\left(1+\frac{\left|h_{n}\right|^{2}P_{n}}{ \sigma_{n}^{2}}\right) \tag{8}\]  
\[\text{subject to: }\sum_{n=1}^{N}P_{n}=P_{T} \tag{9}\]  
where (8) represents the maximum sum rate of the system. \(P_{n}\) represents the power of the subcarrier \(n\). (9) indicates that the sum of the subcarrier power is the total transmit power.  
The \(N\) equivalent channel gain, \(\left|h_{n}\right|^{2}\), of \(N\) subcarriers, which we denote as the vector \(\mathbf{H}\), is the input of the DNN. After the neural network is trained, the output of the DNN is normalized transmit power, which we denote as the vector \(\mathbf{\beta}_{n}\). The power can be determined as \(\mathbf{P}_{n}=\mathbf{\beta}_{n}P_{T}\), where \(\mathbf{P}_{n}\) is the vector of \(P_{n}(n=1,2,\ldots,N)\).  
As shown in Figure 3, we design a network with two hidden layers: one input layer, and one output layer. Since the number of subcarriers is \(N\), the input layer size is \(N\). The output is power in the subcarriers. Therefore, the output layer size is \(N\). The first hidden layer contains 15 neurons, and the second hidden layer consists of 10 neurons. Furthermore, we use sigmoid as the activation function: \(y=\frac{1}{1+e^{-x}}\) (\(x\) is the input of the activation function and \(y\) is the output of the activation function). A softmax layer needs to be connected after the output layer to obtain the normalized power. The formula of the softmax activation function is expressed as:  
\[\text{softmax}(y)_{n}=\beta_{n}=\frac{e^{y_{n}}}{\sum_{i=1}^{N}e^{y_{i}}} \tag{10}\]  
where \(y_{n}\) denotes the power value of the \(n\)-th subcarrier and \(\sum_{n=1}^{N}\beta_{n}=1\). In the experiment, we adopt the adaptive moment estimation (Adam) optimizer to update the weight and bias of the network and 0.01 is the learning rate. The back propagation algorithm is used to minimize the loss function, but the optimization goal is to maximize the sum rate. Therefore, the loss function is defined as the inverse of the sum rate, as shown in the following formula:  
\[\text{loss}=\frac{1}{B\sum_{n=1}^{N}\log_{2}\left(1+\frac{\left|h_{n}\right|^ {2}P_{n}}{\sigma_{n}^{2}}\right)} \tag{11}\]  
Compared with traditional DNN usage, our usage does not need large datasets to train the neural network. The channel gain vector is the input of the DNN. When the neural network is trained to minimize the loss function, the output is the power of the subcarriers.