# Whale Optimization Algorithm

Whale Optimization Algorithm (WOA) is a recently proposed (2016) optimization algorithm mimicking the hunting mechanism of humpback whales in nature.

## Inspiration

Whales are fancy creatures. They are considered as the biggest mammals in the world. An adult whale can grow up to 30 meters long and 180 tons weight. There are seven different main species of this giant mammal such as Killer, Minke, Sei, Humpback, Right, Finback, and Blue whales. Whales are mostly considered as predators. They never sleep because they have to breathe from the surface of oceans. In fact, half of the brain only sleeps. The interesting thing about the whales is that they are considered as highly intelligent animals with emotion.
According to Hof and Van Der Gucht, whales have common cells in certain areas of their brains similar to those of human called spindle cells. These cells are responsible for judgment, emotions, and social behaviors in humans. In other words the spindle cells make us distinct from other creatures. Whales have twice number of these cells than an adult human which is the main cause of their smartness. It has been proven that whale can think, learn, judge, communicate, and become even emotional as a human does, but obviously with a much lower level of smartness. It has been observed that whales (mostly killer whales) are able to develop their own dialect as well.
Another interesting point is the social behavior of whales. They live alone or in groups. However, they are mostly observed in groups. Some of their species (killer whales for instance) can live in a family over their entire life period. One of the biggest baleen whales is humpback whales (Megaptera novaeangliae). An adult humpback whale is almost as size of a school bus. Their favorite prey are krill and small fish herds.
The most interesting thing about the humpback whales is their special hunting method. This foraging behavior is called bubble-net feeding method. Humpback whales prefer to hunt school of krill or small fishes close to the surface. It has been observed that this foraging is done by creating distinctive bubbles along a circle or ‘9’-shaped path. Before 2011, this behavior was only investigated based on the observation from surface. However, Goldbogen et al. investigated this behavior utilizing tag sensors. They captured 300 tag-derived bubble-net feeding events of 9 individual humpback whales. They found two maneuvers associated with bubble and named them ‘upward-spirals’ and ‘double-loops’. In the former maneuver, humpback whales dive around 12 meters down and then start to create bubble in a spiral shape around the prey and swim up toward the surface. The later maneuver includes three different stages: coral loop, lobtail, and capture loop. Detailed information about these behavior can be found in .
It is worth mentioning here that bubble-net feeding is a unique behavior that can only be observed in humpback whales. In this work the spiral bubble-net feeding maneuver is mathematically modeled in order to perform optimization.

## Mathematical model and optimization algorithm
### Encircling prey

Humpback whales can recognize the location of prey and encircle them. Since the position of the optimum design in the search space is not known a priori, the WOA algorithm assumes that the current best candidate solution is the target prey or is close to the optimum. After the best search agent is defined, the other search agents will hence try to update their positions towards the best search agent. This behaviour is represented by the following equations:
${\vec {D}}=|{\vec {C}}.{\vec {X_{p}}}(t)-{\vec {X}}(t)|$
${\vec {X}}(t+1)={\vec {X_{p}}}(t)-{\vec {A}}.{\vec {D}}$ (1)
where $t$ indicates the current iteration, ${\vec {A}}$ and ${\vec {C}}$ are coefficient vectors , ${\vec {X_{p}}}$ is the position vector of the prey, and ${\vec {X}}$ indicates the position vector of a whale.
The vectors ${\vec {A}}$ and ${\vec {C}}$ are calculated as follows:
${\vec {A}}=2{\vec {a}}.{\vec {r_{1}}}-{\vec {a}}$
${\vec {C}}=2.{\vec {r_{2}}}$
Where components of ${\vec {a}}$ are linearly decreased from 2 to 0 over the course of iterations and $r_{1}$, $r_{2}$ are random vectors in [0,1].

### Bubble-net attacking method (exploitation phase)

In order to mathematically model the bubble-net behavior of humpback whales, two approaches are designed as follows:
1- Shrinking encircling mechanism: This behavior is achieved by decreasing the value of ${\vec {a}}$. Note that the fluctuation range of ${\vec {A}}$ is also decreased by ${\vec {a}}$. In other words, ${\vec {A}}$ is a random value in the interval [-a,a] where a is decreased from 2 to 0 over the course of iterations. Setting random values for ${\vec {A}}$ in [-1,1], the new position of a search agent can be defined anywhere in between the original position of the agent and the position of the current best agent.
2- Spiral updating position: This approach first calculates the distance between the whale located at (X,Y) and prey located at (X*,Y*). A spiral equation is then created between the position of whale and prey to mimic the helix-shaped movement of humpback whales as follows:
${\vec {X}}(t+1)={\vec {D^{'}}}e^{bt}cos(2\pi t)+{\vec {X^{*}}}(t)$ (2)
where ${\vec {D^{'}}}=|{\vec {X^{*}}}(t)-{\vec {X}}(t)|$ and indicates the distance of the i-th whale the prey (best solution obtained so far), b is a constant for defining the shape of the logarithmic spiral, and t is a random number in [-1,1].
Note that humpback whales swim around the prey within a shrinking circle and along a spiral-shaped path simultaneously. To model this simultaneous behaviour, we assume that there is a probability of 50% to choose between either the shrinking encircling mechanism or the spiral model to update the position of whales during optimization. The mathematical model is as follows:
${\vec {X}}(t+1)=\left\{{\begin{matrix}{\vec {X^{*}}}(t)-{\vec {A}}{\vec {D}}&p<0.5\\{\vec {D^{'}}}e^{bt}cos(2\pi t)+{\vec {X^{*}}}(t)&p\geq 0.5\end{matrix}}\right.$
where p is a random number in [0,1].
In addition to the bubble-net method, the humpback whales search for prey randomly. The mathematical model of the search is as follows:

### Search for prey (exploration phase)

The same approach based on the variation of the ${\vec {A}}$ vector can be utilized to search for prey (exploration). In fact, humpback whales search randomly according to the position of each other. Therefore, we use ${\vec {A}}$with the random values greater than 1 or less than -1 to force search agent to move far away from a reference whale. In contrast to the exploitation phase, we update the position of a search agent in the exploration phase according to a randomly chosen search agent instead of the best search agent. This mechanism and |A ⃗|>1 emphasize exploration and allow the WOA algorithm to perform a global search. The mathematical model is as follows:
${\vec {D}}=|{\vec {C}}{\vec {X_{rand}}}-{\vec {X}}|$
${\vec {X}}(t+1)={\vec {X_{rand}}}-{\vec {A}}{\vec {D}}$ (3)
where ${\vec {X_{rand}}}$ is a random position vector (a random whale).

## The WOA algorithm

The WOA algorithm starts with a set of random solutions. At each iteration, search agents update their positions with respect to either a randomly chosen search agent or the best solution obtained so far. The a parameter is decreased from 2 to 0 in order to provide exploration and exploitation, respectively. A random search agent is chosen when $|{\vec {A}}|>1$, while the best solution is selected when $|{\vec {A}}|<1$ for updating the position of the search agents. Finally, the WOA algorithm is terminated by the satisfaction of a termination criterion.
The pseudo code of the WOA algorithm is presented below:

## Application

Economic Dispatch Problem
Global MPP Tracking of Photovoltaic System
Skeletal structures
Workflow planning of construction sites
Breast Cancer Diagnosis
Arabic Handwritten Characters
Unit Commitment Problem Solution
Multi-Objective Optimal Vehicle Fuel Consumption
Multi-objective optimal mobile robot path planning
Optimal siting of capacitors in radial distribution network
Multilevel Thresholding Image Segmentation
Optimal power flow problem
Neural Network training
Historic handwritten manuscript binarisation
Combined Emission Constrained Economic Dispatch with Valve Point Effect Loading Problem
Emission constraint environment dispatch problem
Feature Selection
Liver segmentation in MRI images
Multi-Objective Virtual Machine Scheduling in Cloud Computing Environment