Modified LEACH Protocol with GWO Optimization in WSN


This MATLAB code improves the LEACH protocol for energy consumption minimization in WSN. We have used GWO optimization algorithm for this purpose. The new cluster head is elected with minimum intracluster distance, minimum energy consumption and the maximum number of nodes under its influence.

This repository contains :

  • MATLAB code for modified LEACH with GWO optimization
 Discuss Code


A wireless sensor network (WSN) is used to monitor physical or environmental conditions. It consists of several numbers of sensors nodes that monitor the temperature, humidity, and light parameters. The received information is passed through the WSN to the base station. In WSN all the sensor nodes are powered by the battery which consumes high energy for the data transmission. This energy consumption can be reduced by using hierarchical approaches. We selected LEACH (Low-energy adaptive clustering hierarchy) scheme for the minimization of energy consumption.

Thesis Statement

LEACH[1] improves energy efficiency and increases the lifetime of the network. The clusters are formed in the LEACH scheme in which distributed sensor nodes are placed in a group. The sensor node has maximum residual energy selected as the cluster head (CH). All the cluster nodes transmit data to CH, and then CH is forwarding through the other CHs or directly to the base station. The cluster head selection procedure is not optimal in the LEACH scheme. So we proposed GWO optimization algorithm for the optimal selection of CH in LEACH protocol.


LEACH is a MAC protocol implemented with clustering and simple routing protocol in WSN. The key function of LEACH is to minimize the energy consumption necessary to form clusters to increase the lifetime of WSN. Most of the sensor nodes transmit to the cluster head in LEACH protocol. The cluster head compresses the received sensor nodes’ data and forwarded it to the sink node (Base Station). The remaining nodes of the clusters communicate with the cluster head in TDMA (Time Division Multiplexing Access) manner as per CH generated scheduled [1].

The working of LEACH is divided into two phases. The first phase is the setup phase in which clusters are formed in WSN. The second phase is known as steady phase in which information or data is transferred to sink. The cluster head selection phase and clustering phase are the key parts of the LEACH protocol. Each sensor node is having threshold energy as per the formulation

In equation 1, p is cluster head percentage in all nodes, r is the round and G is set of non selected cluster head nodes.

The energy model is followed by LEACH protocol with the two-channel model; free space (d2) for single hope path and multipath fading (d4) for the multihop path. So the energy consumption of l bit packets over distance d is estimated as

Where efs = free space energy loss, emp = multipath fading loss, d= distance between source and destination node, d0= crossover distance =square root of (efs/emp). The energy variable depends on the node distance, so via optimizing node distance, we can minimize the energy consumption at every sensor node in WSN.

GWO optimized LEACH

An objective function is necessary for the optimization algorithm. It must satisfy the condition and constraints of the design network. As per equation 2 the energy depends on the distance of sensor nodes, so objective function shows the relationship between energy and distance variable. Equation 3 shows the fitness function of the LEACH protocol

Here a1 and a2 are the tradeoff factors, and their fixed value is considered as 0.4. The objective function shows the energy consumption with respect to the node distance.

We proposed a GWO optimization algorithm to minimize the LEACH protocol objective function as written in equation 3. The GWO is a Metaheuristic optimization algorithm developed in 2010..

A GWO optimized STATCOM TWO KUNDUR AREA SYSTEM  MATLAB code is available at

We developed a MATLAB script of GWO algorithm to optimize the above mention objective function. GWO is inspired by the food searching behavior of grey wolves. The wolves are attacks in a group and best position of any wolf can provided best solution. We call the objective function in GWO script and get the optimal or best solution in terms of consumption energy of sensor nodes. The position of the grey wolves updated the position of the cluster head of LEACH protocol.

The objective function written in equation 3 is minimized by the GWO algorithm. The position of wolves allocates the position of cluster head in each cluster. The position of wolves has updated the position of cluster heads are also changed.

GWO optimized LEACH

Figure 1 Architecture of GWO optimized LEACH module



  • We create a geographical area of 100*100 in the MATLAB 2018a. The sensor nodes are randomly placed in that area.
  • Initialize the parameters of LEACH protocol like Initial Energy, Number of Nodes, rounds in LEACH, energy for transferring/receiving of each bit, transmit amplifier free space/multipath energy, aggregation energy, and the packet length. Consider 5% of the total nodes as the clusters. So, among 100 nodes 5 cluster are formed using LEACH protocol.
  • Initialized the random position of the grey wolfs in GWO algorithm with limits equal to cluster head formation. Among the 100 nodes 5 cluster heads are selected.
  • Optimized the objective function value which is given in equation 2 and computed the best fit solution in terms of residual energy. Calculate the objective function value for each wolves in each iteration and saved the output.
  • Update the best position of wolves as per the GWO algorithm and estimate the best fitness value of objective function in next iteration.
  • All the process is repeated until the final iteration finished. We obtained the minimum value of the objective function in terms of energy and distance.
  • So the efficient LEACH protocol is achieved by GWO algorithm. The residual energy is reduced in LEACH protocol via optimal selection of cluster head.

Figure 2 WSN network generated for 100 nodes placed randomly


In this work we minimize the energy consumption of sensors in Wireless Sensor Network (WSN). The configuration of WSN environment is done as per the LEACH (Low-energy adaptive clustering hierarchy) protocol due to efficient energy and network lifetime. In LEACH protocol the distributed sensor nodes are placed in a group or cluster. A sensor node of cluster is selected as the cluster head which has maximum residual energy. The cluster head selection is not efficient or optimal in LEACH, so we used a Meta heuristic algorithm called Grey Wolf Optimization (GWO) to select cluster head. The energy consumption of sensor node is minimized by GWO optimized LEACH environment.



  1. Jiang, Shuyu. “LEACH Protocol Analysis and Optimization of Wireless Sensor Networks Based on PSO and AC.” In 2018 10th International Conference on Intelligent Human-Machine Systems and Cybernetics (IHMSC), vol. 2, pp. 246-250. IEEE, 2018.
  2. Beiranvand, Zahra, Ahmad Patooghy, and Mahdi Fazeli. “I-LEACH: An efficient routing algorithm to improve performance & to reduce energy consumption in Wireless Sensor Networks.” In The 5th Conference on Information and Knowledge Technology, pp. 13-18. IEEE, 2013.
  3. Mann, Palvinder Singh, and Satvir Singh. “Improved artificial bee colony metaheuristic for energy-efficient clustering in wireless sensor networks.” Artificial Intelligence Review51, no. 3 (2019): 329-354.
  4. Hatta, N.M & Zain, Azlan & Sallehuddin, Roselina & Abd. Rahim, Shayfull Zamree & Yusoff, Yusliza. (2018). Recent studies on optimisation method of Grey Wolf Optimiser (GWO): a review (2014–2017). Artificial Intelligence Review. 10.1007/s10462-018-9634-.


There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.