# A Novel Algorithm to Optimize the Energy Consumption Using IoT and Based on Ant Colony Algorithm
## 5 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 \(\times\) 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 3: The traveled routes for 50 rounds of simulation repetition. 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  
Figure 4: Residual energy after 25 repetitions. Figure 5: Residual energy after 50 repetitions. 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. Figure 6: Mean energy variance in 50 repetition cycles of the simulation. Figure 7: Comparison between the residual energy of different algorithms with the proposed method. Figure 8: Comparison of the percentage of residual energy reduction in 50 repetition cycles for different algorithms.