# Energy-Efficient Resource Allocation for Downlink Non-Orthogonal Multiple Access Systems
## 3 Proposed Algorithm  
### Subchannel Assignment Algorithm (SAA)  
The exhaustive search algorithm, as everyone knows, is the best performance for confident channel assignment. However, it needs to traverse all users; that is, the complexity increases exponentially with the increase in the number of users and the number of subchannels. High complexity in exchange for performance optimization is not desirable in practical applications. Inspired by [34], to reasonably allocate users and subchannels, we propose a low-complexity greedy algorithm that can not only maximize the energy efficiency of subchannels, but also improve the data rate of weak users and ensure user fairness. To simplify the calculation, we assume that the initial power of all subchannels is equal, and the fractional power allocation algorithm is used to allocate power among the multiplexed users on each subchannel. When allocating subchannels, we propose an algorithm that first sorts the subchannels in ascending order according to the magnitude of the user's worst channel gain on each subchannel and then arranges the matching order of subchannels. When a subchannel matches, it matches the user with the most substantial channel gain on the local channel. In the following matching process, the matched users are excluded from consideration in the matching process. According to the sorting of subchannels, the next subchannel selects only the user with the best channel quality on this channel among the unmatched users. Based on the above matching principle, the remaining users will perform the next round of matching with the subchannel when all the subchannels have reached a user. This subchannel allocation algorithm ensures that the channel gain of the two matched users is as high as possible, thus helping to improve user fairness and reduce the probability of disruption. The detailed flow of the proposed subchannel allocation algorithm is shown in Algorithm 1. ```
1:Construct a channel gain matrix with \(M\) users \(m\in\{1,2,\cdots,M\}\) and \(N\) subchannels \(n\in\{1,2,\cdots,N\}\). 2:Construct the set \(U_{unmatch}\) to record unmatched users. 3:while\(\{U_{unmatch}\}\) is not empty do
4:for\(n=1\) to \(N\)do
5: To compare the channel gain of users on each sub-channel and to select the worst channel gain. 6: Sort the matching order of each subchannel and the ascending order is based on the N worst channel gains selected. 7:endfor
8:if\(\textbf{then}|U_{unmatch}|>M/2\)
9:for Sorted n subchannel do
10: Match the sorted subchannels to the user with the best channel quality on the subchannel. 11: Remove the matched users from \(U_{unmatch}\)
12:endfor
13:endif
14:if\(\textbf{then}|U_{unmatch}|\leq M/2\)
15:for Sorted n subchannel do
16: Match the sorted subchannels to the the remained user of \(U_{unmatch}\) with the best channel quality on the subchannel. 17: Remove the matched users from \(U_{unmatch}\)
18:endfor
19:endif
20:endwhile
```  
**Algorithm 1** Proposed Subchannel Allocation Algorithm. In addition, to clarify the subchannel assignment algorithm in detail, we take the NOMA system with four subchannels and two users for each subchannel as an example. Assume that the channel gain matrix of four subchannels and eight users is  
\[H_{4\times 8}=\left[ \begin{array}{cccccc}1.32&5.78&0.67&1.21&1.06&4.37&2.15&2.23\\ 0.07&3.21&0.87&3.54&1.12&5.01&1.87&4.33\\ 2.38&1.33&4.20&2.68&0.84&1.93&1.70&1.39\\ 1.55&1.96&5.84&1.02&3.21&2.10&1.46&2.79\\ \end{array} \right] \tag{10}\]where we take \(SC_{n}\in\{SC_{1},SC_{2},SC_{3},SC_{4}\}\) as the subchannel, that is, each row of the channel gain matrix. \(U_{m}\in\{U_{1},U_{2},\ldots,U_{8}\}\) is expressed as the user, that is, each column of the channel gain matrix. The subchannel matching process is as follows:  
Step 1: The channel gain of users in \(SC_{1}\) is compared. The user with the worst channel gain is \(U_{3}\), whose channel gain is 0.67. Similarly, the user with the worst channel gain in \(SC_{2}\) is \(U_{1}\), and the channel gain is 0.07.