# THE PROPOSED SS-KH ALGORITHM

The presented SS-KH algorithm takes place in two stages, namely TCH using SS algorithm and FCH using KH algorithm. The SS-KH algorithm operates in four main stages, namely initialization, TCH using SS algorithm, FCH using KH algorithm, and cluster construction. Once the sensor nodes undergo deployment, initialization phase will be executed. At this stage, the nodes gather information about their neighboring nodes and distance to BS. Later, the SS algorithm utilizes the nature of social spiders to select the TCH. Then, the TCH undergoes selection of FCH and its respective CHs using the KH algorithm. Finally, the chosen FCHs form the clusters in the network. The pseudo code of the SS-KH algorithm is shown in Algorithm 8.1 and the entire process is demonstrated in Figure 8.3.

## SS-Based TCH Selection

The SS optimization algorithm is based on behavior of SS and it is employed for electing the TCHs. The sub-processes involved in this mechanism are given below.

8.4.1.1 Representation of Individual Spiders

An essential process lies in the consideration that the SS algorithm is the way of representing the spiders. A group of к cluster center point is indicated by each set defined by each spider that is the most favorable solutions to unequal clustering issue. For instance, let x = {(10.5; 20.4), (15.2; 25.0)} is a spider containing m = 2 cluster centers and has {(10.5; 20.4) and (15.2; 25.0)}, each center has a dimension of n = 2. Each spider in initial population is generated through the consideration of к arbitrary points of the dataset provided where m indicates the cluster count.

8.4.1.2 Distance between Two Spiders

Since the spider undergoes shaping by the collection of cluster centers, it is needed to define the distance between two spiders and not by point set. Therefore, the distance between a pair of spiders is represented as the sum of Euclidean distance between its cluster centers. The spiders with minimal distance hold smaller cluster size. For instance, assume « = {( xdayx)^ X2^y2))andb = ^ xl>^yl)> (ЬХ2>Ьу2 4} are the pair of spiders that has m = 2 clusters centers, with each center comprising a set of two dimensions. Next, the distance between the pair of spiders is represented by: Consider d{^axl;ayl )>(bxi'>byl)) is the Euclidean distance between the centers d((axl;ayi) and (bxl

8.4.1.3 Fitness and Weight of a Spider

The fitness function of each spider is determined by the use of a metric M, a pointer to indicate optimal solutions which can be generated. The main objective of SS algorithm is the reduction of the population fitness. Therefore, in the population, the spider that has less fitness is the best one that can be selected as TCH in the cluster. The spider i is defined as the weight and fitness which has negative correlation, and it is determined as follows:  FIGURE 8.3 Overall process of proposed method. where j(s,) is the fitness rate of the spider. When the TCHs are selected, they will execute the KH algorithm for the selection of FCH which is discussed in the subsequent section.

## KH-Based FCH Algorithm

KH algorithm is based on the herding behavior of krills. It is based on the krill individual’s results. The group of krills hunts for foodstuff and communes with swarm members of the technique. A set of three motions in which the location of a krill has been presented:

• • Endeavor persuaded by other krills
• • Foraging act
• • Physical diffusion

KH considered the Lagrangian model as given in equation (8.5). where N) indicates the movement of other krills, F, is the searching movement, and Di is the physical distribution.

In the initial movement, a target, local and repulsive outcome computes the direction of movement, a,. For krill i, equation (8.6) is defined by: where Nmax indicates the utmost tempted speed, con and u indicates the inertia weights and last motion respectively.

In the subsequent movement, the position of food is identified and earlier experience. At every ith krill, it could be represented as follows: where vy, C0y , and F)oM indicate the seeking speed, inertia, and final movement respectively, fif00>> indicates the attractiveness of food, and indicates the consequence of optimal fitness of the ith krill.

In the final movement, an arbitrary procedure takes place in two ways, namely maximum diffusion speed and an arbitrary directional vector. Equation (8.9) is specified to: where Dmax and 6 indicate the random vector. Using the set of three motions, the location of the krill at time t to t + At is indicated as follows: The value of At is attained as follows: where N V represents the variable count, LBj and UBj are likewise the lower and upper bounds of the jth variables, Ct indicates a constant value of 0.5. The motion of the typical KH is influenced by other krills; for a preset number of generations or until termination condition is satisfied, foraging as well as physical diffusion prolongs to carry out. The transmission generally takes place in two ways, namely intracluster and intercluster communication. The data transmission takes place in a straight way or through intermittent CHs. The way of improving the data transmission within the cluster and the selection of proper CHs from every node in every iteration are the aim of clustering. The data from diverse CMs undergo aggregation at the CH and transmit the data to the BS. It got reduced in the quantity of the energy utilized in this method. At every iteration, every CH has to be allocated. A decision is made by the selection of appropriate node by the KH. An efficient CH in specific round is chosen based on the energy owned by node and distance from CHs member nodes that are not CH. At the setup stage, the sensors will relay the information related to the position and remaining energy level to the BS. The BS determines the average energy depending upon the data. At every iteration, the CH is chosen depending upon the maximum average energy in the specific iteration. Hence, a competitive node is chosen as the CH for that round. The BS undergoes the implementation of the algorithm to determine К number of proper CHs. It minimizes the cost function , as in equations (8.12)-(8.14): where /, indicates the highest average Euclidean distance of nodes to their relevant CHs and Cpk indicates the node count fit to cluster Ck of krills. The function f2 is represented as the ratio of sum of initialization energy of every node, nt = 1,2,.,N, in the network with the totalized present energy of the CHs candidates in the present round. f5 is a predefined constant utilized for weighing the involvement of every subobjective. The intention of the fitness function is the minimization of intra-cluster distance among the nodes and CHs. It undergoes quantification by fv The quantification of energy efficiency takes place using /2. Using the representation of cost function, lower values of fx and f2 indicate that the cluster is optimum and has optimal node count. It also has the requirement of energy to perform the processes associated with the CH.

Step 1: Assume a collection of I krills which holds a set of К arbitrarily elected CHs among the appropriate CH candidates.

Step 2: Determine the cost function of every individual krill:

i. For every node nt, = 1,2,.,N

• • Determine the distance d(njyCHpk) among the nodes nt and every CHpk.
• • Allocate the nodes tt, to CHpk where: ii. Compute the cost function by the use of equations (8.12)—(8.14)

Step 3: Determine the optimal value of every krill and identify the optimal position of the krills.

Step 4: Update the location of each krill in the search area by the use of following equations (8.16) and (8.17). Step 5: Repeat steps 2-4 until the maximum number of rounds is obtained. The BS communicates the data containing the id of the CHs as well as CMs.

SS-KH FOR UNEQUAL CLUSTERING INPUT:

Total Nodes (NodesN), Total Number of Clusters (CN), f()

Initialize Population Size (PopN), Maximum number of Iterations (Maxn), Number of Female Spiders (SpiderF), and Number of Male Spiders (SpiderM), Number of Krills (KHN), Repulsive Effect (coN)

Initialize the iteration t <-1 //Population Initialization V/ e PopN do end for

//Fitness Calculation V/ e PopN do end for repeat

//Calculation of Mating Radius V/ e PopN do end for

//Calculation of weights of Each Spider V/ e PopN do end for

//Calculation of Vibration of Female Spiders V/ e Spiderf do end for

V/ g SpiderM do end for

//Impact of Krill-Herd V/ g KHN do end for

//Mating Process // Cluster head Selection V/ g PopN do V/ g CN do

CH, Choose a CH with Highest Residual Energy from Pop,; | / g Cn

end for end for

//Fitness Calculation until (termination condition satisfied)

OUTPUT: min(f(Pop))