File Exchange

image thumbnail

The Whale Optimization Algorithm

version (230 KB) by Seyedali Mirjalili
WOA is a new algorithm for solving single-objective optimization problems


Updated 22 May 2018

View License

The Whale Optimization Algorithm (WOA) is a new optimization technique for solving optimization problems. This algorithm includes three operators to simulate the search for prey, encircling prey, and bubble-net foraging behavior of humpback whales.
This is the source codes of the paper:
S. Mirjalili, A. Lewis, The Whale Optimization Algorithm, Advances in Engineering Software , in press, 2016, DOI:


A Matlab toolbox for this algorithm can be found here:

If you have no access to the paper, please drop me an email at and I will send you the paper.

All of the source codes and extra information as well as more optimization techniques can be found in my personal website at

I have a number of relevant courses in this area. You can enrol via the following links with 95% discount:

A course on “Optimization Problems and Algorithms: how to understand, formulation, and solve optimization problems”:

A course on “Introduction to Genetic Algorithms: Theory and Applications”

Cite As

Seyedali Mirjalili (2020). The Whale Optimization Algorithm (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (18)


ممنون از مقاله خوبتون . این کد بصورت رایگان در متلب24 منتشر شد ، همچنین اسلاید آماده فارسی به همراه ترجمه فارسی مقاله نیز در لینک زیر قابل دریافت است

Zhanchao Li

Nguyen Thieu

Check out my github, I implemented this algorithm in Python (Numpy) for better performance.

salwa elsayed

syed musthafa

how can i use this coding for tuning pid controllers

djim djim

Thanks for sharing



Is there any binary version of WOA?

hello all
i have applied this technique in LFC problem.
iam geeting the error as
??? Subscript indices must either be real positive integers or logicals.

Error in ==> GWO at 50
can any one resolve my error so that it will be helpful for me


Hi Dr. Mirjalili,

Thank you very much for sharing with us the code for this amazing optimization algorithm. I would like to use it on my research for structural optimization, just as you did in your paper. My question is , the code you shared with us contain examples of optimizing objective function with explicit expressions, can you shed me some light on how to modify the code so that it works for an optimization problem without an explicit expression. For example, I build a parametric finite element model of a structure, then I would like to optimize the structural parameters setting the maximum stress as the objective function. Can you share with us the code for one of the examples of truss optimization in your paper?

Seyedali Mirjalili

@ Ahmad: Yes, you have to use penalty or barrier functions. I have covered this here:
@ Heba: Yes, you have to use penalty or barrier functions. I have covered this here:
@ Weihua: Have you tried to fine tune the parameters of the WOA algorithm (e.g. maximum number of iterations, number of whales, etc.)
@ Ali Sameer: Yes you can. I have got several publications and source codes in the area of training ANN. Please check my website:

Ali sameer

Thanks for your efforts
Dear sir, I want to know if it is possible to utilize your grate algorithm to train Artificial Neural Network

Weihua Zheng

Sir, it seems that there are some problems with the codes, e.g, when dealing with the function 'F3' the optimal value found by WOA is between 40000 and 60000

Heba Elazab

Dear sir, I want to know can we access the program for constrained objective optimization.thanks in advance.

Ahmadi Mike

Dear sir, I want to know can we access the program for constrained multi-objective optimization. Thank you!

mohamed abu eita

Thanks, I have tested it on image binarization,
it's promising result.
for further info


Seyedali Mirjalili

You are right SAllee. It seems that I have forgotten to amend some of the comments. I will fix them soon. Thanks :)


sir,The last two lines in WOA.m should be 'The best solution obtained by WOA is' , you still write the 'The best solution obtained by GWO is' , you maybe forget to change,haha~~~


Links added:

A few comments have been amended in the main.m file.

A link to the toolbox has been added to the descriptions.

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux