# Simulated Annealing for Resource Allocation in Downlink NOMA Systems in 5G Networks
## 3 Simulated Annealing Based Resource Allocation
### SA for Proportional Power Allocation \(\delta_{n}\)  
SA is performed to determine the power ratio for each subchannel according to the system mode as \(\mu=3\), where the power ratio \(\delta_{n}\) is a value between 0 and 1. In this system design, we consider only two users, \(U_{1}\) and \(U_{2}\), sharing the same subchannel \(SC_{n}\) while considering \(G_{1,n}>G_{2,n}\) and that more power is assigned to \(U_{2}\) and less power to \(U_{1}\). In the NOMA system, \(U_{1}\) can cancel the signal interference power from \(U_{2}\) according to the SIC principle and \(U_{2}\) treats the \(U_{1}\) signal as noise. ```
1. Set the number of iterations \(j\in\{1,2,\ldots,J_{Max}\}\):
2. Initialize temperature T = 100. 3. Set the maximum displacements \(\Delta_{max}=1\). 4. Initialize the user pairing configuration. 5. Initialize random values for \(a_{n}\) as current Best Solution \(C_{B}\) for iteration \(j\). 6. CalculateThroughput function of the initial design \(f_{j}\):
7. If \(f_{j}=2\). 8. Choose a random channel from \(n:N_{sc}\). 9. Change the corresponding \(a_{n}\); where \(a_{n}=a_{n}+\rho\ \Delta_{max}\) and \(\rho\in[-1,1]\). 10. Then denote the change in the new configuration \(C_{4}\) for iteration \(j+1\). 11. Calculate the Throughput function after \(f_{j+1}\)
12. If \(f_{j+1}<f_{j}\) we accept the configuration. 13. Else\(f_{j+1}>f_{j}\)
14. Calculate:\(\Delta f=f_{j}-f_{j+1}\). 15. Generate random number of \(\varepsilon\in(0,1)\)
16. if \(\varepsilon<\varepsilon^{-\frac{\Delta f}{\varepsilon}}\). 17. Accept the new solution. 18. Reduce the temperature (\(T_{j}=T_{j-1}-\alpha\ T_{j-1}\)). 19. Accept the solution. 20. End the Algorithm. ```  
**Algorithm 2**Proposed SA-based Subchannel Power Scheme. Since the power ratio \(\delta_{n}\) is designed in the objective function to allocate more power to the user with a weak channel condition and less power to the user with a good channel condition. The user with a weak channel condition receives the interference power from the user with a good channel condition. For instance, \(U_{2}\) received the signal with the interference of \(U_{1}\), where the power ratio of \(U_{1}\) is a small value due to a small power ratio and weak channel gain. Hence, this looks like the noise same as AWGN. The proportional power factor \(\delta_{n}\) is used to distribute the power for the multiplexed users. The user's throughput on \(SC_{n}\) can be maximized by determining the proportional power factor \(\delta_{n}\) while considering the application of SIC according to the NOMA concept. The SA algorithm is applied in order to find the optimal value of \(\delta_{n}\), where the power ratio \(\delta_{n}\in(0,1)\). The initial design started with a random value of power ratio \(\delta_{n}\) as the current best solution for the objective function, then the power ratio is changed on the selected channel. The objective function is evaluated on the selected channel after the change of the power ratio, and the new solution is accepted if it is higher than the current best solution. Then this new solution is updated in the current best solution set, and the temperature is reduced for the current iteration. The SA algorithm estimated the value of the power ratio, as described in Algorithm 3. The SA algorithm searches for the value of \(\delta_{n}\) that varies between 0 and 1 to maximize the user's throughput. Moreover, the analytical solution of the objective function with respect to \(\delta_{n}\) can be solved by the first derivative. The objective function increases to the near value to a maximum of \(\delta_{n}\) because the first derivative is positive, as proved in Appendix B. Since \(\delta_{n}\) is another variable for objective function maximization, that defined as the maximum boundary value of \(\delta_{n}\) in order to give maximum Throughput. Thus, the proportional power ratio \(\delta_{n}\) can be fixed to a value between 0 to 1 that can maximize the throughput based on the NOMA concept. ```
1. Set the number of iterations \(j\in\{1,2,\ldots,J_{Max}\}\). 2.