# Gaslike Social Motility: Optimization Algorithm with Application in Image Thresholding Segmentation
## 2 The Proposed Gaslike Social Motility (GSM) Algorithm
### Gaslike Social Motility Algorithm
Specifically, if a particle is far from the best positions, it will move more significantly than if it is near them. The particle is attracted to remain in the vicinity of the best positions only if its state is comparable to those of its neighbors. If a particle has no neighbors (\(\eta_{I}^{i}\in\{\emptyset\}\)), its position is determined solely by the random  
Figure 1: Selection of neighbors of the particle \(r_{t}^{i}\) in the search space. Figure 2: The direction of displacement of a particle \(r_{t}^{i}\) according to affinity with its neighbors. variable from \(\mathcal{N}(\cdot)\), and its internal state is defined by the objective function at \(\mathbf{r}_{t}^{i}\). To avoid this scenario, an appropriate choice of \(R\) is crucial to ensure particles maintain interactions within the network, tailored to the properties of the objective function. The selection of the parameters \(\epsilon\), \(\gamma\), and \(R\) should be guided by the following considerations: \(\epsilon\) regulates the coupling between a particle's internal state and that of its neighbors. Larger values (\(0<\epsilon<1\)) increase the tendency to resemble neighboring particles, while \(\epsilon=0\) causes the particle to evolve independently of its neighborhood. \(\gamma\) should be small enough to allow cluster formation, as \(\gamma=0\) results in no motion. \(R\) depends on the size of the search space. If the space is large and \(R\) is small, particles may become too dispersed, preventing cluster formation. Conversely, if the space is small and \(R\) is large, particles will have nearly all others as neighbors. The interaction radius \(R\) defines the neighborhood size, and dynamically adjusting \(R\) allows the algorithm to balance local exploitation (small \(R\)) and global exploration (large \(R\)). When a particle has no useful neighbors (i.e., \(r_{B}^{j}=r_{t}^{i}\)), it acts independently, enabling it to escape local optima. Figure 4: Displacement of the particle \(\mathbf{r}_{t}^{i}\) with contribution of the best global position and the contribution provided by the neighbors, scaled by the parameter \(\gamma\). Figure 3: Angular distribution of the displacement of the particle \(r_{t}^{i}\) according to the best positions visited by the neighbors. In this way, we preserve the original property, where individuals evaluate their internal state to determine how much they want to resemble their neighborhood and, in terms of position, how they are located relative to the best position of their neighbors and how similar they are to their surroundings. Table 1 shows the list of GSM algorithm terms. The complete GSM algorithm is found in Algoritm 1. ```
1:\(R\), \(\epsilon\), \(\gamma\), \(bs\leftarrow\) define parameters
2:\(x^{i}\leftarrow\) initialize i \(\in\) N state of the particles randomly
3:\(r^{i}\leftarrow\) initialize \(i\in\{1,N\}\) random position such that \(r^{i}\in\mathbb{R}^{D}\)
4:\(r^{i}_{B}\gets r^{i}_{r}\), initialization of best particle positions
5:\(\eta^{i}\) initialize \(i\in\{N,N\}\) neighbors at zero such that \(\eta^{i}\in\mathbb{R}^{N}\)
6:do
7:for\(i=1\to N\)do
8:if\(f(r^{i}_{t})<f(r^{i}_{B})\)then
9:\(r^{i}_{B}\gets r^{i}_{t}\)
10: Choose particle with best swarm position \(r_{Best}\)
11: Selection of the best particles \(bs\) from \(r_{t}\)
12:for\(i=1\to N\)do
13:\(n\gets 0\)
14:for\(j=1\to N\)do
15:if\(|\mathbf{r}^{i}_{t}-\mathbf{r}^{i}_{t}|\leq R\)&&\(i\
eq j\)then
16:\(\eta^{i,n}_{t}\gets j\)
17:\(n\gets n+1\)
18:for\(i=1\to N\)do
19:\(\mathbf{x}^{i}_{t+1}\leftarrow(1-e)f(\mathbf{r}^{i}_{t})+\frac{\epsilon}{| \eta^{i}_{t}|}\sum_{j\in\eta^{i}_{t}}f(\mathbf{r}^{j}_{t})\)
20:\(\mathbf{r}^{i}_{t+1}\leftarrow r_{\mathcal{N}}+\gamma\left(\sum_{j\in\eta^{i}_ {t}}\frac{r^{i}_{B}-\mathbf{r}^{i}_{t}}{|\mathbf{r}^{i}_{B}-\mathbf{r}^{i}_{t }|}\right)\left(\mathbf{x}^{i}_{t+1}\sum_{j\in\mathcal{U}^{i}_{t}}\mathbf{x}^{ j}_{t+1}\right)\) \(t=\ t\ +\ 1\)
21:while Total number of iterations G is fulfilled
```  
**Algorithm 1** GSM algorithm to solve minimization problems.