Coyote Optimization Based on a Fuzzy Logic Algorithm for Energy-Efficiency in Wireless Sensor Networks

Internet of Things (IoT) is an important technique in the modern wireless telecommunications field. It is based on a collection of sensor nodes connected through wireless sensor networks (WSNs). The lifetime of this network is affected by the battery power of the connected sensor nodes. Network clustering techniques are used to improve energy consumption and extend the lifetime of the WSN. These techniques divide the sensor nodes into clusters and every cluster has a unique cluster head (CH) node. Recently, clustering-based metaheuristic techniques are used to solve this problem and find the optimal CH nodes under certain considerations such as less energy consumption and high reliability. This paper proposes a new clustering scheme for heterogeneous WSN using Coyote Optimization based on a Fuzzy Logic (COFL) algorithm. It uses the coyote optimization algorithm (COA) in conjunction with fuzzy logic (FL) system to reinforce and balance the clustering process for increasing the wireless network lifetime and reducing energy consumption. FL based clustering is adapted to determine a tentative set of CHs. The output of the FL is added as a solution within the initial solutions of the COA. Furthermore, a new fitness function has been adapted to minimize the total intra-cluster distance between each CH node and its cluster members and minimize the inter-cluster distance between the CHs nodes and the base station. An extensive simulation with three different scenarios is performed. The performance of the proposed COFL algorithm is compared with the well-known algorithms; namely low-energy adaptive clustering hierarchy protocol (LEACH) and stable election protocol (SEP) as traditional protocols and also coyote optimization algorithm (COA), grey wolf optimization (GWO), and particle swarm optimization (PSO). The COFL algorithm outperforms other algorithms in terms of alive node analysis, energy consumption, throughput, and central tendency measurements for alive nodes and normalized energy.


I. INTRODUCTION
Internet of Things (IoT) is a communication networking that gained instant importance in modern wireless communications. Wireless Sensor Network (WSN) technology is the main component that the IoT depends on because it consists of a group of sensor nodes connected through wireless media. Fig.1 shows the architecture of the IoT Network. IoT includes many applications such as environmental monitoring and tracking [1], [2], weather [3], industry [4], healthcare [5], The clustering technique is one of the most effective techniques used for managing network energy consumption and increasing network lifetime. The clustering-based hierarchical technique consists of partitioning all sensor nodes into groups known as clusters; every cluster has a leader node known as a cluster head (CH) and the remaining nodes are denoted as cluster members [10], [11]. In the clustering technique, the CHs are accountable for gathering all sensed data from cluster members and transmitting them to the base station (BS).
Furthermore, the CH node selection process is an essential task in the hierarchical clustering technique for enhancing the energy consumption, lifetime, throughput, and stability of the network [12], [13]. Currently, more researchers try to extend the lifetime of the network and reduce the energy consumption by developing the metaheuristic based-clustering algorithms due to the strong limitations of the clustering problem in WSN [14], [15].
In this paper, a coyote optimization based on fuzzy logic (COFL) clustering algorithm is proposed to find the optimal cluster head nodes and cluster the network in a balanced and efficient way, which leads to improve the energy consumption and increase the network lifetime. The COFL is implemented in two phases. In the first phase, the FL system is run to initially select an appropriate set of CHs. It assigns the CHs in an efficient and distributed way based on three input parameters: residual energy (RE), distance from nodes to BS (DBS), and the number of neighboring nodes in the vicinity (ND). In the second phase, the COA is used to enhance overall system performance. It is initialized with the output of the FL system as a good initial solution of the initial population for the COA. This phase uses a newly formulated fitness function for COA that helps the COFL to reach the optimal clustering process.
The performance of the proposed COFL algorithm is compared with the well-known algorithms; namely, COA [16], GWO [17], PSO [18], SEP [19] and LEACH [20]. The results of the experiment prove that the COFL algorithm has better performance than other algorithms in all the scenarios that have been applied.
The rest of the paper is organized as follows: An overview of the related works is described in Section 2. The system model is described in Section 3. The proposed algorithm is formulated in Section 4. The experimental results are offered in Section 5. Finally, the paper conclusion and future work are presented in Section 6.

II. RELATED WORKS
Energy efficiency in WSNs is an important and contemporary goal. More studies were introduced to handle this goal and improve network performance in terms of energy consumption, throughput, load balancing, transmission cost, packet error rate, and latency. Some studies have targeted network communications and data exchange to handle a large amount of data. In these studies, synchronous and asynchronous protocols have been proposed to improve network connectivity, each with its advantages and disadvantages. Many researchers have proposed ways to improve the energy saving of the sensor node by modifying only some of the features of these technologies [21], [22]. Other studies considered the load balancing problem to handle network congestion and data redundancy to improve energy efficiency. When sensor nodes that are connected to the same resource send data at the same time, there will be congestion or failure of data received by the resource that leads to delay-sensitive data reception. Load balancing techniques are used to solve this data reception delay problem and improve network energy consumption [23], [24]. Clustering routing protocols play a significant role in reducing energy consumption and improving energy efficiency in WSNs. Clustering routing protocols in this way can be categorized into four main categories based on their working methods: traditional, metaheuristic, fuzzy, and hybrid algorithms.
A. RELATED CLUSTERING ROUTING PROTOCOL 1) TRADITIONAL ALGORITHMS Low energy adaptive clustering hierarchy (LEACH) [20] is a simple hierarchical clustering protocol in WSN. This protocol contains two phases: The setup phase contains CH selection based on the random probability and the steady-state phase contains cluster formation using single-hop communication with CH to the BS. LEACH has shortcomings that include residual energy among the sensor nodes which isn't considered when choosing CHs and uneven distribution of CH node. Thus, it leads to poor network performance.
Stable election protocol (SEP) is one of the standard algorithms used in energy efficiency problem [19]. It based on the LEACH protocol but works in heterogeneous networks. There are two types of nodes known as advanced and normal nodes. In SEP protocol the selection chance of the node to become CH is accomplished according to the residual energy. The shortcoming of the SEP protocol is that the CHs selection through the two types of nodes is not dynamic. VOLUME 8, 2020 Enhanced clustering hierarchy (ECH) is a clustering hierarchy algorithm that improved the network lifetime by reducing data redundancy in this network [23]. It uses a sleeping-waking mechanism for neighboring and overlapping nodes to reduce data redundancy. However, it suffers from low improvement in the network lifetime. Also, it does not cover the effect of changing the position of sink node on the network lifetime.
Although the traditional algorithms are simple to implement, they can't find the optimal solution especially when the problem becomes complex or too large. Metaheuristic algorithms are introduced to solve this Non-deterministic Polynomial-time (NP)-complete problems.

2) METAHEURISTIC ALGORITHMS
Genetic algorithm (GA) is a very popular algorithm for extending the network lifetime through reducing energy consumption [25]. The shortcomings of this procedure include the large memory space and huge computational time.
Fitness value-based improved GWO (FIGWO) is introduced in [26]. A fitness function is designed based on the nodes having the highest energy as well as the nodes placed near the BS. They have a higher chance of selection as CHs. However, it suffers from balancing the load among the CHs and does not handle network heterogeneity.
Energy center-based routing protocol (EC-PSO) that is based on standard PSO is introduced to maximize the energy of nodes that are close to CHs to avoid hotspot problems [27]. This approach used two stages of clustering. In the first stage, the geometric method has been used for selecting the CH. In the second stage, it uses the PSO algorithm. However, this algorithm completely ignores the distance among nodes, CHs, and base stations when constructing fitness function, thus impacts energy consumption. Also, it does not cover different sink node scenarios.
Chicken swarm optimization-based clustering algorithm (CSOCA) is proposed in order to improve network lifetime and also CSOCA itself by employing GA; named CSOCA-GA, to optimize the energy usage in WSNs [28]. In this method, the author arranged their fitness values in order to select the best nodes that work as CHs in each round and applied the CSOCA-GA crossover and mutation processes to increase the population diversity. However, it does not handle network heterogeneity.
Numerous researchers have found many ideas with respect to usage of fuzzy logic alone or hybrid to select an appropriate and effective CH. Numerous clustering approaches have been suggested on the basis of FL to prolong the lifetime of the network [29].

3) FUZZY SYSTEM
The MOFCA protocol is proposed in [30] where CHs are selected using a fuzzy logic approach. The main target is to overcome the hotspot problem which arises due to multi-hop communication.
The CHEF algorithm is proposed in [31] to select CHs randomly in each round by using two fuzzy parameters namely residual energy and distance. Each CH determines its chance value and then advertises it by using fuzzy if-then rules. CHEF improves the lifetime of the network but cause the network overhead and unnecessary traffic load.
Fuzzy Logic-based Clustering Algorithm (CAFL) was introduced to improve the WSNs lifetime [32]. It used fuzzy logic for CHs selection and also clusters formation processes. The inputs of the fuzzy logic in the case of CHs selection were the closeness to the sink and residual energy, and in the case of clusters formation processes were the closeness to CHs and residual energy of CH.
Several hybrid algorithms have been presented for the WSN clustering problem to benefit from the advantages of each algorithm features and achieve improved results with regard to network lifetime and energy consumption problem.

4) HYBRID ALGORITHMS
A novel method for CHs selections is proposed in [33] based on PSO and fuzzy. In this method, the fuzzy is used for initial clustering and the PSO is utilized for the CH selection. This method prolongs the lifetime of the network. However, the shortcoming of this method is that it isn't suitable for initial clustering to minimize the computation time.
In [14] an ACOPSO hybrid algorithm between ant colony optimization (ACO) and PSO based on energy-efficiency clustering and tree-based routing protocol is presented. Firstly, clusters are formed based on remaining energy in each node, and then hybrid comes to improve the inter-cluster data aggregation. This method does not use various levels of heterogeneity of WSN settings but also extends the lifetime of the network.
Two-tier distributed fuzzy logic-based protocol (TTDFP) was presented to improve the efficiency of data aggregation operations in multi-hop WSNs by adjust the maximum competition radius and threshold parameters [34]. TTDFP is a combination between FL and the simulated annealing (SA). The TTDFP protocol includes two tiers. In the first tier, the proposed fuzzy clustering algorithm selects the set of CHs that maximize network energy efficiency. Then, in the second tier, the fuzzy routing technique is used to obtain the optimal routing path from CH nodes to the sink node. Finally, these two levels are combined into a two-tier protocol to provide an efficient data aggregation structure.
In [35] a new proposed protocol based on the fuzzy logic and LEACH protocol named LEACH-FC protocol is presented. In this protocol, the author has implemented a fuzzy logic-based CH selection and cluster formation to extend the network lifetime based on a distributed approach instead of a centralized approach. The proposed algorithm is found to be effective in energy consumption for enhancing the reliability of WSN.
Researcher demand for a general protocol that can be network lifetime extending, energy-efficiency, stable, and load-balanced [36]. The motivation of our research work is the demands mentioned above.

B. COYOTE OPTIMIZATION ALGORITHM AND FUZZY LOGIC SYSTEM IN ENGINEERING PROBLEMS
In the present work, a new metaheuristic algorithm COA [16] is proposed to optimize the optimal CH selection and cluster formation to extend the lifetime of the network, achieve energy-efficiency, and increase the networkthroughput. The COA algorithm has proven to be effective in many engineering problems in numerous research areas; the COA achieves fast, smooth, and stable convergence than other algorithms.
In electric power transformers the COA has the ability and stability to classify the accurate optimal parameters in single phase and three phase' transformers [37]. The results signify the efficiency and reliability of the proposed COA in estimating accurate model of the transformers compared to other optimization algorithms.
In [38] the COA algorithm employed for tackling with the optimization problem of parameters identification of solar cells and various PV modules, where the applied COA achieves the best values compared to other optimization algorithm.
Another region, feature selection problem; is a NP-hard problem and can be defined as a proces of identifying and removing irrelevant features, to obtain better, faster and more logical solutions for data mining tasks. In [39] authors propose a binary version of the COA, named Binary COA (BCOA), applied to select the optimal feature subset for classification. BCOA performs well in terms of classification accuracy. It has proven a good balance between exploration and exploitation during its search for the best solution, avoiding random searches while escaping from local optima.
On the other side, the FL system has confirmed its efficiency in many fields such as FL for data mining and machine learning. In [40] a novel technique is carried out using FL to support association rule mining (ARM). The suggested technique is a clustering-based one and offers fusion of clustering and ARMS. The result of the proposed technique is effective through experimental verification including numerous realworld datasets.
Another field is the rainfall prediction in [41], a new technique has been proposed for the prediction of rainfall using expert system model-based FL system for the difficult operational tasks needed by the meteorological department.
The using of FL system has proven effective in selecting the CH, through a lot of research such as in [42] new algorithm is proposed using a fuzzy cluster head selection scheme in Cognitive Radio (CR) VANET. The selected cluster head using FL system offers stability and reliability to the cluster compared to other techniques.
A FL based effective clustering (FLEC) of homogeneous WSNs for mobile sink has been presented in [43]. In this work the FL based clustering algorithm for WSN extend the network lifetime. The simulation results explain that the proposed FLEC structure outperforms other protocols.
In the proposed work the FL system is used to reinforce and balance the clustering process for increasing the wireless network lifetime and reducing energy consumption. FL-based clustering is adapted to determine a tentative set of CHs. Thus, the output of the FL is added as a solution within the initial solutions of the COA algorithm. Finally, the final CH is selected using COA algorithm.

III. SYSTEM MODEL A. NETWORK MODEL
In this paper, the network model is assumed as a collection of sensor nodes deployed randomly in a network area with N × N dimension. Nodes are immobile. Every sensor has a distinct ID and coordinates information. Sensor nodes collect environmental information and transmit the data to their corresponding CH nodes. All nodes are heterogeneous in terms of energy. The BS is also immobile and having sufficient energy and their location is known to all sensor nodes.

B. ENERGY MODEL
Through data transmission, the sensor node will be changed among transmitting and receiving states at any given moment. When a sensor node transmits or receives data, it consumed energy based on the distance D between the transmitting and receiving nodes. The free space transmission model (D 2 model) for the one-hop or direct transmission is adopted when the D is small and the multipath model (D 4 model) is adopted when D is large. Consequently, the energy consumed between the transmitter and receiver by transmitting I bits/packet of D can be defined as follows [33]: The received energy is defined as: where the size of the data packet is I while E elec represents the energy consumed per bit. The ε fs represents the free space energy model and ε amp represents the multipath energy model. The D 0 represents a threshold distance that controls states whether to use ε amp or ε fs . The D 0 is calculated as follows:

IV. THE PROPOSED ALGORITHM
The important issue in WSN is to balance the energy consumption in the network to increase the network lifetime.
In this section, a new stable and energy-efficiency clustering algorithm is proposed for WSN named as COFL algorithm, based on FL and COA algorithm. The proposed algorithm uses COA with a good initial population to converge to the optimal solution in a reasonable time. VOLUME 8, 2020

A. PROBLEM ANALYSYE AND FORMULATION OF COFL
The important issue in WSN is balancing the energy consumption in the network to increase the network lifetime.
In this section, a new stable and energy-efficiency clustering algorithm is proposed for WSN; named as COFL algorithm, based on FL and COA algorithms. The proposed algorithm uses COA with a good initial population to converge to the optimal solution in a reasonable time.
Coyotes are types of Canis Latrans. The COA algorithm provides stabilization between exploration and exploitation in the procedure of optimization problems. Coyotes hunt their prey in packs. Each pack is led by an alpha male and uses the nature of infiltration in the process of hunting. In the COA algorithm population size is defined as the multiplication of the number of packs N P and the number of coyotes N c in each pack, which are signified potential solutions numbers to the optimization problem. The COA algorithm starts by assigning the coyotes randomly to the packs. Each coyote represents a single solution to the problem U =(U 1, U 2, . . . , U D ), where D is the problem dimension. Each coyote is started with a random position solution at the start of the algorithm, as in the following equation [16]: where, lb j and ub j represent the lower and upper bounds of the search space and j ∈ (1, 2, . . . .D). The r j is a random number inside the range [0, 1]. Next step, the coyote adaptation to environmental settings and fitness function is described as follows [16]: If the problem is a minimization problem, the alpha coyote of each pack is defined at the moment as follows [16]: Then, the new social condition of the coyote is updated as follows [16] U p,t where δ1 is the distance between the alpha male and a random coyote in the pack and δ2 is the distance between the average location of all coyotes in a pack and a single coyote from the same pack. The r 1 and r 2 are random numbers inside the range [0, 1]. Then, to check the capability of the new solution and evaluate the fitness function of the new solution using the following equation [16]: The coyote determines if the new social condition is better than the older one to keep it, as follows [16]: Furthermore, the birth and the death of a coyote are considered in the COA algorithm. The birth of a new coyote is calculated as a combination of the social conditions of the two parents plus an environmental factor as in the following equation [16]: where P s is the scatter probability P s = 1/D and P a is the association probability P a = ( 1−P s 2 ). The r 1 and r 2 are random coyotes from the P th pack, j 1 and j 2 are two random dimensions of the problem, R j is a random number inside the decision variable bound of the j th dimension and rnd j is a random number in the range of [0, 1]. The pup will live if the fitness value with the pup is less than the older; otherwise, the pup will die. Finally, the social condition of the coyote that best adapted itself is selected and it is used as the global solution of the problem.
The COFL algorithm is based on two optimizations. The first is made through the FL system and the second is made through the COA algorithm. Tentative CHs are chosen based on the FL system then the COA algorithm is applied to optimize this clustering operation. The fitness function of the proposed COFL can be given by: where A and B represent constant value and A+B = 1.
Optimizing the clustering operation is based on improving both the inter-cluster and intra-cluster communications by trying to select the optimal positions of both the CH nodes and the cluster members of each cluster. Improving intra-cluster communication is based on minimizing the distances between all the sensor nodes and their respective CH to make compact clusters. In this part, f 1 can be represented as follows: where SN is the number of neighbors nodes of cluster m and d(s k , CH m ) is the distance between all the elements in the cluster m and the CH m . On the other hand, improving inter-cluster communication is based on minimizing the distances between the BS and the CH nodes, as well extending the average distances between each CH node and all the surrounding CH nodes to cover all the network area effectively. In this part f 2 can be represented as follows: where c is the number of clusters, D is the average distances between the BS and the CH nodes, and d (CH m , CH n ) is the distance between two cluster heads CH m and CH n . The optimal CHs have been elected based on the COA algorithm. The COA evolves the population towards the optimal number of CHs. After initialization, the fitness of each iteration is evaluated followed by the sorting of the population according to fitness values. Then, the best values for the next iteration of the algorithm are chosen.

B. THE COFL PHASES
The COFL algorithm is based on two main phases. The first phase is running the FL system that tries to select the tentative CHs nodes. The second phase uses the output of the FL system as one of the initial population solutions for the COA algorithm which optimizes the election operation of the appropriate CHs nodes to achieve optimum clustering process. The COFL flow structure is depicted in Fig.2 it consists of two phases called: FL phase and the COA phase.

Phase I: Fuzzy Logic Phase
In this phase, a fuzzy logic system is used to elect initial set of CHs. Three parameters are chosen for electing CHs: RE, DBS, and ND. These parameters are applied as inputs to the fuzzy inference system (FIS) and then output probability is calculated. Fuzzy if-then rules are applied to calculate the probability, and the nodes having higher probability are elected as initially assigned CHs. The input variables and their linguistic variables for selecting the CHs are formulated in Table 1.    and better results) is used in the base rule step that consists of 27 rules, all these rules are indicated in Table 2. The center of area method is applied to defuzzify the output linguistic variable into a crisp value. After completion of CHs selection, nodes that are not elected as a CH will join the closest CHs.

Phase II: COA Phase
The set of CHs resulted from the first phase is used in the initial population of the COA to direct the algorithm to find  a better solution than obtained in the first phase. In COA a cluster is represented by a pack, a normal node is represented by a coyote and a cluster head node is represented by an alpha. The COA in this phase relies on the following operations:  (7).
-Evaluate the fitness function of both the new solution and the current solution using equation (11). -Set the position with a minimum fitness function as the current position. 5. Implement birth and death inside the pack using equation (10). Test the possible solution bounds. If bounds are failed, provide birth to a new pup again. Then, compute the fitness value with the pup. If the fitness value with the pup is less than the older, the pup will survive. Else, the pup will die. Next, the coyote with the best fitness value will be selected. Test if a coyote can leave the pack and enter another pack according to P leave . Then, update the information of the pack. 6. The operations from 3 to 5 are repeated till either of these two cases happens: First, reach the optimal solution. Second, the maximum number of iteration is reached. After selecting the final CHs, the closest nodes to CH will join the cluster. After creating the cluster, CHs create a TDMA schedule for node members. In this schedule, node members transmit their data to their CH and then from CH to the BS. The proposed COFL algorithm is shown in algorithm 1.

Algorithm 1
The Proposed COFL Algorithm 1: Begin: 2: Read network configuration 3: Phase I: Run the fuzzy logic system 4: Define FL input parameters RE, DB, and ND. 5: Execute FIS based on the rule base. 6: Return probability that the node is elected as a CH node . 7: Phase II: Run the COA algorithm 8: Set initial COA parameters N p pack with N c coyote and the max-iteration 9: Set the coyote's adaptation as defined in equation (5) 10: While Max-iteration is not attained. 11: For each pack 12: Define the alpha coyote of the pack as equation (6)  13: For each coyote of the pack 14: Update the coyote position as equation (7)

C. THE COMPLEXITY OF THE COFL ALGORITHM
The complexity of the proposed algorithm is based on two main parameters: the time complexity and space complexity. The time complexity considers the time required for clustering a set of n nodes, while the space complexity considers the required system resources interaction, in this case, it represents the interaction between a BS and the CHs. The COFL is implemented in two phases. The time complexity of the COFL is computed based on these two phases. In the fuzzy logic phase, each elected CH makes at most number of comparisons equal n 2 − n . The complexity of this phase is O n 2 , where n is the number of nodes [34]. In the COA phase, the number of exchanged messages in each iteration equal to the total number of nodes. The computational complexity of this phase depends on the number of nodes n, the number of possible solutions P, and the maximum number of iterations Max_itr. Therefore, the complexity of this phase is (n × P × Max itr ) ≈ O(n), where P and Max itr are small values and can be neglected. Therefore, the time complexity of the proposed algorithm is [O n 2 +O (n)]. The space complexity of the COFL is O (c), where c, is the number of CHs, and also the number of interactions between the BS and these CHs. In this case, the space complexity is a very small value compared to the overall complexity of the proposed algorithm and can be neglected. Therefore, by ignoring the lower-order terms and constants, the overall time complexity of the proposed algorithm is O n 2 .

V. SIMULATION RESULTS AND DISCUSSION
The performance of the proposed COFL algorithm and the compared algorithms are performed using Matlab 2017a. Several comparative parameters such as number of alive nodes, the energy consumption of network, First Node Dead (FND), Half Node Dead (HNF), and Last Node Dead (LND) are considered for comparative analysis of algorithms and protocols. The simulation parameters of the proposed algorithms have been organized in Table 3. Several scenarios are established in which the position of the BS is changed to study the efficiency of the BS position for the proposed algorithms and protocols, these scenarios are shown in Fig. 7. In scenario 1 (S1), BS is taken at the center of the network area at (50, 50). In scenario 2 (S2), BS is taken at the corner of the network area at (100, 100). In scenario 3 (S3), BS is taken outside of the network area at (50, 150). The heterogeneous system in this case is initiated with different levels of energy represented by advanced and normal nodes. The energy of each advanced node is (1 + a) times more than the energy of each normal node, where a is the energy factor.

A. EVALUATION OF THE PROPOSED ALGORITHM BASED ON A NUMBER OF ALIVE NODES
In this section, a comparison between the number of alive nodes and the number of rounds is implemented to show the loss rate of the alive nodes per round. This comparison is implemented on the three scenarios S1, S2 and S3.  The number of alive nodes per rounds on every scenario shows the superiority of the proposed COFL algorithm. Fig.8 shows the loss rate of the alive nodes in case of S1. The results show that traditional algorisms such as LEACH and SEP lose 80% of the nodes after few rounds, at 800 and 1300 rounds respectively. Whereas metaheuristic algorithms such as PSO, GWO and COA lose 80% of the nodes after more rounds approximately at 1500 rounds. The proposed COFL algorithm in this case has a minimum loss rate; it loses the same number of nodes approximately at 2000 rounds.    The results show that traditional algorithms have a high loss rate through few rounds: LEACH loses 90% of the nodes at 700 rounds and SEP loses 90% of the nodes at 800 rounds, whereas metaheuristic algorithms lose 90% of the nodes approximately at 1300 rounds. The COFL in this case loses about 90% of nodes at 2000 rounds.
Thus, the network lifetime in the COFL algorithm is higher than existing algorithms, whereas LEACH and SEP failed to prolong the network lifetime. This is an important achievement of the proposed algorithm over the traditional and metaheuristic algorithms. From Figs. 8, 9 and 10 it is clear that the performance of COFL on S1 is better than S2 and S3. Moreover COFL has a positive effect on system stability.

B. EVALUATION OF THE PROPOSED ALGORITHM BASED ON THE ENERGY CONSUMPTION
The result of the consumed energy is depicted in Figs. 11, 12 and 13. The energy consumption of the network nodes was increased in all algorithms when the number of rounds increased. The results show that the consumption of energy of the COFL algorithm is less than the other algorithms.    11 displays the energy-consumption for S1 to assess the efficiency of the proposed COFL algorithm. In this case, LEACH consumed 80% of the node energy at 600 rounds and SEP consumed 80% of the node energy at 900 rounds, while the GWO and PSO algorithms consumed 80% of the node energy approximately at 1000 rounds. Whereas the COA algorithm consumed the same percentage of the node energy at nearly 1200 rounds. The COFL consumed the same energy approximately at 1500 rounds. The average improvement in energy consumptions of COFL over COA, GWO, PSO, SEP and LEACH is 21%, 28%, 35%, 40% and 60% respectively. Fig.12 shows the energy-consumption for S2 to measure the efficiency of the proposed COFL algorithm. LEACH algorithm consumed 80% of the energy at nearly 400 rounds and the SEP consumed 80% of the energy at nearly 500 rounds, whereas the GWO, COA and PSO algorithms consumed 80% of the energy at nearly 1000 rounds. The COFL proposed algorithm consumed 80% of the energy at nearly 1400 rounds. The average energy consumption for the proposed COFL over COA, GWO, PSO, SEP and LEACH is 26%, 29%, 31%, 55% and 64% respectively. Fig.13 shows the energy-consumption for S3 to evaluate the efficiency of the proposed COFL algorithm. LEACH algorithm consumed 90% of the energy at nearly 400 rounds and the SEP consumed 90% of the energy at nearly 600 rounds, whereas the GWO, COA and PSO algorithms consumed 90% of the energy at nearly 1000 rounds. The COFL proposed algorithm consumed 90% of the energy at nearly 1600 rounds. The average energy consumption for the proposed COFL algorithm over COA, GWO, PSO, SEP and LEACH is 36%, 39%, 46%, 58% and 70% respectively.
Figs. 14, 15 and 16 represent the FND, LND and HND of all algorithms for S1, S2 and S3 respectively. The proposed COFL algorithm has achieved better performance than all other algorithms in different scenarios. Fig.14for S1shows that the proposed COFL algorithm is 8.82%, 17.54% and 42.19% superior to PSO, SEP and LEACH algorithms for FND. Also, for HND the proposed COFL algorithm is 15.48%, 16.63%, 23.59%, 38.83% and 54.08% better than the COA, GWO, PSO, SEP and LEACH algorithms respectively. For the LND, the proposed COFL algorithm increases network lifetime by 20.89%, 35.67%, 32.69%, 48.64% and 50.07% than the COA, GWO, PSO, SEP and LEACH algorithms respectively. Fig. 15 for S2shows that the proposed COFL algorithm is better than the COA, GWO, PSO, SEP and LEACH algorithms by 4.95%, 14.65%, 30.89%, 34% and   57.22% respectively. For HND, the proposed COFL algorithm shows an enhancement in results compared to the COA, GWO, PSO, SEP and LEACH algorithms by 5.59%, 5.68%, 6.53%, 37.54% and 51% respectively. The proposed COFL algorithm increases network lifetime for HND compared to COA, GWO, PSO, SEP and LEACH algorithms by 22 One of the important improvements that result from enhancing energy consumption is increasing the efficiency of data exchange through the network which is represented by increasing the throughput. Where the throughput is the total number of data packets received by the BS over the total number of rounds. Figs. 17, 18 and 19 illustrates that the proposed COFL algorithm outperforms compared algorithms through 4000 rounds on the three scenarios: S1, S2 and S3 respectively.   17 shows the throughput of COFL against the other algorithms in case of S1. The throughput of COFL outperforms COA, GWO, PSO, SEP and LEACH by 55%, 65%, 85% 90% and 89% respectively. Fig. 18 shows the throughput of COFL against the other algorithms in case of S1. The throughput of COFL outperforms COA, GWO, PSO, SEP and LEACH by 31.5%, 56.36%, 48.9% 64.23% and 89.36% respectively. Fig. 19 shows the throughput of COFL against the other algorithms in case of S1. The throughput of COFL outperforms COA, GWO, PSO, SEP and LEACH by 1.9%, 9.77%, 58.8% 69.82% and 73.11% respectively.

D. STATISTICAL ANALYSIS OF COFL
A central tendency is a statistical analysis evaluation method represented by a single value that used to describe a clustering process of a set of data and also describe the center of this data. There are three ways to measure the central tendency: the mean, the median, and the standard deviation (STD).  The mean value represents the sum of all the data entries divided by the number of entries. The median value represents the value that lies in the middle of the data when the data set is ordered. The STD measures variability and consistency of the sample or population. In statistical data analysis, less variation is often better. Table 4 shows these evaluations through 2000 round for 200 nodes in case of S1. According to this case, it is observed that the proposed COFL has attained high energy and maximum number of alive nodes when compared to other algorithms. The mean of the alive nodes realized by proposed COFL algorithm is 13%, 14  The STD of the normalized energy pertaining to proposed COFL algorithm is 8.44%, 8%, 9.39%, 13.37% and 4.81%; outperforming the COA, GWO, PSO, SEP and LEACH algorithms. Table 5 shows the same evaluation in case of S2, the proposed COFL has reached high energy and maximum number of alive nodes compared to other algorithms. The mean of the alive nodes realized by the proposed COFL algorithm is 9.66%, 10

VI. CONCLUSION AND FUTURE WORK
This paper proposed a new hybrid algorithm for clustering heterogeneous WSN based on the FL system and the COA algorithm known as COFL. The FL system selects an initial set of tentative CHs based on the three inputs variables (residual energy, distance from nodes to BS and the number of neighboring nodes in the vicinity). The final CHs are identified through the COA algorithm. The main impact of the proposed algorithm is associating nodes to their equivalent CHs. An appropriate fitness function is designed which considers essential factors of the network.
The results were compared for the three scenarios of the position of the BS. Herein the target is to show the effect of BS locations on the performance of the proposed algorithms. Within this test, 200 sensor nodes are deployed randomly in 100 × 100. The BS is located at three different locations: the center, corner, and outside of the network area; these locations have been referred to as S1, S2 and S3 respectively. The results were tested against different metrics such as the number of alive nodes, energy consumption, throughput and central tendency.
The results show that the BS placement in the center of the network area (S1) has a positive effect on the result of the proposed COFL algorithm. Moreover, the results show that the COFL algorithm has a better performance compared to other algorithms; COA, GWO, PSO, SEP and LEACH. The COFL algorithm can provide better results in all the different scenarios and all the metrics. In the future, there is a need to expand the network configurations to address mobile nodes as either the sensor nodes or BS. Also, to address increasing the number of network nodes and increasing the variance and heterogeneity in energy levels between these nodes. IBRAHIM ELNAHRY worked with the Faculty of Computers and Information Technology, University of Tabuk, for six years. He also worked the Head of computer engineering with Fahad Bin Soultan University, Saudi Arabia, for three years. He is currently an Assistant Professor with the Department of Computer and Control System, Faculty of Engineering, and a Manager of the Faculty of Engineering, Quality Assurance Unit, University of Port Said, Egypt.
ABOUL ELLA HASSANIEN is currently the Founder and the Head of the Egyptian Scientific Research Group (SRGE) and a Professor of information technology with the Faculty of Computer and Artificial Intelligence, Cairo University. He has more than 1500 scientific research articles published in prestigious international journals and over 50 books covering, such diverse topics as data mining, medical images, intelligent systems, social networks, and a smart environment. His research interests include machine learning, optimization, medical image analysis, space sciences, and telemetry mining. He won several awards, including the Best Researcher of the Youth Award of Astronomy and Geophysics of the National Research Institute, Academy of Scientific Research, Egypt, in 1990. He was also granted a Scientific Excellence Award in humanities from the University of Kuwait for the 2004 Award and received the superiority of scientific in technology-University Award, Cairo University, in 2013. Also, he honored in Egypt as the Best Researcher at Cairo University, in 2013. He also received the Islamic Educational, Scientific, and Cultural Organization (ISESCO) prize on Technology, in 2014, and the State Award for excellence in engineering sciences, in 2015. He also received Abdul Hameed Shoman Arab Researchers Award, in 2015. He holds the Medal of Sciences and Arts from the first-class from President Abdelftah Al-Sisi and also he wins the Scopus international award in 2019 for meritorious research contribution in the field of computer science. VOLUME 8, 2020