# Clustered Distributed Learning Exploiting Node Centrality and Residual Energy (CINE) in WSNs
## 3 CINE Solution
### Overview of CINE  
Considering the intrinsic limitations of WSN devices and the limited computational and energy capabilities, we have designed and implemented a methodology that allows one to guarantee network efficiency trading off lifetime and reliability. More specifically, we assume to have a WSN where nodes have severe resource limitations. Although the support of solutions for the execution of machine learning in WSNs has been advocated in the recent past [1], to cope with limited node capabilities, we use clusters inside the network and the selection of few cluster representative nodes to simplify the problem of device model training. Accordingly, we assume that only a few nodes, denoted as _cluster heads_ (CHs), perform training, while other cluster nodes, denoted as cluster members (CMs), execute inference by only applying the model disseminated by their CH. In order to balance the consumption of energy and processing resources, we let the CH role, which is the most demanding in terms of energy consumption, rotate among nodes belonging to the same cluster. Accordingly, we introduce a CH selection mechanism. The mechanism considers that \(N_{C}\) regions have been defined in the network area and that a cluster consists of all nodes located in a given region. Regions are defined by exploiting the statistical knowledge of node distribution in the area so that the number of nodes in all of the clusters is approximately the same. Let \(N_{CM}\) be the average number of nodes in a cluster. Note that the detailed policies for the identification of clusters and the consequent selection of cluster members is out of the scope of the current paper. For an extensive discussion of the design of clustering algorithms for ad hoc and sensor networks that are guaranteed to have an assigned number of cluster members, please refer to [26]. We assume that each node has the information required to identify its cluster at its startup phase. This can be easily achieved by using position information along with the awareness of the above-mentioned cluster regions. The first node joining the cluster will be the initial cluster head. We define a time window duration as \(\tau_{w}\), which represents the interval during which the cluster head does not change and is a constant known to all of the network nodes. At the end of the window, the current cluster head broadcasts a COMPETITION_INITIATION message to all cluster members by applying any appropriate geo-cast mechanism [27], to identify the CH for the next time window. This starts a competition phase that lasts for a time interval equal to \(\tau_{c}\). The appropriateness of the \(j\)-th node for the CH role is related to a number of parameters, such as its residual energy (\(rE_{j}\)), its centrality (\(C_{j}\) discussed later in Section 3.2), and its computing capabilities (\(P_{j}\)). Each node \(j\), after evaluating a _penalty_ value, \(\mathcal{G}_{j}=\phi(rE_{j},C_{j},P_{j})\), will answer back by broadcasting the value of its penalty inside a COMPETITION_TERMINATION message, which also carries the sender ID, i.e., \(j\). The broadcast will be executed at a time \(t=\tilde{t}+\delta_{j}\leq\tau_{C}\) where \(\delta_{j}\) is a a random variable generated according to a probability distribution whose average is proportional to \(\mathcal{G}_{j}\). In this way, nodes with smaller \(\mathcal{G}_{j}\) values (i.e., a lower penalty) will answer before the others. Othercluster members, upon hearing the COMPETITION_TERMINATION message, will not answer back and identify the new CH as the sender of the COMPETITION_TERMINATION message. For the following \(\tau_{w}\) interval, the CH will remain unchanged. During this \(\tau_{w}\) interval, training will be executed only by the CH, while cluster members will only perform inference. In case the residual energy at a CH decreases below a threshold, \(rE_{Tthr}\), before \(\tau_{w}\), a new competition procedure will be triggered to identify a new CH. This will be done through a COMPETITION_REQUEST message sent by the CH node.