A Novel Algorithm to Optimize the Energy Consumption Using IoT and Based on Ant Colony Algorithm

: Internet of Things (IoT) is a new concept in the information and communication technology studies which indicates that any creature (human, animal, or object) can send and receive data through communication networks, such as the internet or intranet platform. Wireless sensors have limited energy resources due to the use of batteries to supply energy, and since it is usually not possible to replace the batteries of these sensors. In addition, the lifespan of the wireless sensor network is limited and short. Therefore, reducing the energy consumption of sensors in IoT networks for increasing network lifespan is one of the fundamental challenges and issues in these networks. In this paper, a routing protocol is proposed and simulated based on an ant colony optimization algorithm’s performance. The clustering is performed with a routing method based on energy level criteria, collision reduction, distance from the cluster-head to the destination, and neighborhood energy in the proposed method. The cluster head is selected based on the maximum residual energy, minimum distance with other clusters, and consumed energy. This energy is minimized to reach the base station. The node with more energy than the threshold is selected as the new cluster head. Then, four conditions are applied for routing: the shortest path, the leading path, the shortest distance to the source node and the destination node, and routing. Results show that after about 50 cycles of transferring information, only the average of 19.4% of the initial energy is consumed in the network nodes. Therefore, obtained results illustrate that the proposed method helps to retain the energy more than 40% comparing the available methods.


Introduction
The Internet connects all users, but this network's structure is changing, and a new member is being added to the accumulation. This new member is not a user and is referred to as (Things) [1,2]. The word is derived from the phrase "of the Things." A Thing may be addressed to any device that has a sensor for exchanging information [3]. In general, the Internet of Things is a network of physical objects embedded with electronic components [4], software [5], sensors [6], and connections [7]. Therefore, they can provide more value and services by exchanging information (at unprecedented speeds and scales) with manufacturers, operators, or other devices.
The Internet of Things can improve the quality of life in various areas, including medical services, smart homes, smart cities, industry, environmental and water protection, energy management and consumption, and more [8]. Data transfer is significant for communication and in human-to-human or human-machine or machine interaction, since time plays a vital role in data transfer, so that a message will reach its destination within a permitted period. Therefore, the data must use the minimum or shortest route to reach the destination in such a way. Routing is creating and maintaining paths between nodes in wireless networks and is an essential issue in Internet of Things (IoT) networks [9]. A significant challenge for researchers is to develop routing algorithms in IoT networks. Firstly, in IoT networks, the paths are continually changing due to the dynamic nature of the nodes in these networks, which causes frequent changes in network connectivity and segmentation and new routes need to be discovered for data transformation. There are two types of routing protocols based on topology and clustering criteria [10,11]. The topology criterion refers to nodes and objects orders in the network (based on the maintenance of routing information), and in the clustering technique, the nodes are grouped within a cluster [12]. In each cluster, a cluster head is selected, and the cluster head communicates with the other cluster heads to transfer the packet, which ultimately saves the node energy by communicating through the cluster head. Numerous studies were conducted on energy saving issues in wireless sensor networks [13].
The IoT system needs a robust network infrastructure and a proper routing structure. Energy consumption issues must be considered to increase the lifespan of the node in grid systems. There are essential features such as energy-saving and the life extension of wireless networks for nodes. A node spends most of its energy on transmitting and receiving packets. In the IoT, the primary source of power for the node is the battery. However, in most cases, it is difficult for users to reach the location of the nodes. Battery replacement is often impossible due to a large number of nodes. However, the battery power of a node is also limited. Therefore, energy conservation has become a significant concern in wireless networks. It is necessary to develop new and efficient energy-saving schemes to reduce energy consumption and extend the grid life. This paper aims to present a routing method based on machine learning algorithms to reduce energy consumption and increase network life in the IoT system. In these networks, it is possible to determine the best path to the optimal points (destination) using machine learning algorithms [12][13][14][15]. This paper aims to use the efficient, ultra-innovative, and nature-inspired optimization algorithm called the ant colony optimization algorithm to route IoT and optimize energy consumption and network life. This method is inspired by the routing of leading ants and placing a substance called a pheromone. This paper is organized into five sections. The second section reviews the previous work, and the third section describes the proposed algorithm for optimization. In the fourth section, the simulations' results are presented, and a general comparison is made between the proposed design and some published references in recent years. In the fifth section, a summary of the proposed method and conclusions will be presented.
The main contributions of the paper can be listed as follows: • Applying simultaneous application of energy level criteria, reduction in collisions, and distance from the node to the destination and neighborhood energy in clustering.

•
Proposing a novel approach to optimize the pattern to route and send information. • Implementing the colony optimization method for the energy consumption of sensor networks in IoT.

Routing Algorithms in IoT Platform
In [16], to reduce delivery delays, a method was proposed and simulated for routing in the Internet of Things using a public algorithm. The proposed algorithm for synchronizing duplicate databases ensures a sufficient number of random data exchanges on the network so that all nodes can eventually receive all the messages. As a result, all messages are delivered to the destination. Available routing is similar to massive sending on a network because it tries to send every message to all network nodes. Of course, in each step, like massive sending, the message is not sent to all neighboring nodes, but it tries to determine the location of the recipient using several unique methods (such as using GPS) so that the network resource consumption (such as memory) is reduced. However, this method strongly requires bandwidth and buffer.
In [17], a simple routing method called direct forwarding was proposed, in which when the source node generated a message, it stores it in its buffer and carries it until a collision with a destination node and delivers the message to it. This method generates one copy of the message, and as a result, the least data transfer is performed to deliver the message, and the overhead is minimized on the network. However, the message's delivery may be delayed too much because there are no restrictions on the delivery delay.
In 2016, researchers used content-oriented routing technology to solve the traffic congestion problem in the central network area [18]. With routing data related to intermediate relay nodes for processing, it is possible to achieve data at a higher speed, thus effectively reducing network traffic. As a result, a significant reduction in latency can be achieved. In addition, duplicate data transmission can be eliminated after data collection, which mainly reduces wireless communications' energy consumption and saves battery life. Therefore, in this paper, two methods for implementing this technology were proposed and simulated. The first method is content-centric routing (CCR), and the second method is the integration of the first method with the Internet Engineering Task Force Routing Protocol for Low-Power and Lossy Networks (IETF RPL) protocol, both of which are implemented on the Contiki operating system using the TelosB platform. The simulation results show the superiority of the first method in low network latency, high energy efficiency, and reliability.
In 2015, after reviewing various IoT routing methods by researchers [19], an optimizing energy consumption algorithm called Energy-Efficient Content-Based Routing (EECBR) was proposed and simulated. The proposed algorithm uses a virtual topology that is centrally constructed, and routing is distributed in such a way that the path of the generated events is directed to the desired subscribers or sensors. This method has been implemented and simulated with Omnet ++ software, and the simulation results have better conditions in terms of the energy variance than the compared ones. A novel modelling framework has been introduced in [20] to model the security-energy-environment issues as the main features in considering the quality of service (QoS) for the applications of the Internet of Things. In [21], an overview on the energy management in the Internet of Things environment was presented. This review aims to recognize significant research trends of power consumption in Internet of Things platform.
A method for eliminating the shortcomings and deficiencies related to resource constraints in the field of memory, computing power, and the energy of the wireless sensor terminal node in the Internet of Things is presented in the reference [22], which is performed by the IoT routing method and based on the informed clustering of energy. This method is called resource-aware Ad hoc On Distance Vector (RA-AODVjr) and is designed by combining RA clustering and AODVjr routing protocol. In this protocol, the best neighbor in the terminal node is selected, and the network traffic is balanced when the source of the terminal node is limited, and the wireless routing network is used. The simulation results show that the conditions for achieving load equilibrium with energy-limited nodes are limited. Compared to the original AODVjr protocol, the method proposed in this paper achieves load balancing with better conditions, and this is due to better neighbor node access technology, which achieves better balance in the local network traffic, and the average latency due to better routing. In 2014, researchers proposed two methods for routing the Internet of Things based on the ant colony algorithm [23]. The EEPR method, which routes to missing packets, is probabilistic. The EEPR algorithm controls the requested packets to reduce missing packets and network traffic in the AODV protocol. A source node forwards Route Request (RREQ) packets to neighboring nodes to send the data packet. In all types of AODV protocols, each node that forwards an RREQ packet sends the same packet to neighboring nodes. In other words, any node that does not forward RREQ packets indicates that it has disconnected the entire connection. The energy distance function is used to implement the EEPR method. Therefore, in this paper, two different routings were developed. One is Expected Transmission Count (ETX), which creates a good connection between the nodes. Each node periodically receives packets from a small band and sends them to neighboring nodes. In the second method, through the energy variance of adjacent nodes, the probability of a link between two nodes is performed. The simulation results in an extensive network with a high lifetime using the cloning algorithm and showing better results than the AODV algorithm.
Spyropoulos et al. proposed a method called "distribution and focusing" to limit the overhead of delivering a message [24]. In this method, we first enter the distribution phase, in which the source generates L number up to the sending signal with each new message. The token means that the host node can generate and send another copy of a specific message. When a replay node has only one signal to send, we enter the focus phase, where the message can be sent to another replay node according to specific criteria. These sending criteria are based on timers that record the time elapsed since the two nodes met.
In 2018, Youssef et al. presented a clustering scheme to extend nodes' lifespans in the Internet of Things [25]. One of the most critical problems and challenges in the Internet of Things is reducing power consumption to extend the network's lifespans. The clustering method is one of the approaches which is used to consume energy efficiency. However, most of the clustering schemes are chosen randomly without considering important parameters or based on a centralized approach using a base station that can affect the network's scalability. In addition, single-hop communications are used by clusters to send their measured data to clusters, leading to increased cluster energy consumption in large-scale networks. Therefore, in this paper, a clustering scheme based on a distributed approach is proposed. Different parameters are considered for cluster head selection as well as for multi-hop communication.
The results show that the proposed scheme has better performance in energy consumption and the number of viable nodes.
In 2015, Bouyer and colleagues proposed a new way to reduce energy consumption in the IoT. The optimal use of energy in these types of networks is crucial. Recent research shows that organizing network nodes in some clusters increases energy efficiency and ultimately increases network lifespan. Therefore, controlling the number and location of cluster heads and the size of the cluster in terms of the number of nodes leads to a balance in the energy use of the cluster heads and increases the network lifespan. Clusteringbased routing protocols are energy-efficient protocols that improve the lifespan of an IoT-based network. The purpose of clustering is to minimize the total transfer power by adding it to a single path for a longer network life. In this paper, the fuzzy c-means (FCM) and C-means algorithms are used for the optimal number of cluster heads and their position. The application of FCM in routing helps to change Low Energy Adaptive Clustering Hierarchy (LEACH) parameters during execution. The results show that the hybrid algorithm increases the network lifespan compared to the LEACH algorithm [26].

Optimization Approach in IoT Routing
In 2015, Leo et al. proposed an energy-efficient clustering scheme for nodes' lifespan in the IoT network with separate nodes. A suitable clustering algorithm for node classification can increase grid energy efficiency. However, clustering requires additional overhead, such as selecting and determining the cluster head and cluster construction. This paper proposes a new regional energy-conscious clustering method using separate nodes called REAC-IN. In REAC-IN, cluster heads are selected based on weight. The weight is determined based on each sensor's static energy and the average regional energy of all sensors in each cluster. Improperly distributed clustering algorithms can separate nodes from clusters. These disconnected nodes communicate with the sink by consuming excessive amounts of energy. The average regional energy and the distance among the sensors and the sink are used to determine whether the isolated node sends its data to the threaded node in the previous node or the sink. This process is performed to increase the network's lifespans. The simulation results of the current study showed that REAC-IN optimizes other clustering algorithms [27].
In 2015, Azharuddin et al. introduced a clustering algorithm and fault tolerance and energy-efficient routing algorithm for wireless sensor networks. Energy conversion and fault tolerance are two significant issues in deploying a wireless sensor network. The design of routing and clustering algorithms for large-scale wireless sensor networks should address these issues for long-term network operation. This paper proposes distributed clustering, and routing algorithms commonly referred to as Distributed Clustering and Routings (DFCRs). It has been further proven that this algorithm has optimal energy consumption and fault tolerance. The DFCR algorithm uses the distributed time retrieval of distributed sensor nodes due to a sudden error in the cluster vertices. This algorithm considers the sensor nodes without cluster heads in its communication domain. The researchers performed extensive experimental tests on the proposed algorithm using various network scenarios. Then, the experimental results are compared with the existing algorithms to show the algorithm's performance power in terms of various metrics and achieve the desired results [28].

Motivation
The ant colony algorithm is inspired by scientific studies and observations on ant colonies. A moving ant leaves a certain amount of pheromones (in different sizes) which determine the path. Among the most critical and exciting behaviors of ants is their behavior to find the path, especially how to find the shortest path between the source and the original path. This type of ants' behavior has a kind of mass intelligence that finds the best and shortest path based on the signs they leave [29,30]. Therefore, these algorithms are based on the ability of simple ants to solve complex problems through cooperation. The collective behavior of these ants can be used when calculating the routes.

Background
This paper's primary purpose is to design an algorithm based on the decentralized performance of ants, using their natural ability to find the shortest path between the origin and destination by moving in the network, which uses routing criteria as optimal target functions and optimizes routing on the Internet of Things. In order to solve various problems with the ant colony algorithm, their necessary behavior must be considered: -They likely choose the path that has the most pheromones, or in other words, the one more ants have already crossed.
-On the other hand, the methods by which some insects select a leader for decisionmaking lead us to the formation of a computer algorithm that can play an essential role in the network efficiencies.
The primary intellectual basis of the ant algorithm is: "Among the obstacles and limitations in nature, ants always choose the most optimal way from different permutations to reach food." According to pheromones and ant's traveling, where more ants have already traveled, this leads to finding the shortest way to solve the routing problem and thus reduce energy consumption in this paper. Artificial ants are used as optimizing elements to implement ant colonies. Of course, these elements are fundamentally different from real ants, which are: memory, artificial barriers, life in a discrete environment [31].
Let A is a nest, E is a food source, FC is a barrier. According to the obstacles, the ant goes only through F or C from A to E or E to A; the distance between the points is shown in Figure 1. For each time unit, there are 30 ants from A to B, and 30 ants from E to D. When the quality content hormone (information) for ease of calculation is extracted during the material immobility at the initial time, the paths DC, DF, BC, BF, which have no information, is placed in B and E and ants choose a random path. From a statistical point of view, we can say that the probability of choosing DF, BC, BF, and DC is the same. After the time unit, the amount of information on the BCD path is twice the BFD information's content. T is the red moment; there will be 20 ants from B to C, ten ants from B and D to F. Over time, ants choose the BC path with more probability. Finally, the path selection, D, is made from the nest to the food source to find the shortest path [31]. In the following subsections, the functions and elements of the ant algorithm are included:

Pheromone Function
In the first equation, the amount of k pheromone of ant is calculated on the d ij edge and in the second equation, the total pheromone on that edge is calculated by traveling the m ants [31]:

Heuristic (Visibility) Function
Equation (3) is also called the visibility relationship, and the ratio shows the inverse of the distance of each edge, and for any constant amount of pheromone, the shorter the edge length, the higher its density:

Probability Function
This function determines the probability of selecting the next city and is calculated for all cities where the ant k can be selected from city i. For the maximum value of this function, the traveling is followed from i to the selected city based on the value of this function.

Update Function
When the next city is selected, and before starting the next step to identify the next possible city on the route, the pheromone function is updated to evaporate some of the pheromone that occurs over time to prevent rapid convergence in the algorithm: Equation (5) calculates the amount of pheromones at time t + 1. This relationship consists of two components: (1) this section contains the total amount of secreted pheromones in the distance (t, t + 1); (2) since some parts of the pheromone evaporate over time, so this part of the relationship expresses the pheromone value of time t with a coefficient (ρ-1). Therefore, the whole relation calculates the net amount of pheromones at time t + 1 [31].

1.
Determine the initial value for the pheromone function and the heuristic function; 2.
Enroll the city of origin for each ant in the banned list; 3.
Calculate the probability function to select the next city for each ant in each city; 4.
Normalize the population of cities for selecting each ant to the banned list of that ant; 5.
Add the selected city of each ant to the banned list of that ant; 6.
Determine the best route; 7.
Update and go to step 3.

The Proposed Method
The proposed method for routing in the IoT is performed to reduce energy consumption in two phases. The steps of the proposed algorithm are depicted in Algorithm 1. The first phase is related to clustering, and the second phase is related to steady state for routing. For optimizing energy consumption in sensors in the Internet of Things, the clustering method is an effective way to reduce the energy consumption of sensors and raise their lifespan and thus increase the overall lifespan of the network. Clustering is used to reduce energy consumption in the grid, and dynamic cycles are used to prevent re-clustering. Algorithm 1 proposed algorithm steps.

1:
Phase one 2: Sensors clustering (inputs: energy and distances) 3: Cluster heads ← higher-energy nodes 4: Clinging other nodes to cluster heads based on their distance 6: Phase two 7: Steady-state for routing 8: Send data to cluster head 9: Selecting best route neighbor nodes (output: best node for transferring) Several higher-energy nodes will be selected for network clustering as cluster heads based on the amount of residual energy in the sensor nodes. The other available sensor nodes will be attached to each selected cluster head based on the selected cluster heads' distance and then become cluster members. Eventually, clusters will be generated in the network. Accordingly, member nodes sense data from the environment and send it to their cluster head. The cluster heads are then created based on routing, and the distance to the central station sends the aggregated data received from the nodes of their cluster to another cluster head as the next step in routing or directly to the base station.
Hierarchical clustering on the Internet of Things can significantly affect global scalability, lifespan, energy efficiency, and latency. Hierarchical routing is an efficient way to consume less energy within a cluster, aggregation, and data combination to reduce the number of sent messages to the base station. A single-level network may overload the cluster heads with increased sensor density.
Such an overload may lead to the unsuccessful proceeding of events. In addition, a single-level architecture is not scalable for a broad set of nodes that cover a large area because sensors cannot usually communicate over long distances. Hierarchical clustering is significant, especially in applications that require scalability. Scalability in this area requires load balancing and the proper use of resources and applications that require effective data aggregation. Clustering is part of routing protocols.
Clustering has numerous other benefits with different goals, such as supporting network scalability and reducing energy consumption (through data aggregation). In this paper, through the application of the clustering method based on the ant colony algorithm and the mentioned advantages, we also reduce the collisions, which are discussed as the newest challenges in wireless networks. On the other hand, clustering can stabilize the network topology at the sensor level and reduce the overhead and overall maintenance costs of the topology; this means that the sensors are maintained only when they are connected to their cluster heads and are not affected when there are changes in the levels between the cluster heads. The cluster head can also implement optimized management strategies, which will improve network performance and increase the battery life of nodes, thereby increasing network life.
Clustering-based routing protocols are one of the most important ways to reduce power consumption in wireless sensor networks. This new clustering protocol, called the ant colony algorithm based on clustering algorithm, clusters the network nodes based on the criteria including the energy level, collision reduction, and distance from the cluster node to the destination and neighboring energy, and tries to balance the energy in the cluster better and ultimately increase network life and maintain network coverage. This paper aims to improve the traditional idea of clustering (spatial clustering) to achieve the primary goal of wireless sensor networks, i.e., to increase network life while maintaining network coverage and provide an integrated method for clustering based on energy location. We believe that in presenting the new algorithm, energy-based clustering could create clusters with the same energy level and distribute energy consumption across network nodes. The flowchart of Figure 2 shows the main steps of the proposed method for routing in the target network. As can be seen in the diagram, the routing in the proposed method has three necessary steps as follows:
In the continuation of this section, each of these steps will be explained.

Clustering
This step of the proposed method's primary purpose was to divide the sensor network nodes into clusters. The sensor node clustering phase consists of two stages. In the first stage, based on validation indicators, the optimal number of clusters is determined. The clustering algorithm depends on several factors, such as the number of clusters and the distance between clusters. One of the most critical issues in clustering is selecting the right number of clusters.
In general, the number of clusters is appropriate when: -The samples in a cluster are as similar as possible. A common criterion for determining data density is data variance.
-Samples of different clusters should be as separate as possible.
The above conditions are also expressed so that the clusters should have maximum compaction, and their separation should be as high as possible. Clustering can be defined as an unsupervised classification method in which there is no prior knowledge of categories. The minimum default is to provide a suitable solution for clustering in all available methods to determine the number of clusters. It contradicts the basic assumption of unsupervised classification in the clustering definition. Traditional clustering algorithms are suitable methods for clustering that require the number of clusters at the beginning of the algorithm. The purpose of cluster validation is to find clusters that best fit the data. In general, it can be said that three methods are used to measure and calculate the separation of clusters, which are:

•
The distance between the nearest data from two clusters; • The distance between the farthest data from two clusters; • The distance between the centers of the clusters.
The primary purpose of sensor clustering is to divide the sensors into several different clusters based on their similarity. Therefore, each cluster's sensors are more similar to each other, and the features in different clusters are less similar to each other. Most of the proposed methods for sensor clustering have drawbacks.
Among such shortcomings, one can mention the following cases: -In most clustering methods, the number of clusters must be determined before performing the clustering algorithm. In other words, in most of these methods, parameter k, which specifies the number of clusters, must be specified by the user. In general, it is difficult to determine the number of clusters for the initial characteristics, and only the number of optimal clusters can be determined by trial and error.
-Data distribution in a cluster is one of the essential criteria in clustering, which is not considered in most previously proposed methods for clustering sensors. The degree of scattering of features in a cluster can significantly enhance the performance of the clustering algorithm.
-In most existing methods for clustering sensors, all features are considered the same during the clustering process and will have an equal effect on clustering. While in some cases, it is better to have a more significant impact on the clustering process for many features that are more similar to each other.
In this paper, to address these problems, a specific algorithm called the ant colony optimization algorithm was used to cluster sensor nodes.

Optimization of Cluster Centers
This step's primary purpose was to select a cluster center from each cluster based on a set of defined criteria. The following combination of four criteria is used to select cluster centers:

•
The total energy of selected cluster centers; • The total distance of the nodes of that cluster from the center of the cluster; • No central node collision inside the cluster; • The total distance of the selected cluster centers from each other.
As the first criterion is increasing, and the other three criteria are lowered, the cluster centers are better positioned. As a result, the proposed method is a multi-objective algorithm that needs to be optimized. With the multi-objective nature of the fit function problem for selecting cluster heads, the proposed method is defined as follows: f 1: Total energy of selected cluster centers; -f 2: The total distance of the nodes of that cluster from the center of the cluster; -f 3: No collision of the center node of the cluster with the nodes inside that cluster; -f 4: The total distance of the selected cluster centers from each other.
The ultimate fitness function is defined as Equation (6): Here γ, β, α are four fixed parameters that determine the impact of these four different criteria. The goal of optimization is to maximize the above objective function. Since the second and fourth criteria must be minimized, they are placed inversely in the fitness function. Using the ant colony optimization algorithm is to select a cluster head node in each cluster based on different parameters.
When clustering is performed, the distance between all nodes is measured with other cluster nodes, and the node with the least distance is selected as the cluster node. Nevertheless, the most important thing is not to collide in routing, and thus, the cluster head node may be changed and not measured only by distance and energy. Therefore, at each routing step, the amount of residual energy of the cluster head node will be compared to a predefined threshold, and if the energy level is less than this amount, another node in the same cluster will be selected with more residual energy than the cluster head and replaces the previous cluster head and acts as a member node. If there is no node with more residual energy than the cluster head in a cluster due to non-collision, re-clustering will be applied to the grid, which includes high energy overhead and reduces the grid's life.

Data Transfer
When the clusters are formed, and the cluster heads of each cluster are selected, normal nodes send the sensed data to the relevant clusters. The cluster heads send the data packet to the base station after applying the community functions or data combination. In order to calculate the energy, first, the energy of each node is measured, and then the consumed energy to transmit k data bits to the distance d is calculated as Equations (7) and (8): Energy consumption to receive k data bits is calculated as Equation (9): In the above relationships, E elec is the electronic transmit/receive energy, k, message size in terms of number of bits, d distance between receiver and transmitter, E tx_amp , amplification energy, ε f riss amplification factor, dc rossover , threshold distance whose transmit factor changes in it.
The following conditions are then considered for routing: 1.
The most optimal path is selected as the shortest path to transmit a message between two nodes; 2.
Routing is conducted in a progressive way to reach the goal; 3.
The distance of the nodes is measured to select the path with the source node; 4.
The distance of the desired nodes to the destination is also measured.
With the above conditions applied, a neighbor node condition is selected with all the above conditions. For optimization with the ant colony algorithm, these paths are entered in this algorithm. Then, a matrix is generally formed for each path. When this matrix is formed, the most optimal path is selected using the ant colony algorithm. For the nodes' energy to be close together and the network not to put too much pressure on individual nodes, all nodes are used for routing during execution, and the energy variance is low.

Simulation Results
This section states the simulation process, expresses the results, and compares the proposed method with different methods. It should be noted that the hypothetical environment for simulating is a square environment with 200 × 200 dimensions, and the cycles are repeated 50 times. In order to simulate the proposed method, the MATLAB software environment was used. When different cycles of the algorithm are repeated, and successive changes have occurred in multiple cluster heads, and routing is performed for this cluster change, and the following figure shows the multiple traveled paths to transfer information after 50 cycles. The traveled routes for 50 rounds of simulation repetition can be shown in Figure 3. It is seen that routing is performed between almost all nodes in different cycles in order to distribute energy consumption throughout the network. Figure 4 shows that after about 25 cycles of 50 cycles, the average of 28% of the initial energy is consumed in the network nodes. It indicates the high energy consumption of the sensor network in its initial stages. Figure 5 also shows the average residual energy in the nodes after 50 cycles of the algorithm. In these 50 repetition cycles, about 49% of energy is consumed, which indicates the optimality of the proposed method in increasing the network lifespan.   Figure 6 shows the mean energy variance in 50 times of simulation. This figure shows the low energy variance due to the close energy of the nodes in the network, as the goal is to use all nodes in routing.
The proposed method is compared with three different types of algorithms. The results of these three algorithms are shown with the proposed method. Figure 7 shows the residual energy of different algorithms with the comparison of the proposed method. For better comparison, each method is simulated and presented in 50 repetitions. Each method that preserves the energy is more effective and better. Hence, the lower slope of the lines demonstrates the higher performance of the method. This result shows that the proposed method was successful to retain the energy more after several cycles. The EEUC was the weakest method in energy consumption and the energy reached 0.030 from 0.107. This means that through the EEUC method, more than 71.96% of the energy is consumed after 50 cycles. Additionally, the four algorithms are compared in a column in Figure 8. All four algorithms were simulated with specific energies in 50 rounds, and the reduction percentage of initial energy and residual energy is shown. This figure shows that the proposed method with an ant colony algorithm has a more optimal percentage than the other three algorithms.  For further comparison, the number of dead nodes in 50 simulation cycles is compared for 100 nodes. Figures 9 and 10 show a comparison of the number of dead nodes and the percentage of dead nodes, respectively. According to the results, the proposed method with an ant colony algorithm shows better results than other methods. In the initial iterations, due to the ant colony algorithm's nature, the recovery percentage is slightly slower than subsequent iterations. Table 1 shows the results of the first time that one of the sensors in a node dies for different methods. It can be seen that the first node lasts during 21 cycles and after that the trends of defection are comparatively slow using the proposed method. Nonetheless, the first node dies very soon and in less than four cycles for other methods.

Method Proposed EAMMH LEACH
No. of cycles 21 3 2 Figure 10. Comparison between the number of dead nodes in different algorithms.

Conclusions
In this paper, we tried to improve the performance of energy savings in the Internet of Things based on the evolutionary algorithms. In order to achieve this purpose; the clustering method was applied to increase network life and control sensor nodes' energy consumption in the Internet of Things platform. The ant colony optimization algorithm was used to optimize the routing method, and acceptable results were observed compared to other algorithms. Using the proposed method, the consumed energy for 25 repetitions was about 28% of its original energy, and the mean variance for energy indicated that the energy of the nodes is close to that of others due to the use of all nodes for simulation. These achievements demonstrate that the proposed method can simultaneously decrease the consumption of energy and increase the lifetime of the nodes. Moreover, according to the comparison with other algorithms, the proposed method is about 50% more advanced than the known algorithms and saves more energy and reduces the number of dead nodes by about 81%. One of the shortages of this method is the lack of an optimization approach in the clustering stage. It is suggested to use the ant colony algorithm or other suitable approaches for the clustering stage as one of the possible future research avenues to continue this work.

Conflicts of Interest:
The authors declare that they have no known competing financial interests or personal relationship that could have appeared to influence the work reported in this paper.