*2.4. The Whale Optimization Algorithm*

The hunting behavior of humpback whales is the source of inspiration for the Whale Optimization Algorithm (WOA). The whales hunt in groups, and when they find their prey, consisting of schools of krill or small fish near the water surface, they attack it from below using two maneuvers: encircling and spiraling.

The WOA uses a population of vector solutions ('whales'), which are hunting for prey independently, guiding their search by following a reference individual, usually their leader, i.e., the whale closest to the problem solution ('food'), according to its fitness function.

During the algorithm, whales use initially encircling, then spiral attack, in the same way PSO and BOA use the broad exploration and the exploitation of the search space near the optimal solution.

In each iteration *it*, the encircling performed by each whale *j* from the population is described by [42]:

$$x\_{\uparrow}^{(it+1)} = r \varepsilon \underline{f} \underline{r} \underline{r} \underline{\text{nuc}} e^{(it)} - A \cdot D\_1 \tag{10}$$

where

$$A = 2 \cdot a \cdot md\_1 - a \tag{11}$$

$$D\_1 = \left| \mathbf{C} \cdot \textit{reference}^{(it)} - \mathbf{x}^{(it)} \right|, \quad \mathbf{C} = \mathbf{2} \cdot \textit{r} \textit{nd}\_2 \tag{12}$$

The coefficient *a* from equation (11) is a scalar value decreasing during the iterative from a positive value to 0. The (·) sign denotes the element-by-element multiplying of vectors, and | |, an absolute value.

For the extreme values of *a* = 0 and *a* = 1, equations (10) to (12) show that position *xj (it*+*1)* will always lie between *xj (it)* and *reference(it)*, thus moving any whale towards the reference solution used to guide the population. If values larger than 1 are given to *a*, factor *A* from (11) will also increase, moving the wales beyond the target and exploring a possibly uncharted portion of the search space.

If the reference position is *reference(it)* = *leader(it)*, the leader from the current iteration, when *A* decreases, whales get closer to the leader, encircling the prey or the optimal solution. If another whale is used as reference, *reference(it)* = random(*x(it))*, the search will shift towards its path, simulating the exploration of the sea in search for food performed by real whales.

The spiral attack phase is described by an equation that combines oscillatory and exponentially variating components:

$$\mathbf{x}\_{j}^{(it+1)} = D\_2 \cdot e^{b \cdot l} \cdot \cos(2 \cdot \pi \cdot l) + lade r^{(it)} \tag{13}$$

with

$$D\_2 = \left|leader^{(it)} - x\_j^{(it)}\right|\tag{14}$$

In equation (13), *b* is a constant, and *l* is a random value from the [–1, 1] interval [42].

The initially large, then gradually decreasing values of *a*, so that first |*A*| > 1, then |*A*| < 1, |*A*| → 0, first move the whales away from the leader in exploration, then encourage encircling, followed by spiral attack. If *p* denotes a random number, the general equation for changing the position of a whale follows as:

$$x\_{j}^{(it+1)} = \begin{cases} \frac{reference^{(it)} - A \cdot D\_{1\prime}}{D\_2 \cdot e^{lb} \cdot \cos(2 \cdot \pi \cdot l) + leader^{(it)}} & \text{if} \quad p < 0.5 \end{cases} \tag{15}$$

The flowchart of a WOA iteration is presented in Figure 6.

**Figure 6.** The flowchart of a WOA iteration.

WOA has two specific parameters that can be tuned for better performance: coefficient *a* from Equation (11) and constant *b* from (13).
