# Privacy-Preserving Handover Optimization Using Federated Learning and LSTM Networks
## 3 Method
### Dynamic Handover Algorithm  
The Algorithm 1 is designed to optimize handover decisions in wireless communication systems by utilizing predicted signal strengths. It aims to improve the overall network performance by reducing unnecessary handovers. The algorithm takes as input the test set of handover triggers (ho_trig_test), predicted Reference Signal Received Power (RSRP) values (predicted_rsrp), predicted nearest Reference Signal Received Power (NRSRP) values (predicted_nrxrsrp), and the Mean Absolute Error of the RSRP predictions (mae_rsrp). A key parameter in this algorithm is the continuity_threshold, set to 3, which determines the minimum count for a valid handover decision. ```
Input:ho_trig_test, predicted_rsrp, predicted_nrxrsrp, mae_rsrp Output:optimized_handover_predictions, handover_trigger_points, event_a3_handover_points Initialize:handover_trigger_points \(\leftarrow\)[], optimized_handover_predictions \(\leftarrow\)zeros_like(ho_trig_test), continuity_count \(\leftarrow\)0, base_dynamic_threshold \(\leftarrow\)mae_rsrp, \(ping\_pong_effects\gets 0\), time_window \(\leftarrow\)100 fori in range(len(val_df) - time_window_)do window_data \(\leftarrow\)val_df[i : \(i+time\_window\)] if(window_data[\({}^{\prime}\)CellID\({}^{\prime}\)] \(\
eq\) window_data[\({}^{\prime}\)CellID\({}^{\prime}\)] and window_data[\({}^{\prime}\)CellID\({}^{\prime}\)] \([0]=\)window_data[\({}^{\prime}\)CellID\({}^{\prime}\)][\(-2\)] and window_data[\({}^{\prime}\)CellID\({}^{\prime}\)][\(-1\)] = window_data[\({}^{\prime}\)CellID\({}^{\prime}\)][\(1\)]) then ping_pong_effects \(\leftarrow\)ping_pong_effects \(+\)1 endif endfor adjusted_TTT_threshold \(\leftarrow\)base_TTT_threshold \(+\)ping_pong_effects for each(pred_rsrp,pred_nrxrsrp) in zip(predicted_rsrp, predicted_nrxrsrp) with index \(i\)do if\(i>0\)then prev_avg_rsrp \(\leftarrow\)mean(predicted_rsrp[max(\(i-3,0\) to \(i\)]) prev_avg_nrxrsrp \(\leftarrow\)mean(predicted_nrxrsrp[max(\(i-3,0\)) to \(i\)]) else prev_avg_rsrp \(\leftarrow\)pred_rsrp prev_avg_nrxrsrp \(\leftarrow\)pred_nrxrsrp endif dynamic_threshold \(\leftarrow\)base_dynamic_threshold \(\times\)(1 + 0.5 \(\times\) abs(prev_avg_rsrp - pred_rsrp)/mae_rsrp) ifpred_rsrp \(>\)prev_avg_rsrp - dynamic_threshold and pred_nrxrsrp \(>\)prev_avg_nrxrsrp then continuity_count \(\leftarrow\)continuity_count \(+\)1 if continuity_count \(\geq\) continuity_threshold then optimized_handover_predictions[\(i\)] \(\leftarrow\)1 endif else continuity_count \(\leftarrow\)0 endif endfor Return: optimized_handover_predictions, handover_trigger_points, event_a3_handover_points
```  
**Algorithm 1** Dynamic Adjustment Algorithm  
The algorithm initializes several variables: handover_trigger_points as an empty list to store the points where handovers are triggered, optimized_handover_predictions as an array of zeros with the same shape as ho_trig_test, and continuity_count to trackthe count of consecutive valid handover conditions. Additionally, base_TTT_threshold is set to 10, representing the base Time to Trigger threshold, and base_dynamic_threshold is set to the mean absolute error of RSRP predictions. Other variables initialized include newalcount set to 0, ping_pong_effects set to 0, and time_window set to 100, which defines the size of the analysis window. The next step will start calculating the number of ping-pong effects, which occur when a mobile device rapidly switches back and forth between two base stations. This is conducted by sliding a window of size time_window over the dataset and checking if the first cell in the window is different from the last cell, but matches the second-to-last cell, and if the last cell matches the second cell. If these conditions are met, the ping-pong effect counter is incremented. After counting the ping-pong effects, the algorithm adjusts the Time-To-Trigger threshold by increasing it based on the number of detected ping-pong effects.