# Node Screening Method Based on Federated Learning with IoT in Opportunistic Social Networks
## 3 Methods
### Description of the Transmission Process
The transmission rate of the parameter data of the federated learning task between the terminal equipment and micro base station and which between the micro base station and the macro base station can be expressed as  
\[v_{\lambda}^{n}=W_{n}w\bigg{(}1+\frac{e_{n}C_{n}}{N_{0}W_{n}}\bigg{)},n\in N_{\lambda} \tag{10}\]  
\[v_{\lambda}^{n}=W_{m}w\bigg{(}1+\frac{e_{m}C_{m}}{N_{0}W_{m}}\bigg{)},m\in M_{\lambda} \tag{11}\]  
Among them, \(W_{n}\) and \(W_{m}\) respectively represent the available bandwidth between the device and the micro base station and between the device and the macro base station. \(C_{n}\) is respectively expressed as the channel gain between the device and the micro base station and \(C_{m}\) means that between the micro base station and the macro base station. \(e_{n}\) and \(e_{m}\) represent respectively the transmit power of the device and the micro base station, \(N_{0}\) represents the noise power spectral density. Therefore, the total transmission time for the device to upload the local parameters to the model aggregation server is  
\[t_{\lambda}^{tra}=\frac{\left|\mu_{m,n}^{*}\right|}{v_{\lambda}^{n}}+\frac{ \left|\mu_{m,n}^{*}\right|}{v_{\lambda}^{n}},\ n\in N_{\lambda},m\in M_{\lambda} \tag{12}\]  
where \(\mu_{m,n}^{*}\) represents the size of the local model parameter to be uploaded by the terminal device \(\lambda\). The calculation delay of the terminal equipment can be expressed as  
\[U_{\lambda}=\sum_{m\in M_{\lambda}}\sum_{n\in N_{\lambda}}U_{m,n} \tag{4}\]0  
where \(\left|U_{m,n}\right|F_{\lambda}\) represents the number of CPU cycles required to complete the federated learning task \(\lambda\) on the terminal n, and \(f_{m,n}\) represents the CPU frequency when the terminal device executes the federated learning task. The total delay of each round of federated learning is determined by the terminal device with the largest delay. Therefore, the total delay is defined as  
\[U_{\lambda}=\sum_{m\in M_{\lambda}}\sum_{n\in N_{\lambda}}U_{m,n} \tag{4}\]1  
For a federated learning task \(\lambda\in\Lambda\), the node selection problem can be summarized as selecting the node set \(N_{\lambda}\in N\) for each iteration, so that the accuracy of this training is the best, which means the total loss function is the smallest, and the constraints are the training and transmission delays. They must be controlled within a certain range. It can be seen that the above problem is a typical NP problem. In a changeable edge network, the node selection strategy needs to be changed as the environmental status information changes. The DRL-based node selection framework [33; 34; 35; 36; 37; 38] can continuously interact with the environment and learn node selection strategies to obtain the greatest return. The DRL-based node selection framework proposed in this paper is shown in \[U_{\lambda}=\sum_{m\in M_{\lambda}}\sum_{n\in N_{\lambda}}U_{m,n} \tag{4}\]2 It consists of three parts: environment, agency, and reward. The environment mainly includes network status, terminal equipment, and target model information. The agent interacts with the environment, starts from a state, chooses actions according to its strategy distribution, and obtains rewards. Agents obtain batch samples of actions, rewards, and environmental status to update the actor-critic (AC, actor-critic) network. There are often a large number of terminal devices participating in FL training in edge networks. When dealing with node selection problems, the learning rate of the traditional AC algorithm is difficult to determine, this problem easily leads to slow or premature convergence [39; 40; 41; 42; 43; 44]. The convergence performance is not ideal. Therefore, this paper designs a DPPO-based node selection algorithm based on the idea of multithreading and PPO algorithm design.