## 4 The Proposed Scheme HFECS
### Cluster Formation  
In HFECS, the BS executes the election procedure and creates a CH election set. Initially, when \(C_{R}=1\), the BS adds \(k\) sensor nodes with highest values of \(\alpha_{\sigma(i)}\) in the CH election set after executing the election procedure given in Algorithm 1 and then invokes those \(k\) sensor nodes by sending them a CH_Election_set message. After receiving the CH_Election_Set message from the BS, the potential CH starts preparing its CH_announce message and then send this message to all working neighbors in that cluster to advertise its role as a potential CH. The pseudocode for this procedure is given in Algorithm 2. If the CH_announce message is sent by multiple potential CHs, then CMs send Connection Request 'Con_Req' message to the CH with highest attribute values \(\alpha_{\sigma(4)}>D_{\text{F4}}\). For example, if a neighboring sensor node receives CH_announce from multiple potential CHs, then the sensor node becomes a cluster member of that CH which offers better link quality with that neighboring sensor node in comparison to other CHs. However, if the CH_announce message is sent by a single potential CH, then CMs send a Con_Req message to that CH without any delay. Meanwhile, the new CH creates a CM_set and adds all the working CMs in CM_set after receiving the Con_Req messages from CMs. Subsequently, the new CH transmits the TDMA schedule to all CMs in that cluster, keeping in view the asynchronous working-sleeping cycle of CMs. This TDMA schedule for every CM should be selected vigilantly from a CH as the timeslot for forwarding the sensory data to the CH should be within working time of that CM. Each CM extracts its own CM timeslot from the TDMA schedule sent by the CH, stores the CM timeslot in its local buffer and waits until the CM timeslot becomes current timeslot. The pseudocode for CM task execution is given in Algorithm 3. ```
Input: CH election procedure Output: Potential CH advertising its role and making local decision for data fusion Begin:
1. if(\(C_{R}=1\)), then
2. BS executes the CH election procedure
3. BS creates a CH election set
4. BS adds \(k\) sensor nodes in CH election set with highest (\(\alpha_{\sigma(i)}>D_{\text{F1}}\))
5. BS invokes \(k\) working sensors with highest attribute values in CH election set by sending
6. CH_Election_Set message
7. endif
8. Wait for collected data from CHs
9. if(final prediction result received from CH), then
10. Evaluate the collected data to determine the possibility of event happening
11. if(event happened)
12. Perform standard operation procedure
13. endif
14. endif
```  
**Algorithm 2** HFECS (BS Side)  
The construction of OCRG is very important to understand the asynchronous working-sleeping cycle of sensor nodes. Therefore, we need to construct an OCRG to analyze the opportunistic connections between CM-CH and CM-CM in a heterogeneous WSNs. When the CM timeslot becomes the current timeslot, \(V_{CM(i)}\) calculates its link connectivity with \(V_{CM(j)}\) in terms of time-frequency parameter, residual energy, LQR, distance from the BS and Nsupport as per Equation (12),  
\[ \begin{array}{l}L_{V_{CM(i)}V_{CM(j)}}=\begin{array}{c}max\\ V_{CM}\in S_{j}\end{array}\left\{\alpha TF_{V_{CM(i)}V_{CM(j)}}+\beta R_{E,V_{ CM(i)}V_{CM(j)}}+\gamma S/N_{V_{CM(i)}V_{CM(j)}}+\ \alpha D_{\text{tbBS}(CM(i))}+\ \delta N_{\text{support}(CM(i))}\right\}\end{array}  \tag{12}\]  
where \(i=j=1:\frac{N}{N_{C}}-2\), \(TF_{V_{CM(i)}V_{CM(j)}}\) is the time-frequency parameter between \(V_{CM(i)}\) and \(V_{CM(j)}\), \(R_{E,V_{CM(i)}V_{CM(j)}}\) is the residual energy of node \(V_{CM(i)}\) and \(V_{CM(j)}\), \(S/N_{V_{CM(i)}V_{CM(j)}}\) is the link quality factor between \(V_{CM(i)}\) and \(V_{CM(j)}\), \(D_{\text{tbBS}(CM(i))}\) is the distance to the BS from \(V_{CM(i)}\) and \(N_{\text{support}(CM(i))}\) is the number of sensor nodes supported by \(V_{CM(i)}\) in case \(V_{CM(i)}\) becomes \(V_{CH}\).