Skip to main content
. 2022 Sep 20;22(19):7113. doi: 10.3390/s22197113
Algorithm 2: Pseudo-code for the proposed approach
Step1: Initialize the population of gray wolves Gi (i = 1, 2, …, n)
Step2: Initialize a, A, C
Step3: Calculate the fitness of each agent in search space
Step4: Galpha = fittest wolf
Step5: Gbeta = second best wolf
Step6: Gdelta = third best gray wolf
Step7: Repeat while itr < Round, then do
Step7.1: for each gray_wolf do
Step7.2: for each ith sensor in each best search agent gray wolf do
Step7.2.1: Find ith maximum loaded CH Max and minimum loaded CH Min in Alpha, Beta and Delta.
Step7.2.2: Perform load-balanced clustering for all the best search agents alpha, beta and Delta, respectively.
Step7.2.3: If A < 1
    [Search into Initial Solution Space i.e., Exploitation]
    [//Call Exploitation();]
    //Update Galpha
    Step7.2.3.1: Set G_Load1 = Gbeta[i]
    Step7.2.3.2: Set G_Load2 = Gdelta[i].
         If G_Load1< Galpha[i] && G_Load1 < G_Load2
           Galpha[i] = G_Load1
         Else if G_Load2 < Galpha[i]
           Galpha[i] = G_Load2
         [End]
    Step7.2.3.3: Set G_Load1 = Gbeta[i].
    // Update Gbeta
    Step7.2.3.4: Set G_Load2 = Gdelta[i].
         If G_Load1 > G_Load2
           Gbeta[i] = G_Load2
         Else
           Gbeta[i] = G_Load1
         [End]
     //Similarly update delta
Step7.2.4: Else diverge or perform exploration
    //Look in to global space
    //Call Exploration();
    Step7.2.4.1: Initialize G from the global search space.
    //Update Galpha
    Step7.2.4.2: Set G_Load1 = Galpha[i].
           If G_Load1 > G
                Galpha[i] = G
           Else
                [No change]
           [End]
    //Update Gbeta
    Step7.2.4.3: Set G_Load2 = Gbeta[i].
           If G_Load1 > G
                Gbeta[i] = G
           Else
                [No change]
           [End]
    //Similarly update delta
[End of if in Step7.2.3][End for loop]
Step7.3: Update a, A, C
Step7.4: Calculate the fitness of each gray wolf
Step7.5: Update Galpha, Gbeta, Gdelta
Step7.6: Increment itr
[End while loop]
Step8: Return best gray wolf Galpha