*4.5. Onlooker Bees*

In the onlooker bee phase, the onlooker bee will select good food sources for further search based on the information conveyed by the employed bee, with the aim of obtaining high-quality solutions and accelerating the convergence of the algorithm. In this paper, a sorting-based selection strategy is proposed to improve the search efficiency of the onlooker bee and speed up the convergence of the algorithm. First, the individuals in population are ranked according to (21), and those with small values are in the front. The high-quality solutions are placed in front of the bad solutions. Then, the onlooker bee selects an individual in population to follow according to (24), in which (24), *i* represents the *i*-th individual to follow and *N* denotes the population size. Therefore, the individual with the top ranking has a higher probability of being selected.

$$index\_i = rand\left(\frac{N+i}{2}\right) \tag{23}$$

After selecting the individual *Xindex* according to the selection method proposed in this paper, the onlooker bees randomly select the neighboring individual *Ti* of the current individual for two-point crossover [41] to generate a new individual. The two-point crossover is divided into two parts: the sequence of operations and the velocity matrix, and the specific operation is as follows: two points in the range are randomly selected, the part between two points in *Xindex* is left untouched, and the rest is filled by *Ti*. For the job sequence, the remaining positions in *Xindex* are filled by the jobs in *Ti* that are different from the remaining jobs in *Xindex* in turn. For the velocity matrix the remaining positions in *Xindex* are filled by the corresponding positions in *Ti*.

Regarding the newly generated individuals, the algorithm will decide whether to replace the original individuals according to the greedy selection algorithm. In particular, in order to prevent the algorithm from falling into local optimum, this paper introduces mutation in the onlooker bee phase, and the probability of mutation of individuals in the population is 1/N. This avoids the algorithm from falling into local optimum to some extent. The whole onlooker bee detailed process is shown in Algorithm 4.

```
Algorithm 3 Employed bee phaseInput: population P;
Output: new population, P
                                  '
                                   ;
1: P
    '
      = P;
2: for i = 1 to N do
3: si = Quality(Xi);
4: end for
5: Sort(P
          '
           , s);
6: for i = 1 to N do
7: li = Level(Xi);
8: X
         '
         i = GetNew(Xi,qi);
9: for z = 0 to li do
10: if z = 0 then
11: if X
               '
               i < Xi then
12: Xi = X
                     '
                     i;
13: qi = 1;
14: else
15: qi = qi + 1;
16: end if
17: if qi > 5 then
18: qi= 1;
19: end if
20: else
21: Xb=GetBad(Xi);
22: if X
                '
                i < Xb then
23: Xb = X
                     '
                      i;
24: break;
25: else
26: qb = qb + 1;
27: end if
28: end if
29: end for
30: end for
31:return P*.
```
In Algorithm 4, *Select*() indicates that the onlooker bee selects a food source to follow according to (23), *GetNeighbourhood*() indicates a random selection from the neighbors of the food source, TPX() indicates the two-point crossover, and *Mutation*() represents mutation of an individual **X**, including the job sequence and speed selection matrix.
