# Energy Efficient Routing Protocol in Sensor Networks Using Genetic Algorithm
## 4 Methodology  
In Figure 1, WSN is shown where sensor nodes are connected wirelessly. Nodes may move randomly and this, in turn, would lead to channel breakage and topology change. Accordingly, another route should be discovered. We propose an algorithm that can provide an alternative efficient route if the primary one is disconnected. Here, we explain the mechanism of our proposed GA-AOMDV method. This protocol generates a scores matrix representing a set of optimum routes between the source and the destination. AOMDV produces an array of alternative routes based on the minimum number of nodes. GA algorithm is applied on these routes devoted by AOMDV to generate more routes where the consumed energy at nodes is minimal. In our algorithm, we assume all nodes have the same initial energy. GA has six steps explained below:  
* Initialization: In this step, we set our assumptions for the needed parameters: Genes: This is the number of sensor nodes in a path before any data communication takes place, PopSize: This is the population size which is a set of all available routes between two end nodes, P\({}_{\text{c}}\): This is the probability where a couple of routes may be crossed over, P\({}_{\text{m}}\): This is the probability where a node in one route may be mutated, SurvivorSel: This is the survivor selection rule where a route can be considered as an accepted alternative based on its fitness score, GensNochange: This is the termination of the route search process where the array of available routes is sorted descendingly using the fitness values. At this stage, the optimized array has no further change. * Fitness: We apply this function twice. Firstly, all routes returned by AOMDV are evaluated through the fitness function in Equation (1). Secondly, other routes generated through crossover and mutation phases are examined through this function to assess its efficiency as potential accepted route. * Selection: Using the FF values, some of the AOMDV generated routes will be excluded to save the processing time needed for the next crossover and mutation. In doing this, the elitism method [32] is used where routes with small fitness scores will be removed from the selected routes pool. In other words, a route where its nodes have low energy will be excluded from the population of the parent routes where the crossover and mutation phases are applied. Therefore, the population will only represent elites which are the available routes with the minimum number of nodes and highest residual energy. * Crossover: In this step, every couple of routes are paired and crossed over using the probability P\({}_{\text{c}}\). Nodes are switched between each pair of routes with high fitness scores. The range of P\({}_{\text{c}}\) is between 0.45 and 1 [32]. P\({}_{\text{c}}\) is selected to be 0.5 in our simulation as it was indicated in [33] that it works perfectly with a large population size. * Mutation: This phase is applied on the routes generated by AOMDV and crossover. In this step, the node order is altered in the same route using the probability P\({}_{\text{m}}\). The range of P\({}_{\text{m}}\) is between 0.001 and 0.5 [33]. In our simulation, P\({}_{\text{m}}\) is selected to be 0.1 as it is commonly used by researchers [33]. New routes generated by crossover and mutation are assessed in the survivor select phase. * Survivor selection: Each route generated by crossover and mutation phases is considered as a new child. If the fitness of the child is greater than the scores of its parents, then this child route will be added to the array of potential efficient routes; otherwise,  
Figure 1: Wireless sensor network. this child route will be dropped. Optimized routes array is accordingly sorted and the route selected is the one with the highest fitness level. Other routes are alternatives that will be likely used whenever the selected route's nodes become faulty or move out of the network area. Figure 2 shows the steps that our routing protocol goes through to generate and select routes for data packets forwarding.