Proposing a Algorithm for Optimizing Energy Consumption

The purpose of this paper is to use the social spider algorithm to improve energy consumption in wireless sensor networks. In this regard, finding a suitable place for routers was done with a social spider algorithm in the system by selecting and optimally placing elements in the network and revising the Objective function. To use it, the initial number was 12, and the maximum number of loop iterations in the algorithm was 100 replications. We achieved these values with several runs and errors. Besides, to achieve the best results, to solve the problem, they can be considered as the default algorithm. In this research, the MATLAB implementation language was used to implement the spider algorithm, and then NS 2.35 tool was used to simulate the network environment and use the algorithm. In this study, three standard gate placement algorithms were used for comparisons, including BRP, RDP, and RGP. The results showed that the proposed method could have the lowest energy consumption. It can cause fair and uniform energy consumption between all nodes. It will also increase the lifetime of the network. Optimization of routing algorithms for such networks by using the spider algorithm also reduced the number of errors (failures) in the system and increased the life of the network with the help of the mentioned method. The proposed method, compared to the techniques presented before this study, is acceptable and, while creating the desired capabilities in terms of security, does not impose much time overhead on the system.


Introduction
The wireless sensor network is distributed from a large number of usually small wireless sensors.It has an irreplaceable limited energy source, one or more sensors, a computing unit, and a radio transmitting and receiving unit [1].A sensor network consists of a large number of sensor nodes that are located within a widely distributed area to collect data and information about that location.And the location of these sensor nodes may not be known in advance, and this feature allows us to use sensor nodes in inaccessible and hazardous environments [2].Limitation of nodes in terms of battery power and the available bandwidth is one of the features considered in these networks [3].Once the nodes are deployed in the environment, for example, behind enemy lines, inside a nuclear reactor, or in the forest, it is impossible to access or replace the nodes.This has led to a lot of attention to save energy consumption of nodes and increase network lifetime [4].Different methods are used to perform energy consumption reduction operations based on network topology and node characteristics, weather and environmental conditions, and constraints in various states; Therefore, in wireless sensor networks, prolonging network lifetime, saving energy, improving coverage, and load balance is critical factors in designing a protocol.The Social Spider Optimization Algorithm is a new optimization algorithm introduced in 2015 by a person named James.The social spiderseeking behavior can be described as their mass movement towards the food source.On the web, the spider receives and analyzes published vibrations to determine the potential path of the food source.This natural behavior is used to optimize the search space in this way.Each position on the web indicates that it is a practical solution to the optimization problem.Besides, the web acts as a medium for transmitting vibrations produced by spiders.On the web, each spider has a position and a fit and represents finding a food source in that position.The spider can move freely on the web but not on the single web.When a spider wants to move to a new place, its motion will generate a vibration that spreads throughout the web.Each spider vibration contains information from a spider, and others can receive this vibration information [5].The social spider algorithm is designed to simulate the search behaviors of spiders, which can be a perfect option in improving routing to reduce energy consumption and increase network lifetime.Power can also significantly reduce latency.Since the basic paper [6] used a bee colony to optimize routing and improve energy consumption in the WSN, the simulation results show that using this algorithm compared to other older protocols used has consumed less energy.Weaknesses of this research work include performing experiments on small and unrealistic data platforms, low network coverage (amount of space understudy), low number of nodes, etc.All of this means that the criteria under review do not improve significantly.With these details, the purpose of this paper is to use the social spider algorithm to improve energy consumption in wireless sensor networks.In this regard, energy efficiency is investigated based on the social spider algorithm, which indicates the extension of network lifetime.The social spider algorithm is designed to simulate spider search behaviors that can be successfully used in routing techniques.Finally, the performance of this proposed method in the WSN network will be compared with other optimization algorithms.To achieve the objectives of the research, the following questions are raised: 1) How will the proposed method reduce energy consumption in the WSN? 2) How to optimize routing in WSN by using a social spider algorithm?3) How can the social spider algorithm in WSN select more suitable nodes for the network backbone for routing?
examine the SMO mechanism in the context of WSNs, formulating a mathematical model of behavioral patterns that is adapted to the cluster-based SMO-C approach.The proposed method is based on the behavioral structure of spider monkey, to improve traditional routing protocols in terms of low power consumption and network system quality [10].Inspired by social spiders, the authors of this article proposed a new social spider algorithm to solve global optimization problems.This algorithm is mainly based on the strategy of feeding social spiders and uses vibrations on the spider web to determine the position of predators.From the various proposed intelligent algorithms, a new model of social nutrition strategy to solve optimization problems was introduced.Besides, they performed a sensitivity analysis of the initial parameters for the proposed algorithm, and instructions for selecting parameter values were created.The social spider algorithm is widely used using numerical functions, and the proposed algorithm has superior performance compared to other advanced algorithms [11].This paper introduces a Bee Cluster energy-efficient clustering protocol based on ABC metacognition that inherits the proposed meta-host capabilities to achieve optimal cluster heads and energy efficiency in WSNs.The simulation results show that the proposed clustering protocol performs better than other known protocols based on packet delivery, power consumption, power consumption, lifetime, and latency as performance metrics.In this article, which was selected as the baseline article, a bee colony was used to optimize routing and improve energy consumption in WSN [6].In this paper, we present a modified mono heuristic artificial bee with an improved solution search equation to improve exploitability.An energy-efficient clustering protocol based on metacognitive iAbC has been introduced that inherits the proposed meta-tag capabilities to obtain optimal clustering and improve energy efficiency in WSNs.The simulation results show that the proposed clustering protocol performs better than other known protocols based on packet delivery, power consumption, power consumption, network life, and latency as performance metrics [12].
WSN wireless sensor networks are a network of hundreds of sensory nodes.Since the lifetime of the system is directly related to the lifetime of each node, the power of each node is limited, and the WSN is under severe pressure.This paper proposes a framework based on the service-oriented architecture in cloud computing to provide services to users.And data is also collected in the data center by the WSN based on the bee routing protocol at regular intervals.Since the proposed framework is based on service-oriented architecture and routing strategy of the artificial bee colony algorithm, it provides easier access and data development [2].Recent studies have shown that mobile wells can solve the problem that energy consumption by sensor nodes in wireless sensor networks is not balanced.In this paper, a routing protocol based on a bee colony algorithm is presented to solve this problem.This protocol uses the concentric loop mechanism to guide the path search and selects the optimal path to establish the way delivered in the WSN with the associated well.Using an artificial bee cloning algorithm to optimize the transmission path, the routing protocol can find an alternative method when changing the good coordinates in the WSN with high speed and efficiency.The experimental results show that the proposed routing protocol can balance the network traffic load and increase its lifetime [7].
The proposed algorithm of this paper is new evolutionary multiple optimization methods based on the spider optimization algorithm.In this algorithm, the optimal is searched in the form of separate subpopulations that are evolving.The proposed method uses a measure of the mass of spiders around the optimum.A subset of spiders that evolve to this threshold means that they have an optimization, and that optimization must be stored in external memory.Besides, after several repetitions, the answers stored in memory are included in all our optimizations.In this way, global and local optimizations are identified in the problem.The numerical results also show the efficiency of the proposed algorithm [8].In this paper, a new sensor design based on the social spider optimization algorithm is proposed to increase coverage for WSNs.In this algorithm, the person simulates the habits of social spiders, and their work and cooperation efforts are divided based on gender differences.Simulation experiments were used to demonstrate the effectiveness of the proposed method [9].According to the background research in the present article, one of the new meta-heuristic algorithms was used to achieve the desired results.With the studies done so far, this algorithm has not been used to solve such a problem.The main purpose of this research is to optimize routing algorithms, reduce energy consumption to create a fair and uniform energy consumption between all nodes, and increase the network lifetime for wireless sensor networks using spider algorithm and reduce the error rate of the network.In the proposed work, to improve wireless sensor networks, the social spider algorithm is used, which uses a layer-based and clusterbased architecture to cover the entire area of the established nodes.With this approach, the number of iterations of cluster head selection is reduced, which increases the lifetime of the network.Data packets received from different nodes follow an acceptable path to transport packets to the destination with minimal use of available energy and fault tolerance.

Steps of the proposed system:
Figure 1 shows the steps of the proposed method: Using the social spider algorithm Design WSN with the help of NS Consider several node variables and the location of routers and gateways Apply the desired algorithm on the network Check the results

Comparison of proposed methods with previous methods
Figure 1: Flowchart of the proposed method

2.1.Details of the proposed method
The solution proposed in this research is to use the social spider algorithm to obtain the appropriate number of gate nodes and determine the location of these nodes in the best qualification.How the proposed method works are as follows: The center coordinates of each region are obtained, and the distance between the two nodes is calculated, and the average communication radius will be calculated.The amount of coverage is calculated for each node, and then the total distance of each point to the target points is obtained.It should also be noted that more coverage and the less total distance is better.Proportional to the value of the parameters of each node, a value is obtained for it.The nodes are sorted in descending order of magnitude.Half of the points that have more value are selected, and these parameters are stored.Then, using the desired algorithm, their location is also determined.The total number of points is specified, followed by the number of points to be selected.

2.2.Hypotheses of the proposed method according to the social spider algorithm 2.2.1. Apply social spider algorithm routines
Each position on the web represents an acceptable solution to the optimization problem, and all possible solutions to this problem have different positions on the web.The web also acts as a medium for transmitting the vibrations produced by spiders.Each spider has a position on the web.The quality (or fitness) of the solution is based on the objective function and indicates the possibility of producing a food source in the position.Spiders can move freely on the web.But, they cannot leave the web because web sites show inappropriate solutions to the optimization problem.When a spider moves to a new position, it creates a vibration that propagates through the web.Each pulse of information holds one spider, and other spiders can receive information when receiving a pulse.

Spiders on the WSN
Initially, a predefined number of spiders are placed on the web.Each spider has a memory that stores the following personal information, as described in the previous chapter: S position on the web.+ Fitness Current Position s. + Shake the target s in the last iteration.+ The number of repetitions that have been done recently and recently changed the target vibration.+ The movement that was performed in the previous iteration.+ Next move, which is used to guide the movement during the last iteration.According to observations, spiders have a clear sense of vibration.Besides, they can separate the various vibrations emitted by a web and feel the stresses associated with it.So with the help of this operation, more optimal positions can be created for the deployment of routers.In this algorithm, a spider vibrates when it makes a new position different from the previous one, so the same procedure can lead us to better results over time.The intensity of the vibration is related to the fit of the position.The vibration spreads on the web, and other spiders can sense it.In this way, the spider on the same web shares its personal information with others to achieve collective social knowledge.

The effect of vibrations on the WSN and finding the best positions
Pulse is an essential concept in SSA.This is one of the main features that distinguishes SSA from other meta-heuristic algorithms.In SSA, we use two properties to define a vibration, namely the position of the source and the intensity of the vibration source.The search space optimizes the position of the source, and we set the vibration intensity in the range [+1, 0].Each time a spider moves to a new position, it vibrates in its current position.We also consider the position of the spider at time t as Pa (t) or only as Pa if the time parameter is t.We use I (Pa, Pb, t) to indicate the intensity of the vibration used by a spider at position Pb at time t and the source of vibration at position Pa.Using these symbols, I (Ps, Ps, t) can be used to indicate the intensity of vibration produced by spiders at the source position.
Formula 1: I(Ps, Ps, t) = log ( 1 Where C is a constant, so all possible proportionality values are more significant than C.

Search pattern to find the best deployment on WSN
Because in SSA, there are three stages: initial, repetitive, and final, and these three phases are performed continuously.So in each run of SSA, we start with the initial phase, then repeat the steps, and the algorithm terminates, and the existing solutions are output.In the initial stage, the algorithm determines the objective function and its solution space.The value of the parameter used in SSA is also specified.After setting the values, the algorithm optimizes to create an initial population of spiders.As the total number of spiders remains unchanged during SSA simulation, a fixed-size memory is allocated to store information.The position of the spiders is randomly generated in the search space and its proportionality value is calculated and stored.Vibration The primary target of any spider in the population is at its current position and the vibration intensity is zero.All other parameters stored by each spider also start with zero.This phase initiates the initial phase and advances the iterative phase algorithm to search for spiders.In the iteration step, the algorithm performs a number of iterations.In each iteration, all the spiders on the web move to a new position and evaluate its values, so that they can find the best positions to deploy the routers, which in turn leads to the better routing on WSN.Each repetition can be divided into the following sections: physical assessment, vibration generation, movement change, and random gait.

Set algorithm parameters to apply in WSN
Choosing the right SSA parameters for numerical and real-world optimization problems can be time-consuming.In real-world optimization problems, the evaluation of the fit function may take longer than the assessment of the performance of our criteria, and evaluation may take a few seconds or even minutes, making it impossible to configure trial and error parameters.As an alternative, researchers have proposed some schemes to replace the trial and error parameter selection scheme.We perform extensive simulations on benchmark operations that cover a wide range of optimization problems.In SSA, we used three user-controlled parameters to guide search behavior: • Ra: This parameter reduces the amount of vibration when propagating in the network.
• Pc: This parameter controls the probability that the spiders will control their next change of motion during the random walking phase.• Pm: This parameter defines the probability of each value in one dimension.

Implementation tools
In this research, the MATLAB implementation language is used to implement the spider algorithm.Then the simulation of the network environment and the use of the desired algorithm are presented.Besides, the NS 2.35 tool is used to perform existing simulations.

3.1.Implementation outcomes
As mentioned before, the primary purpose of this research is to find a suitable place for routers using the social spider algorithm in the network.This was done by selecting and optimally placing the elements in the system and revising the objective function.To use it, the initial population size is 12, and the maximum number of loop iterations in the 100-iteration algorithm is considering, which we achieved with several runs and errors.To achieve the best results to solve the problem, they can be viewed as the default of the algorithm.To show the capabilities of the proposed method in the system, the results of the test performed are displayed in the form of a graph.

3.2.Compare with other available methods
In this study, three standard gate placement algorithms will be used for comparisons, including BRP, RDP, and RGP, because they are the most well-known methods defined to find the best place for gate placement.For this reason, it was preferred to compare its algorithm with these standard algorithms in this study to examine the proposed model.Two experiments were performed.In the first experiment, it was assumed: Nc = 200, Nr = 36, l = 1000m; for example, 200 customers are distributed in a square area of 1000m x 1000m; The square is evenly divided into 36 small square cells, and a sensor router is placed in the center of each cell.Simultaneously, the spine bandwidth is assumed to be 20 Mbps, and the local bandwidth is 10 Mbps.The second experiment is similar to the first, but Nc = 400, Nr = 64.The local traffic demand of each sensor router is randomly generated in all experiments.In each experiment, the gate placement problem is optimized with a maximum of one parameter: the total return of all customers is specified as Spider Sum.The minimum productivity of each customer is identified as Spider Min.The results are then compared with the results of the basic algorithm.First, the production efficiency and the worst process obtained from each algorithm are compared.As shown in    Figure 8-shows the displacement costs per gate.The results show that the proposed method has a low price because, for each gate, the highest operational capacity is obtained.A comparison of the results of the proposed method with the proposed algorithms indicates that it is essential that the proposed method has a better performance.As can be seen, the proposed method obtains the optimal answer in fewer repetitions than its similar techniques, which is also more desirable than the proposed methods.

CONCLUSION
In this paper, a new method for selecting and positioning routers based on the social spider algorithm is presented.After evaluation, the system performance was shown for the proposed algorithm in terms of network period and lifespan.The proposed method is often better than the other forms being compared.The results of simulation and implementation of this method and comparing it with the results of previous researches with the same goals showed that this method has a high capability and has good flexibility in different conditions; at the same time, it will not increase costs and damages in the system; therefore, it will be an effective and economical method.The evaluation results show that this method is acceptable compared to the techniques presented before this study.While creating the desired capabilities in terms of security does not impose much time overhead on the system.Since the purpose of using the spider optimization algorithm in this research, the following specified goals were set: • Lowest energy consumption to choose the best.
• Increase fault tolerance • Fair and uniform energy consumption between all nodes.
• Increase network life.
• Routing optimization in wireless sensor networks.According to the results of the experiments, the accuracy of the above can be proved because the proposed method can have the lowest energy consumption.It can lead to fair and uniform energy consumption between all nodes.It will also increase the lifetime of the network.Optimization of routing algorithms for such networks by using the spider algorithm also reduced the number of errors (failures) in the system and increased the life of the network with the help of the mentioned method.
In this paper, a new evolutionary algorithm derived from the social behavior of spiders for the optimal global search for constrained optimization functions is discussed.The purpose of improving this algorithm is to increase the convergence speed while maintaining good accuracy in achieving the optimal solution.The results of the proposed method on the test functions show that the accuracy of the algorithm in achieving the best answer in each test function along with reducing the evaluation of the optimization function (faster convergence) compared to the spider community method has been achieved.Also, it has achieved an average of more than fifty percent improvement.

Suggestions for the future works
As a suggestion for future work and research, the following can be mentioned: Using more criteria alongside other optimization algorithms; Due to the passage of time and the advancement of technology, the tools used by society are continually changing.Besides, along with that, the interests and needs of the people change, so the results obtained in this research cannot be satisfied until years later.Therefore, to achieve the most optimal result at any time, it is better to pay attention to the changes and fluctuations that occur in the world of technology.Also, the experiments can be performed in a more extensive and more realistic range than the experiments of this research, because here it is enough to examine the proposed model on a hypothetical network.
Figure (2) to Figure (5), it is clear that the results of our algorithm are better than the results of the basic algorithm in all experiments.

Figure 2 :Figure 4 :
Figure 2: Comparing the total performance of the worst-case scenario of each customer (Mbps Vs. number of gates)

Figure 6 :Figure 7 :
Figure 6: Comparison of the total performance of each gate in the first test (Mbps Vs. number of gates)

Figure 8 :
Figure 8: Comparison of the total performance of each gate (Mbps Vs. number of gates)