Manta Ray Foraging Optimization (MRFO)-Based Energy-Efficient Cluster Head Selection Algorithm for Wireless Sensor Networks

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.


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]. e sensor nodes, BS, and the end-users are the three elements that de ne 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]. ese nodes are small and cost-e ective. Nowadays, WSNs are in charge of collecting and sending information from their surroundings [3]. As a result, their performance is signi cantly a ected 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]. is 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]. e 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. e 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. e 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. e performance of the proposed algorithm is assessed and compared with that of some clustering algorithms reported in literature. e proposed algorithm outperformed some of the wellknown reported algorithms in terms of the energy consumption, the network lifetime, and the number of received packets. e main contributions of this paper are as follows: (1) e 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. e rest of this paper is organized as follows: Section 2 discusses the related literature. e details of MRFO are given in Section 3. e 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.

Related Work
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 lowenergy 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. e idea of LEACH is to select CHs based on predetermined probability. e 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. e 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. e 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. e 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. e 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. e 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. e 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. e biggest downside of the LDC is that clusters might be formed in a wrong way. e 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. en, 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. e 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. e 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. erefore, 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. e 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]. e 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]. e sensor nodes are first deployed at random in a target area and remain stationary. e 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]. is 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.
e 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]. e 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. e energy-efficient cluster head selection algorithm uses a hybrid of HSA and PSO algorithms. is 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. e 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. is 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]. e 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].

Journal of Electrical and Computer Engineering
Another clustering algorithm that uses nature-inspired methodology is the LEACH-GA [36]. e algorithm has setup 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 setup phase, the preparation stage is only performed once. e 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.
is protocol calculates the score of each sensor node using three parameters to determine the best CHs. ree 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].
is 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.

Manta Ray Foraging Optimization (MRFO)
3.1. Chain Foraging. Manta rays can detect planktons and swim toward them. e 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. is means that in each iteration the best solution is achieved and the solution on the front of each individual is modified.
e chain foraging mathematical model is given as in [40], (1) Here,

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 2 − Dspace, an individual not only moves in a spiral path towards the food but also follows the one in front of it. e mathematical equation that can be used to model the spiral-shaped movement of manta rays in 2D space is given as follows [40]: where w is a number between 0 and 1 that is randomly chosen. is motion can be modified to model n − D space as follows [40]: where β is the weighting coefficient, T is the largest number of iterations that can be executed, and r 1 is a rand number in [0, 1]. e best approach found so far is cyclone foraging, which has a good exploitation of the area of interest. is 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. is mechanism is primarily for exploration and it allows the MRFO to conduct a thorough search. e mathematical equation for this mechanism is as follows [40]: where LB d and UB d are the upper and lower limits of the d − th dimension, respectively, and x d rant is a randomly generated position throughout the search space.

Somersault Foraging.
is 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. us, they always update their positions on the basis of the best position they have discovered so far. e following is the mathematical model of this strategy [34].
e somersault factor is denoted by S � 2 which determines the manta rays range for the somersault while r 2 and r 3 are two random numbers in [0, 1]. By determining the somersault range, each individual can move to any position in a new search domain. en, they are placed in the best position to be found between their current position and their symmetrical position as given in equation (5). e 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. e dense areas around x d best 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. e t/D value is reduced from 1/T to 1, in order to make an exploratory and exploitative search.

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. e amount of energy consumed by the sensor node during transmission depends on the size of the data and the propagation distance (d). 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 to where E eleo denotes the amount of energy consumed per bit by the transmitter and receiver, E fs represents the energy consumed by the amplifier for free-space loss, E mp is the amplification energy, and d 0 represents the threshold transmission distance.
In the same way, the energy consumed while receiving l bits of data is calculated using

Network
Model. e 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) e 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) e BS is stationary and can be placed within the sensing region or outside it

Problem Formulation and the Proposed Algorithm.
First, the problem of CH selection is modeled as a constrained optimization problem. en, the MRFO is implemented to solve the optiN j mization problem by finding the minimum value of the fitness function. is 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 Journal of Electrical and Computer Engineering 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). e formation of clusters is the next phase. e 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: N: total number of live nodes M: total number of CHs S: all set of nodes in the WSN S � S 1 , S 2 , . . . , S N S CHS : the collection of CHs, S CHs � CH 1 , CH 2 , . . . , CH M N j : the number of nodes in cluster j d max : the maximum range of communication of a sensor node R max : the maximum range of communication of a CH T h : the threshold energy to become a CH d o : the threshold distance E si : the initial energy for a node E CHj : the energy of the0020 jthCH(CH j ), 1 ≤ j ≤ M E avg : the average energy of all active nodes dis(s i , s j ): the distance between the nodes S i and S j e 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 f 1 be a function of the mean total distance between each sensor and its respective CH intracluster, and f 2 is a function of the distance between the BS and the CH. For optimal CH selection, we must reduce f 1 and f 2 . Moreover, let f 3 be a function that is the reciprocal of all the CHs' total current energy. It is worth noting that this reciprocal, f 3 , should be minimized. Finally, f 4 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 f 1 , f 2 , f 3 , and f 4 . e parameters responsible for the derivation of a newly formulated fitness function are as follows.
e average intracluster distance f 1 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. erefore, the intracluster distance must be minimized in order to save energy and sensors closer to many other sensors are selected as CHs.
e function f 1 is given as follows [13]: e average sink distance (f 4 ) 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. f 2 is given as follows [13]: e residual energy (f 3 ) 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. e function f 3 is given as follows [13]: e clusters balancing (f 3 ): 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. e function f4 is given as in [41] e 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. e proposed fitness function is given as e intracluster distance, the sink distance, the residual energy, and the cluster balancing, respectively, are used to formulate the functions f 1 , f 2 , f 3 , and f 4 . e weights α, β, c, and c are used to control the contribution of the different functions f 1 , f 2 , f 3 , and f 4 . ese weights are used to satisfy α + β + c + ε � 1. 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. e problem is formulated as single objective function that represents a weighted some of all the functions to be optimized. e 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. e MRFO algorithm is used to solve the optimization problem by determining the best set of CHs to minimize the fitness function in (12). e best set of CHs reduces the overall energy consumption and increases the networks lifetime. Table 1 shows the nomenclature used in the proposed algorithm.  Step 2: for i � 1 to N p do (1) Calculate fitness of each individual (P j ) using equation (12).
(2) e best individual x best End for (c) Step 3: END if ELSE\\ Chain foraging Step 4: END FOR (e) Step 5: Return the best solution found so far. x best (f ) Step 6: e nearest sensor nodes to x best are the selected CHs. Regarding cluster formation, after the CHs have been chosen, non-CH nodes send request messages to the CH to join the cluster. e 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. e e pseudocode of the proposed CH selection algorithm is shown in Figure 1 while Figure 2 depicts the flowchart of the MRFO-based clustering algorithm.

Simulation Results and Comparison
MATLAB is used to implement the MRFO-C. ree 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. ese 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. e performance of the proposed algorithm to design WSN is compared with that of some well-known Journal of Electrical and Computer Engineering clustering algorithms such as the PSO-ECHS algorithm in [13] and the LEACH algorithm in [14]. e simulation parameters for the proposed protocol are listed in Table 2.
e following metrics are used to evaluate the performance of the proposed algorithm: (1) e total energy consumed in a number of rounds, during which the CHs collect, aggregate, and route data to the BS (2) e networks lifetime is measured as the number of rounds until the last node death (LND) (3) e 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., (200 X 200 m 2 ). 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 −5.2, 9.3, it will be changed to 0, 9.3 e 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 (200 × 200 m 2 ). Figure 4 shows the 30 CHs that are selected using the MRFO algorithm from the set of 300 sensor nodes in a monitoring area (200 × 200 m 2 ). Figure 5 shows a randomly deployed wireless sensor network with 400 sensor nodes in a monitoring area of (200 × 200 m 2 ).
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 (200 × 200 m 2 ).
Another randomly deployed wireless sensor network but with 500 sensor nodes in a monitoring area of (200 × 200 m 2 ) is shown in Figure 7. e 50 CHs selected using the MRFO algorithm from the set of 500 sensor nodes in a monitoring area of (200 × 200 m 2 ) are shown in Figure 8. Figures 9-11 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 12-17 show comparisons of the total energy consumption for the 400node 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.        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. ese 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. erefore, 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. is is because both the energy consumption and the lifetime of the network directly affect the number of packets received at the BS. e 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 1000 * 1000 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.

Conclusion
Manta ray foraging optimization (MRFO) is used to select cluster heads (CHs) in wireless sensor networks (WSNs) architecture. e 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. e 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.
e 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
e authors declare that they have no conflicts of interest.