Wireless sensor network (WSN) has become a very popular technology with a wide range of applications. It consists of several spatially distributed sensors that work collaboratively to monitor a given region of interest (ROI). The limited energy available for each sensor node is a crucial restriction that affects the overall performance of the network. Therefore, energy efficiency is a major concern in WSNs. Over the years, many techniques have been developed and used to reduce energy consumption in WSNs. Clustering is one of the most effective energy-saving techniques that significantly can improve the efficiency of WSNs in terms of the network lifetime, energy consumption, and the number of received packets. In this paper, an energy-efficient algorithm for cluster head (CH) selection based on a newly formulated fitness function and using the manta ray foraging optimization (MRFO) is proposed. The objective function for the proposed formulation takes into account different network parameters such as the average distance between the CH and the sensors in its cluster, the distance between CHs and the base station (BS), residual energy, and CH balancing. The proposed algorithm is tested by running many simulations under a variety of conditions. The simulation results showed that the proposed algorithm has a better performance than that of some other algorithms reported in the literature in terms of energy consumption, networks lifetime, and the number of received packets.

1. Introduction

WSN consists of a group of sensors that are distributed to monitor a physical environment in order to collect data and send it to a nearby central base station (BS) [1]. The sensor nodes, BS, and the end-users are the three elements that define the WSN structure [2].

Sensor nodes are electronic devices that include a processor, storage, a transceiver module, single or multiple sensors, an analog-to-digital converter (ADC), and a power source (typically a battery) [2]. These nodes are small and cost-effective. Nowadays, WSNs are in charge of collecting and sending information from their surroundings [3]. As a result, their performance is significantly affected by their limited capabilities (typically reduced memory, limited battery, and processing capabilities). Moreover, wireless sensor nodes can communicate only in a local form with limited bundle of local neighbors due to the limited transmission power [4].

As a result of their versatility in problem solving across many application domains, WSNs have become more popular, and they have the potential to change our lives in a variety of ways. Due to the rapid growth of sensor technology, very small and intelligent sensors have been developed, allowing WSNs to be used in a variety of applications such as military applications [5], area monitoring [6], transportation [6], medical/health applications [7], environmental applications [8], and many others. In general, the data collected by each sensor is sent to a BS (i.e., sink) to be analyzed [9]. This BS acts as an interface between users and WSN.

Clustering methods are utilized for simple node management, improving scalability, reducing energy consumption, data aggregation, robustness, and load-balancing [10]. Clustering divides sensor nodes into virtual groups called clusters, where each group performs different roles. Clustering is characterized as the process of grouping nodes into clusters depending on predefined criteria and selects the most efficient node from each cluster to work as a CH [11]. The data from all sensor nodes is collected by the CH, aggregated, and then directly forwarded to the BS or through an intermediate CH. Instead of sending data from all sensor nodes in a cluster, the CH transmits the aggregated data in order to decrease the transmitted packets over the network and hence reduce the energy consumption. The data acquired from the CH node is further processed at the BS before it is made available to the end-users [10]. As a result, when choosing a sensor to serve as a CH, proper considerations should be given to the problem of sensor overload [12,13]. In addition, in the process of selecting a sensor to be a CH, important factors such as the distance between the CH and the sensors in its cluster (intracluster distance), the distance between CH and the BS (sink distance), and the residual energy of the sensor should be carefully considered [12].

In this work, a novel clustering algorithm based on the manta ray foraging optimization (MRFO) is proposed to improve the performance of WSN. The proposed algorithm MRFO-C is used to solve the CHs selection problem formulated as an optimization problem using a new fitness function that takes into account intracluster distance, sink distance, CH balancing, and residual energy. Extensive simulations and tests of the proposed algorithm to design WSN are carried out under various conditions. The performance of the proposed algorithm is assessed and compared with that of some clustering algorithms reported in literature. The proposed algorithm outperformed some of the well-known reported algorithms in terms of the energy consumption, the network lifetime, and the number of received packets. The main contributions of this paper are as follows:(1)The CHs selection problem is formulated as an optimization problem using a new fitness function based on many network parameters that considerably affect the network performance.(2)Introducing the MRFO algorithm as a stable and efficient optimization algorithm to the WSN community.(3)Reporting the use of the MRFO algorithm to solve CHs selection optimization problem and achieving optimal WSN performance in terms of the energy consumption, the network lifetime, and the number of received packets.(4)Extensive simulations and assessments of the proposed algorithm to design WSN under various conditions are reported.

The rest of this paper is organized as follows: Section 2 discusses the related literature. The details of MRFO are given in Section 3. The assumptions and system model are given in Section 4. Details of the proposed algorithm are presented in Section 5. Section 6 has the results of this work. Finally, the conclusion of the paper is given in Section 7.

In this section, related clustering algorithms are reviewed for both heuristic and nature-inspired based clustering approaches. Many clustering algorithms were developed depending on heuristic methods. For example, the low-energy adaptive clustering hierarchy (LEACH) is a very common algorithm for clustering depending on heuristic methods [14]. It is a protocol that organizes itself, adapts clusters, and introduces the concept of rounds. LEACH assumes that all sensor nodes are homogenous and have limited energy sources and that the BS is fixed and remote from the sensors. Sensors can constantly monitor the environment, communicate between them, and send data to the BS. The idea of LEACH is to select CHs based on predetermined probability. The disadvantage of LEACH is that it allows choosing a low-energy CH, which reduces the network's lifetime and hence decreases the network performance. As a result, various modifications to the LEACH algorithm have been proposed to improve its performance.

The authors in [15] introduced LEACH-B (balanced) that proposes an upgraded version of LEACH by establishing the quasi-optimal number of CHs. In LEACH-B, a second phase of CH selection considers the residual power of the candidate node and adjusts the number of CHs based on this factor. LEACH-B is similar to LEACH in its selection of a random number, and in the way the threshold value is calculated. However, the LEACH-B added a new selection stage. In particular, all the selected candidates can be sorted in the order of residual power and only (n × p) of the candidates are chosen (where n is the total number of sensor nodes and p corresponds to the percentage of CHs). LEACH-B ensures the optimal number of CHs. However, it has the disadvantage of taking more time to select CHs.

The energy-LEACH (E-LEACH) protocol was introduced by the authors in [16] to improve the CH selection procedure. It uses the node's residual energy as the primary metric to determine the possibility of turning a certain node into a CH. The E-LEACH protocol is divided into rounds in a way similar to that of LEACH protocol. Every node has the same chance of becoming a CH in the first round, implying that CHs are chosen randomly. After one round of communication, each node’s residual energy is different in the subsequent rounds, and this is taken into account when choosing the CHs. As a result, nodes with higher residual energies are more likely to become CHs than nodes with lower residual energies. The disadvantage is that the CHs must keep their receivers turned on at all times to receive data.

M-LEACH is a similar algorithm to LEACH [17], with the exception that, rather than sending data to the BS directly, it forwards data to the next-hop CH node. However, it does not have cluster formation phase. Furthermore, it ignores important metrics such as energy and node degree in multihop data transfer between CHs.

The PEGASIS algorithm [18] is one of the heuristic approaches that has been introduced to improve LEACH. In this algorithm, sensors are arranged in a chain and one of them is randomly chosen as the leader of the chain. In each round, the chosen leader collects data, fuses it, and sends it to the BS. Hence, the distance between the BS and the CH is not taken into account by this algorithm which is its main flaw. Another disadvantage is that the residual energy of a node is not taken into account during the CH selection process. The least distance clustering (LDC) has been proposed to improve the lifetime of WSNs [19]. Here, the non-CH nodes are assigned to the closest CH, which speeds up the cluster formation phase. The biggest downside of the LDC is that clusters might be formed in a wrong way.

The EPEGASIS algorithm [20] is proposed to address the problem of hot spots in four ways. In order to proceed, the best communication distance must be determined in order to reduce transmission energy consumption. To protect dying nodes, a ten-threshold value is set, and mobile sink technology is used to balance node energy consumption. Then, depending on its distance from the sink node, the node can adjust its communication range.

Many other clustering algorithms have been developed which are based on the application of natural methods. The author in [21] introduced LEACH-C. It should be mentioned here that, in LEACH, all nodes can choose CHs on their own, resulting in a large number of CHs. The LEACH protocol is improved in LEACH-C by allowing the BS to have information about the nodes such as the remaining energy and the location during the CH selection stage. Therefore, the BS selects the most appropriate nodes for CHs and the remaining nodes are used to form clusters. Extra overhead on the BS is a disadvantage of LEACH-C, which makes it incompatible with large-area networks. In [22], the authors proposed an extended LEACH protocol (FL-LEACH) that uses fuzzy logic to determine the number of CHs that should be selected in WSN. The complexity and accuracy of the fuzzification and defuzzification processes are the disadvantages of FL-LEACH.

Due to their simple implementation, high quality solutions, quick convergence, and ability to escape from local optima [13], evolutionary techniques are preferred for solving optimization problems in a large search space [23]. Particle swarm optimization (PSO) [23], grey wolf optimization (GWO) [24], butterfly optimization (BOA) [25], genetic algorithm (GA) [26], and differential evolution (DE) [27] have all been used to solve the CH selection problem.

PSO clustering (PSO-C) is an algorithm based on evolutionary approaches for clustering [23]. The CHs in PSO-C is chosen based on inter-cluster distances and the ratio of all nodes' initial energy to their current residual energy. On the other hand, the distance between the CH and the BS is an important factor that can have a significant impact on the network's energy consumption.

A novel coverage control algorithm based on PSO is proposed in [28]. The sensor nodes are first deployed at random in a target area and remain stationary. The entire network is then divided into grids, with each grid’s coverage rate and energy consumption are calculated separately. Finally, the sensing radius of each sensor node is adjusted based on the grid’s coverage rate and energy consumption.

Another popular clustering algorithm employing advanced techniques is the PSO-ECHS [13]. This algorithm chooses a CH based on the intracluster distance, the sink distance, and the sensor's residual energy. A fitness function is formulated using a linear combination of these parameters. However, when selecting CH, this algorithm ignores load-balancing. As a result, some big clusters and some small clusters could be formed resulting in relatively high energy consumption.

The Global Levy Flight of Cuckoo Search with PSO is proposed to improve network performance by implementing balanced energy dissipation in [29].

One more clustering algorithm that incorporates evolutionary processes is the enhanced energy-saving CH selection algorithm, which is based on the Whale Optimization Algorithm (WOA-C) [30]. The WOA-C algorithm supports the selection and use of a fitness function for energy-aware CHs selection. It takes the residual energy of the node and the total energy of nearby node into consideration. However, this approach disregards load balance, intracluster distance, and sink distance when selecting a CH.

The energy-efficient cluster head selection algorithm uses a hybrid of HSA and PSO algorithms. This algorithm selects the head of clusters by calculating the target function value based on the maximum Euclidean distance of all nodes from their CHS, as well as the ratio of total energy of the network to the total energy of the CHs [31].

TTDFP (Two-Tier Distributed Fuzzy Logic Based Protocol) is proposed to extend the lifetime of multihop WSNs by combining the efficiency of clustering and routing phases. TTDFP is a distribution adaptive protocol for sensor network applications. In this protocol, an optimization framework is used in combination with the two-tier fuzzy logic-based protocol to tune the parameters used in the fuzzy clustering tier in order to optimize the performance of a given WSN [32].

In [33], a novel social spider optimization (SSO) algorithm for sensor networks clustering is proposed based on a simulation of spiders' social cooperative behavior. Nodes in the proposed algorithm resemble a swarm of spiders that interact with one another according to colony-specific biological rules. The fitness of nodes is also determined using fuzzy logic based on the two criteria of battery level and distance to sink.

To improve the energy efficiency of rule-based fuzzy clustering algorithms, a modified clonal selection algorithm (CLONALG-M) is proposed. To elucidate the basic principles of an adaptive immune system, the CLONALG-M algorithm is used, which is based on the clonal selection principle. This principle is used to determine the approximate deployment of output-based membership functions that improve the performance of rule-based fuzzy clustering algorithms with previously known rule base and membership function shape [34].

The modified clonal selection algorithm (CLONALG-M) is used to improve the performance of rule-based fuzzy routing algorithms. CLONALG-M is used to determine the approximate form of output membership functions, which improves the overall performance of fuzzy routing algorithms with known rule bases and membership function shapes [35].

Another clustering algorithm that uses nature-inspired methodology is the LEACH-GA [36]. The algorithm has set-up and stationary stages and an additional preparation phase before the first cycle commences. All nodes select the head of the clusters during the preparation phase and send messages to the BS with candidate head, node IDs, and geographical positions. As the BS receives messages from all nodes, it employs a genetic algorithm to find the best CHs that reduce the total energy needed. During the next set-up phase, all nodes with optimal probability values broadcast advertisement messages to form clusters. Before the first-round set-up phase, the preparation stage is only performed once. The complexity of this algorithm and the additional overhead on the BS for calculating the percentage of CHs are its drawbacks. In [37], the firefly algorithm (FA) and hesitant fuzzy were proposed to implement a new CH selection protocol. This protocol calculates the score of each sensor node using three parameters to determine the best CHs. Three scenarios are simulated and evaluated to describe the performance of the proposed protocol.

A novel trajectory scheduling method based on coverage rate for multiple mobile sinks (TSCR-M) is presented in [38]. This method is proven to be useful for large-scale WSNs. Finally, the authors in [39] proposed a method to handle high-order, high-dimension, and sparse sensor (HOHDST) network.

3. Manta Ray Foraging Optimization (MRFO)

3.1. Chain Foraging

Manta rays can detect planktons and swim toward them. The better the location is, the higher the concentration of planktons. Manta rays form a chain of fodder head to tail. With the exception of the first individual, all individuals should move not only towards the food but also towards each other. This means that in each iteration the best solution is achieved and the solution on the front of each individual is modified. The chain foraging mathematical model is given as in [40],Here, is the position of individual in the dimension at time , is a weight coefficient, and is a random vector in . is the position of high-concentration planktons. The position of the individual is updated by the position of the current individual and the position of the food.

3.2. Cyclone Foraging

Whenever planktons are viewed in deep water by manta rays community, they create a long drilling chain and swim in a spiral motion towards food. Each manta ray swims towards the one in front of it while spiraling towards the food. In 2D space, an individual not only moves in a spiral path towards the food but also follows the one in front of it. The mathematical equation that can be used to model the spiral-shaped movement of manta rays in 2D space is given as follows [40]:where is a number between 0 and 1 that is randomly chosen. This motion can be modified to model space as follows [40]:where is the weighting coefficient, is the largest number of iterations that can be executed, and is a rand number in . The best approach found so far is cyclone foraging, which has a good exploitation of the area of interest. This behavior is also employed in order to enhance the exploration procedure. By assigning a new random location in the search space, individuals are forced to look for a new position far away from the best current one. This mechanism is primarily for exploration and it allows the MRFO to conduct a thorough search. The mathematical equation for this mechanism is as follows [40]:where and are the upper and lower limits of the dimension, respectively, and is a randomly generated position throughout the search space.

3.3. Somersault Foraging

This behavior is thought to be centered on the position of the food. Each individual is swimming around the pivot and hanging in a new position. Thus, they always update their positions on the basis of the best position they have discovered so far. The following is the mathematical model of this strategy [34].

The somersault factor is denoted by which determines the manta rays range for the somersault while and are two random numbers in . By determining the somersault range, each individual can move to any position in a new search domain. Then, they are placed in the best position to be found between their current position and their symmetrical position as given in equation (5). The disturbance of the current position diminishes with the deterioration of the distance from the best position to the position of each individual. All individuals gradually come towards the best solution in the search space. As a result, the variety of hollow foraging decreases accordingly as the number of iterations increases. The dense areas around can be very useful, while the scarce ones can much help with exploration.

MRFO begins with the creation of a random population in the problems field in a similar manner to other metaheuristic optimizers. Each individual updates its position with respect to the leading individual and the reference position at the end of each iteration. The value is reduced from to 1, in order to make an exploratory and exploitative search.

4. WSN Models and Proposed Algorithm

4.1. Energy Model

In this paper, the adopted energy model is a first-order radio model [23]. In this model, the radio electronics and the power amplifier consume energy while transmitting data. However, only radio electronics consume energy while receiving data. The amount of energy consumed by the sensor node during transmission depends on the size of the data and the propagation distance . Furthermore, the energy consumption of the sensor node increases if the propagation distance exceeds a certain threshold value as given in (6). In this model, the total energy consumed by each sensor node for transmitting l bits is calculated according towhere denotes the amount of energy consumed per bit by the transmitter and receiver, represents the energy consumed by the amplifier for free-space loss, is the amplification energy, and represents the threshold transmission distance.

In the same way, the energy consumed while receiving l bits of data is calculated using

4.2. Network Model

The following is a list of the network assumptions that are made:(1)All sensors are assumed to be randomly positioned and to remain stationary once deployed over the sensing field(2)In the sensing field, each sensor node is eligible to be selected as a CH or as a regular sensor node(3)All sensor nodes are homogenous (i.e., they have equal and limited energy, in addition to having similar communication and processing capabilities)(4)Every sensor node regularly sends data to its CH or BS(5)The total number of sensor nodes exceeds the total number of CHs(6)Based on the distance of transmission, the sensor nodes use different levels of transmission power(7)When the nodes are within feasible communication range, wireless and symmetrical communication links are established(8)The BS is stationary and can be placed within the sensing region or outside it

4.3. Problem Formulation and the Proposed Algorithm

First, the problem of CH selection is modeled as a constrained optimization problem. Then, the MRFO is implemented to solve the optimization problem by finding the minimum value of the fitness function. This means that the CHs selection problem is formulated as a minimization problem [23]. In the proposed formulation, the CH algorithm depends on some parameters i.e., the distance between the sensor node and the CH, the distance from the BS to the CH, balance factor, and the residual energy. During CH selection, the position and residual energy of each sensor node will be sent to the BS to see if they meet the energy threshold (i.e., the mean energy of the sensor nodes). The formation of clusters is the next phase. The non-CH sensor nodes will join the nearest CH for cluster formation. To simplify the description of the formulation of the fitness function, the following terminologies are used:: total number of live nodes: total number of CHs: all set of nodes in the WSN : the collection of CHs, : the number of nodes in cluster : the maximum range of communication of a sensor node: the maximum range of communication of a CH: the threshold energy to become a CH: the threshold distance: the initial energy for a node: the energy of the0020 : the average energy of all active nodes: the distance between the nodes and

The main goal of the proposed algorithm is to choose CHs from normal sensor nodes based on energy efficiency in order to extend the lifetime of the relevant network. For efficient CH selection with energy efficiency, we considered the residual energy of the sensor nodes, the average intracluster distance between the sensor nodes, the distance from CH to the BS, and cluster balancing.

Now, let be a function of the mean total distance between each sensor and its respective CH intracluster, and is a function of the distance between the BS and the CH. For optimal CH selection, we must reduce and . Moreover, let be a function that is the reciprocal of all the CHs' total current energy. It is worth noting that this reciprocal, , should be minimized. Finally, is the cluster balancing factor which must be reduced to balance the number of sensors in the cluster. As shown later, in order to obtain an energy-efficient algorithm for cluster head (CH) selection, the fitness function will be calculated using functions , , , and . The parameters responsible for the derivation of a newly formulated fitness function are as follows.

The average intracluster distance is calculated as the mean total distance between each sensor and its respective CH intracluster. During intracluster communication, all sensor nodes use some energy to send data to their CH. Therefore, the intracluster distance must be minimized in order to save energy and sensors closer to many other sensors are selected as CHs. The function is given as follows [13]:

The average sink distance is calculated by dividing the distance between the BS and the CH by the total number of sensor nodes in a given cluster. All CHs must route their aggregated data to the BS, so the distance between the CH and the BS is important in terms of energy consumption. As a result, the distance between all CHs and the BS must be minimized to reduce energy consumption. is given as follows [13]:

The residual energy is the sum of the current energy of the selected CHs. Since the total energy must be maximized, the reciprocal is taken into consideration when balancing each objective function. Because the lifetime of the network is determined by the amount of energy used, the reduction in energy consumption is critical. The function is given as follows [13]:

The clusters balancing : the balancing factor is defined as the average number of nodes in a particular cluster to the total number of nodes. Because sensor nodes are randomly organized, some large and small clusters may be formed, so the cluster size must be balanced. The function f4 is given as in [41]

The aforementioned parameters are used in the formulation of the fitness function collectively and significantly affect the energy consumed in the WSN.

Rather than minimizing each fitness function individually, it is preferable to focus on the above fitness combination. As a result, the current fitness function is a linear combination of functions that depends on these parameters to reduce energy consumption. The proposed fitness function is given as

The intracluster distance, the sink distance, the residual energy, and the cluster balancing, respectively, are used to formulate the functions , , , and . The weights , , , and are used to control the contribution of the different functions , , , and . These weights are used to satisfy . To efficiently reduce energy consumption in a WSN, a trial-and-error procedure is used to determine the values of these variables.

It is worth noting that there are alternative analytical and evolutionary optimization methods that can be used to solve multifunction optimization problems. However, we used a simple but effective model to handle the cluster head multifunction optimization problem. The problem is formulated as single objective function that represents a weighted some of all the functions to be optimized. The weights are used to emphasize the importance of some functions in reducing energy consumption. On the other hand, analytical model usually requires gradient information which can be easily avoided using evolutionary algorithm. Furthermore, the use of multiobjective optimization algorithm is computationally very expensive to solve the problem at hand.

The MRFO algorithm is used to solve the optimization problem by determining the best set of CHs to minimize the fitness function in (12). The best set of CHs reduces the overall energy consumption and increases the networks lifetime. Table 1 shows the nomenclature used in the proposed algorithm.

In the implementation of the MRFO algorithm, individuals represent a set of CHs in the MRFO algorithm and the size of each set of CHs is set to 10% of the sensor nodes. The MRFO algorithm takes a set of active sensors , as inputs and the optimal set of CHs as outputs. The following steps summarize the MRFO algorithm’s implementation to solve the CHs selection problem:

(a)Step 1: Initialize individual .
(b)Step 2: for to do
   (1)Calculate fitness of each individual using equation (12).
   (2)The best individual
End for
(c)Step 3: FOR t = 0 to  = Maximum number of iterations
(i) For : TO THEN
(1)If THEN \\ Cyclone foraging
(2)If THEN \\
END if
ELSE\\ Chain foraging
(3)Compute the fitness of each individual , if
(5)\\Somersault foraging.
(6)Compute the fitness of each individual.
(d)Step 4: END FOR
(e)Step 5: Return the best solution found so far.
(f)Step 6: The nearest sensor nodes to are the selected CHs.
(g)Step 7: Stop

Regarding cluster formation, after the CHs have been chosen, non-CH nodes send request messages to the CH to join the cluster. The non-CH nodes are then permitted to join a cluster with the closest CH based on the shortest distance (Euclidean distance).

Initialization and iterations make the most difference in calculating the computational complexity of MRFO-C. Initialization is performed in Step 1 of the algorithm. The complexity of iteration is . In the worst-case scenario, one for loop is started at Step 2 and executed individually up to the number of individuals. As a result, the degree of difficulty is . In Step 3, the outer for loop is executed until the maximum number of iterations is reached. First, the for loop begins at line number and continues until the number of individuals reaches , and the size of the individual reaches m. As a result, the complexity of Step 3 is . As a result, the proposed algorithm's overall complexity is .

The pseudocode of the proposed CH selection algorithm is shown in Figure 1 while Figure 2 depicts the flowchart of the MRFO-based clustering algorithm.

5. Simulation Results and Comparison

MATLAB is used to implement the MRFO-C. Three different scenarios are used to test the protocol. To investigate the effect of the BS position, three different scenarios are created, in which we change the position of the BS. These three different scenarios for the position of the BS are considered in the current simulation findings. In scenario 1, the BS is placed at the center of the region of interest (ROI), and the BS is located in the corner of the ROI in scenario 2, while in scenario 3, the BS is placed outside the ROI. In the simulation, 10% of the total number of the nodes in a WSN is chosen as CHs. The performance of the proposed algorithm to design WSN is compared with that of some well-known clustering algorithms such as the PSO-ECHS algorithm in [13] and the LEACH algorithm in [14]. The simulation parameters for the proposed protocol are listed in Table 2.

The following metrics are used to evaluate the performance of the proposed algorithm:(1)The total energy consumed in a number of rounds, during which the CHs collect, aggregate, and route data to the BS(2)The networks lifetime is measured as the number of rounds until the last node death (LND)(3)The total data packets received by the BS over the entire lifetime of the network

It is worth noting that the MRFO-C algorithm may cause a search agent to have a new position outside the specific monitoring area (i.e., . As a result, the search agent’s updated position should be generated in such a way that it remains within the range of this monitoring area. In this case, we used the absorption rule for the boundary state. In particular, if the updated position is outside the monitoring area, then the new position will be changed to be at the edge of the monitoring areas; e.g., if the calculated updated position is , it will be changed to The proposed algorithm is first used to find the best set of CHs for three different networks with 300, 400, and 500 sensor nodes and 30, 40, and 50 CHs, respectively. At the end of round 5000, the total energy consumption is calculated. First of all, Figure 3 shows a randomly deployed wireless sensor network with 300 sensor nodes in a monitoring area of .

Figure 4 shows the 30 CHs that are selected using the MRFO algorithm from the set of 300 sensor nodes in a monitoring area .

Figure 5 shows a randomly deployed wireless sensor network with 400 sensor nodes in a monitoring area of .

Next, Figure 6 shows the 40 CHs that are selected using the MRFO algorithm from the set of 400 sensor nodes in a monitoring area of .

Another randomly deployed wireless sensor network but with 500 sensor nodes in a monitoring area of is shown in Figure 7.

The 50 CHs selected using the MRFO algorithm from the set of 500 sensor nodes in a monitoring area of are shown in Figure 8.

Figures 911 show comparisons of the total energy consumptions for the 300-node network at three different positions for the BS. Hence, for the three positions of the BS, the total energy consumptions achieved by the proposed algorithm are lower than those for the PSO-ECHS and the LEACH algorithms. Namely, when comparing the MRFO to the PSO-ECHS, the overall energy consumption of the MRFO is reduced by 4.5% on average. Figures 1217 show comparisons of the total energy consumption for the 400-node and 500-node networks for three different positions of the BS. In terms of the achieved total energy consumption, the proposed algorithm outperformed the PSO-ECHS and LEACH algorithms for the two networks and for all positions of the BS.

Tables 3-5 show the total energy consumption achieved by the three algorithms (i.e., LEACH, PSO-ECHS, MRFO-C) at the end of round 5000 for various numbers of CHs. In terms of the total energy consumption, the proposed algorithm outperformed the other two algorithms.

The different algorithms are then used to compare the lifetime of the network in terms of number of rounds for three different networks with sensor nodes of 300, 400, and 500 and CHs of 30, 40, and 50, and for different positions of the BS. Figures 18-20 show the comparisons of the networks lifetimes for the three networks. It is demonstrated that the proposed algorithm outperformed the PSO-ECHS and the LEACH algorithms in terms of networks lifetime. Under various conditions, the proposed algorithm extended the lifetimes of the WSN. These findings support the importance and necessity of considering the sensor nodes’ residual energy during the CHs selection process in this proposed algorithm. A CH, in fact, uses more energy than regular sensor nodes. Therefore, the energy of a CH decreases faster than the energy of ordinary nodes. When a low-energy sensor node is selected, it can die quickly, disturbing the life of the network.

To extend the network's life, CHs are chosen in the proposed method only from active sensor nodes with residual energies higher than the average residual energy. It can also be seen in Figure 18-20 that the proposed algorithm has a longer network's lifetime when the BS is at the center of the monitoring area. As the BS moves from the center to the corner or outfield of the target area, the networks lifetime decreases [13].

Finally, Figures 21-23 show comparisons of the number of data packets received by the BS for the three different networks with sensor nodes of 300, 400, and 500, and CHs of 30, 40, and 50, and for different positions of the BS. It can be seen that the BS receives the most data packets during the lifetime of the network when the proposed algorithm was used. This is because both the energy consumption and the lifetime of the network directly affect the number of packets received at the BS. The number of the received packets is greater because the proposed algorithm consumes less energy and has a longer lifetime as compared with other algorithms. Moreover, if the BS is at the center of the ROI, the number of packets received shall be higher. When the BS is moved from the center to the corner or outside the ROI, the number of packets received decreases.

Simulation in a large environment with a network size of 10001000 with 1000 nodes is conducted to prove that the proposed protocol is scalable. Table 6 shows that the proposed protocol outperforms the PSO-ECHS algorithm in terms of networks lifetime.

6. Conclusion

Manta ray foraging optimization (MRFO) is used to select cluster heads (CHs) in wireless sensor networks (WSNs) architecture. The CH selection problem in a WSN is formulated as an optimization problem using a new fitness function that takes into account various network parameters such as the average distance between the CH and the sensors in its cluster, the distance between CHS and the BS, residual energy, and CH balancing. The performance of the proposed clustering algorithm (MRFO-C) is evaluated and compared to that of the energy-efficient cluster head selections (PSO-ECHS) and the energy-efficient low-energy adaptive clustering hierarchy (LEACH) using extensive simulation results. The achieved results showed that the proposed algorithm outperformed the PSO-ECHS and LEACH algorithms in terms of energy consumption, networks lifetime, and the number of packets received. In particular, on average, the overall energy consumption achieved by MRFO-C is less than that achieved by the PSO-ECHS algorithm by 4.5%. In addition, the networks lifetime and the number of received packets achieved by MRFO-C are enhanced by 10% and 7%, respectively, compared to those achieved by the PSO-ECHS algorithm.

Data Availability

No data were used to support the results.

Conflicts of Interest

The authors declare that they have no conflicts of interest.