Performance of the Whale Optimization Algorithm in OneMax Problem 🐳

I wish everyone full days plenty of optimization again 🛎️
I have published before the performance of the PSO algorithm against the One Max problem after my article, I came across an optimization algorithm that is more interesting to me. We may not know which optimization algorithm will do well in a problem. Because each problem contains its own unique differences, different optimization algorithms also cause differences in the results with the methods it contains. I was just as curious as you are, and to find out the result, I first investigated why our whales were sampled for solving an optimization problem and compiled it for you. Let’s start learning together 🏋

📢 The Whale Optimization Algorithm (WOA) is one of the meta-heuristic algorithms that is entirely inspired by the hunting strategy of humpback whales. Humpback whales have their own unique hunting strategies that allow them to breathe under water, forming bubbles and thus get close to their prey. Of course, being hungry in nature is not a situation that any living thing would want. Unlike other whale species, these humpback whales have developed a systematic hunting technique, succeeding in instinctively neutralizing their prey. The WOA is modeled in 3 parts as wrapping around prey, moving towards prey, and searching for prey 🐋.

If you want to approach these humpback whales in a little more detail first, come on 👩🏼‍🏫

[gdlr_core_space height=”30px”]

Humpback Whales

Humpback whales hunt fish that roam in herds with their unique hunting technique. They consume fish and crabs that enter their mouths along with the large amount of water they take into their mouths to filter out nutrients. Humpback whales although large are considered quite acrobatic. After throwing their bodies over the surface of the water, they slap the water and throw themselves back into the water. Humpback whales, which can reach a weight of 48 tons and 19 meters in length, survive by eating animals on the surface of the water and fish on the bottom, are mostly found in the Atlas and the Great Ocean 🌊

[gdlr_core_space height=”30px”]

Working Principle and Flow Chart 📐

Humpback whales predict the position of their prey by surrounding them with air bubbles.In this optimization algorithm, prey relative to whales is considered the optimum point to reach. Since the optimal solution is unknown in optimization problems, the optimum point is considered to be the best solution reached or a point trying to approach it.

The behavior of whales to move towards prey is modeled in two parts: narrowing the circle around the prey and spiral movement. Narrowing the circle around the prey is possible by reducing the value of α in the equation ⚪ ️

Spiral Motion Used To Surround Prey

[gdlr_core_space height=”30px”]

Flow Chart

[gdlr_core_space height=”30px”]

To examine the test functions used in the project, these are the optimization functions such as eggholder, schaffer, booth, mayas, cross_in_tray and levi respectively. I have been giving the following a place in a section 👇🏻

Schaffer Function 🟠

The formula of the Schaffer function can be reached immediately from below.

📌 When the Schaffer function is executed, you can access the visualizations of the search space and the best orientation from the following image.

[gdlr_core_space height=”30px”]

Eggholder Fonksiyonu 🟢

The formula for the Eggholder function can be found immediately below.

📢 When the test functions listed here are executed for the Booth function of the whale optimization algorithm, the following compatibility value is reached.

For the solution of the onemax problem, as in my other paper, when calculating with Sigmoid function, the size values were changed and the size values were executed for 100, 500 and 1000 respectively on behalf of a total of 30 whales.


You can access another article from the link where I examined the performance of the PSO algorithm in the One Max problem 🧷

[gdlr_core_space height=”30px”]

The best_globalbest value for the PSO algorithm is held in a numpy array and then the following values are reached by applying the Wilcoxon statistic. The best value positions in the BOA and PSO algorithms were compared in this way. For the performance comparison of PSO and BOA algorithms, which is the main objective of the project, the global best-kept values between values calculated in both herd algorithms are kept and evaluated in a numpy array as a result of running 30 times.

D size of problem: 100, number of iterations : 100.000 and total 30 times run

D size of problem: 500, number of iterations : 100.000 and total 30 times run

D size of problem: 1000, number of iterations : 100.000 and total 30 times run

[gdlr_core_space height=”30px”]

Comparison of PSO and WOA Algorithms

The result of both optimization algorithms that I examined is understood by looking at the values in the table where the PSO algorithm works more performance with the arguments specified. When the w value is 0.005 and the c1 value is 0.005 and the c2 value is 0.009 for D=1000 the best value calculated for the PSO algorithm is 7.397751636520865e-05. Size values increase by 100, 500 and 1000, while the values obtained are better for PSO and WOA algorithms 🔍

Since we have examined the performance of optimization algorithms that we often need in the field of artificial intelligence, we hope to see in another article. Healthy days 👩‍⚕️


  1. Murat Canayaz, Recep Ozdag, Data Clustering Based On The Whale Optimization, December 2017 .
  2. Erkan TANYILDIZI, Tuncay CIGAL, Chaotic Map Whale Optimization Algorithms, Fırat University, Eng. Comp. Article, 29(1), 309-319, 2017.
  3. Retrieved from
  4. Retrieved from
  5. Retrieved from

Leave a Reply