# Adaptive Salp Swarm Algorithm for Optimization of Geotechnical Structures
## 2 Salp Swarm Algorithm  
A salp is a type of marine animal in the Salpidae family. It has a cylindrical structure with apertures at the ends similar to those of a jellyfish, which move and eat by pumping water through internal feeding filters in their gelatinous bodies. The salp swarm algorithm (SSA), a population-based optimization technique, was developed by [PERSON] et al. [49]. The salp chain can be used to calculate the SSA's behavior while hunting for optimal feeding sources (i.e., the target of this swarm is a food position in the search space called FP). To mathematically model salp chains, they are sampled into two groups: followers and leaders. The salp at the head of the chain is known as the leader, while the others are known as followers. The swarm is led by the leader of these salps, and the followers follow in his footsteps. The chain begins with a leader, who is followed by the followers to guide their movements.  
Similar to other swarm-based algorithms, the salp location is specified in a \(n\)-dimensional search space, where \(n\) is the number of variables in a given problem. As a result, the positions of all the salps are recorded in a two-dimensional matrix known as \(X\), as shown in Equation (1):  
\[X_{i}=\begin{bmatrix}x_{1}^{1}&x_{2}^{1}&\dots&x_{d}^{1}\\ x_{1}^{2}&x_{2}^{2}&\dots&x_{d}^{2}\\ \vdots&\vdots&\dots&\vdots\\ x_{1}^{n}&x_{2}^{n}&\dots&x_{d}^{n}\end{bmatrix} \tag{1}\]  
The fitness of each salp is then determined in order to define which salp has the best fitness. It is also supposed that the swarm's goal is a food position called \(FP\) in the search area.  
The following equation can be used by the leader salp to change positions:  
\[x_{i}^{1}=\begin{cases}FP_{i}+r_{1}((ub_{i}-lb_{i})r_{2}+lb_{i})&r_{3}\geq 0\\ FP_{i}-r_{1}((ub_{i}-lb_{i})r_{2}+lb_{i})&r_{3}<0\end{cases} \tag{2}\]  
where \(x_{i}^{1}\) denotes the first salp's position in the \(i\)th dimension, and \(FP_{i}\) denotes the food position in the \(i\)th dimension. The lower and upper bounds of the \(i\)th dimension are represented by \(lb_{i}\) and \(ub_{i}\), respectively, and the coefficient \(r_{1}\) is calculated with Equation (3):  
\[r_{1}=2e^{-(\frac{4t}{t_{max}})^{2}} \tag{3}\]  
In addition, the random numbers \(r_{2}\) and \(r_{3}\) are between 0 and 1. The maximum number of iterations is \(t_{max}\), and the current iteration is \(t\). It is worth noting that the \(r_{1}\) coefficient is critical in a SSA because it balances exploration and exploitation throughout the search. The following equations are used to change the positions of the followers:  
\[x_{i}^{j}=\frac{1}{2}\left(x_{i}^{j}+x_{i}^{j-1}\right) \tag{4}\]  
where \(j\geq 2\). In case some agents transfer outside of the search area, Equation (6) shows how to move salps back into the search area if they leave it:  
\[x_{i}^{j}=\begin{cases}lb_{i}&if\ x_{i}^{j}\leq\ lb_{i}\\ ub_{i}&if\ x_{i}^{j}\geq\ ub_{i}\\ x_{i}^{j}&otherwise\end{cases} \tag{5}\]  
The pseudocode of the SSA is shown in Algorithm 1.  
```
Initialize the salp population \(x_{i}\) (\(i=1,\,2,\,\ldots,\,n\)) considering \(lb_{i}\) and \(ub_{i}\) while\(t\leq t_{\text{max}}\) Calculate the fitness of each search agent (salp) Put the best search agent as \(FP\) (Food position) Update \(r_{1}\) by Equation (3) for each salp (\(x_{i}\)) if\(i=1\) Update the position of the leading salp by Equation (2) else Update the position of the follower salp by Equation (4) end if Amend the salps based on the upper and lower bounds of variables Calculate the fitness of each search agent \(FP\) Update the food position \(t=t+1\) end return the food position \(FP\) and its best fitness
```  
**Algorithm 1** Salp swarm algorithm