# A Relay Optimization Method for NOMA-Based Power Line Communication Systems
## 3 Optimization Process and Performance Analysis
### Uplink from Relay Node to Other Users
The specific calculations are as follows:  
\[C_{min}=R_{min}\times\frac{1}{N}\sum_{i=1}^{N}B_{i} \tag{35}\]  
\[\text{BER}_{i}=0.5\cdot\text{erfc}\Big{(}\sqrt{\text{SINR}_{i}}\Big{)} \tag{36}\]  
where \(N\) is the total number of users, \(B_{i}\) is the bandwidth of the \(i\)-th user, \(\text{BER}_{i}\) is the bit error rate of the \(i\)-th user, \(\text{SINR}_{i}\) is the signal-to-noise ratio of the \(i\)-th user, and erfc is the complementary error function. Input: Initial power values, predicted CSI, noise power, and minimum capacity. Process: Set the minimum capacity requirement. Run the heuristic optimization function to obtain optimized power values. Select the relay node that minimizes total power and meets communication quality requirements. Output: Best relay user index. After optimization, the system's performance needs to be analyzed. In this paper, performance indicators for the LSTM model's CSI prediction include Mean Absolute Error (MAE) and Mean Squared Error (MSE). MAE is the average of the absolute values of all prediction errors, reflecting the average difference between predicted and actual values:  
\[\text{MAE}=\frac{1}{M}\sum_{i=1}^{M}\left|\text{CSI}_{i}-\text{CSI}_{i}\right| \tag{37}\]  
where \(\text{CSI}_{i}\) is the actual value, \(\text{CSI}_{i}\) is the predicted value, and \(M\) is the number of samples. MAE is easy to interpret, with error units consistent with the original data. It is not sensitive to outliers and does not become amplified by extreme error values as MSE does. However, it does not reflect the impact of large errors well. MSE is the average of the squares of all prediction errors. It reflects the average squared difference between the predicted and actual values:  
\[\text{MSE}=\frac{1}{M}\sum_{i=1}^{M}(\text{CSI}_{i}-\text{CSI}_{i})^{2} \tag{38}\]  
MSE, due to the squared term, is more sensitive to large errors and reflects the impact of outliers. To evaluate the entire system, metrics such as SINR, system capacity, and power consumption are used. The system includes users with relays enabled and those without relays, and performance metrics are calculated separately for each. For relay users, the SINR is:  
\[\text{SINR}_{i}^{\text{relay}}=\frac{P_{i}\cdot\text{CSI}_{i}}{\sigma^{2}} \tag{39}\]  
For non-relay users, the SINR is given by:  
\[\text{SINR}_{j}^{\text{non-relay}}=\frac{P_{i}\cdot\text{CSI}_{j}}{\sigma^{2}} \tag{40}\]For relay users, the capacity \(C_{i}^{\text{relay}}\) can be calculated as follows:  
\[C_{i}^{\text{relay}}=\log_{2}\Bigl{(}1+\text{SINR}_{i}^{\text{relay}}\Bigr{)} \tag{41}\]  
For non-relay users, the \(C_{j}^{\text{non-relay}}\) is given by:  
\[C_{j}^{\text{non-relay}}=\log_{2}\Bigl{(}1+\text{SINR}_{j}^{\text{non-relay}} \Bigr{)} \tag{42}\]  
The total system capacity \(C_{total}\) is the sum of the capacities for both relay users and non-relay users:  
\[C_{total}=\sum_{i\in\text{relay}}C_{i}^{\text{relay}}+\sum_{j\
eq\text{relay}} C_{j}^{\text{non-relay}} \tag{43}\]  
Through the above steps, a new optimization algorithm was designed and implemented. This algorithm combines deep learning models to predict CSI with heuristic optimization algorithms for power allocation and relay selection. It ensures that total power is minimized while meeting communication quality requirements in a system combining NOMA and OFDM and selects the optimal relay position. The specific process of the algorithm is shown in Figures 3 and 4. Figure 3 is a flowchart of the LSTM model training and prediction process, and Figure 4 is a flowchart of the simulated annealing optimization process following the prediction. The following is the simulation verification and concrete analysis of this method. As shown in the figure, the channel gain exhibits exponential decay with increasing distance. From a distance of 1 to 5, the channel gain decreases from 1 to nearly 0. At shorter distances (e.g., 1), the channel gain is highest, indicating optimal transmission efficiency.