File Exchange

image thumbnail

SSA: Salp Swarm Algorithm

version (109 KB) by Seyedali Mirjalili
SSA is a novel algorithm for solving single-objective optimization problems


Updated 22 May 2018

View License

The main inspiration of SSA is the swarming behaviour of salps when navigating and foraging in oceans. Read this webpage to know more about the inspiration:

This is the source codes of the paper:

S. Mirjalili, A.H. Gandomi, S.Z. Mirjalili, S. Saremi, H. Faris, S.M. Mirjalili, Salp Swarm Algorithm: A bio-inspired optimizer for engineering design problems, Advances in Engineering Software, in-press, DOI:

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). SSA: Salp Swarm Algorithm (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (20)


thanks for free code. this code shared in
اسلاید فارسی، ترجمه مقاله و انجام پروژه با الگوریتم Salp نیز توسط تیم ما قابل انجام است

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

Benchmark 17 is showing error. I mean dimensions are not matching. See the Matlab reply...
Error using >
Matrix dimensions must agree.
Error in SSA (line 87)
Error in main (line 47)

Thanks for your nice comment Quoc.

The code works perfectly.
Thank you for your great work!

Thank you for your advice. @Seyedali Mirjalili

Thanks Kacjer, I noticed updating more than one solution better solve some problems. Try to do some experiments to see which method suits your problem best.

Besides, I have another question. Don't we need to update the leader according to the fitness comparison after every iteration? Thank you so much.

Thank you for your excellent contribution. I wondered why half the swarms are chosen as the leader to update their position. Thank you again!

@ sush mhatugade: you have to add constraints in the objective function.
@ Mohammed: you have to add constraints in the objective function.
@ Premkumar: It is difficult for me to debug your code given this short description. Please use the Matlab debugger and run the code line by line until you find the error.

James Too

Mai I know the reason for the SSA algorithm to use " if i <= N/2 " , but not "i==1" for the leader salp to update? Thank you

I thought of using this algorithm for detecting global peak (Solar PV MPPT). While running the code, it is showing that "N" is Undefined function or variable 'N', Undefined function or variable 'newindex' and Undefined function or variable 'Sorted_salps'. The first assignment to a local variable determines its class. Please help me in this regard.

How to add constraints in the code?

how do we enter equality constraints in the code?

I am working on other projects now.

Weimin Xiao

would you consider evaluating the SI with cec2013 or later benchmark functions?

Yes, it is a swarm intelligence technique

is this algorithm comes under the category of PSO?


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