# Gaslike Social Motility: Optimization Algorithm with Application in Image Thresholding Segmentation
## 2 The Proposed Gaslike Social Motility (GSM) Algorithm
### Gaslike Social Motility Algorithm  
The emergent behavior described by Equations (1) and (2) is well-suited for use as an optimization algorithm. To adapt this behavior for optimization, we introduced modifications while retaining the core principles of the original model. As a result, (1) and (2) are reformulated as follows:  
\[x_{t+1}^{i}=(1-\epsilon)f(r_{t}^{i})+\frac{\epsilon}{|\eta_{t}^{i}|}\sum_{j\in \eta_{t}^{i}}f(r_{t}^{j}), \tag{3}\]  
\[r_{t+1}^{i}=r_{\mathcal{N}}+\gamma\left(\sum_{j\in\eta_{t}^{i}}\frac{r_{B}^{j} -r_{t}^{i}}{|r_{B}^{j}-r_{t}^{i}|}\right)\left(x_{t+1}^{i}\sum_{j\in\eta_{t}^{ i}}x_{t+1}^{j}\right). \tag{4}\]  
Here, we consider a population of \(N\) motile particles, each with a continuous position \(\mathbf{r}_{t}^{i}\in\mathbb{R}^{D}\). Each particle \(i\) navigates the \(D\)-dimensional search space, where \(x_{t}^{i}\in\mathbb{R}\) represents the state (or \"mood\") of the \(i\)-th gas particle, reflecting its perception of the environment. The evolution of the particle's state depends on its interactions with its neighborhood. In particular, when \(r_{B}^{j}=r_{t}^{i}\), the best position achieved by the neighboring particle \(r_{B}^{j}\) coincides with the position of particle \(r_{t}^{i}\). In this case, the neighbor does not provide any meaningful contribution and is therefore ignored. Figure 1 illustrates an example of neighbor selection for the particle \(r_{t}^{i}\) within the search space. The primary objective is to optimize the function \(f(\cdot)\) by adjusting the position \(\mathbf{r}\) of the gas particles. The optimization process depends entirely on the position \(\mathbf{r}\) at the time step \(t\), which is influenced by the particle's mood \(x_{t+1}^{i}\). The factor \(x_{t+1}^{i}\sum_{j\in\eta_{t}^{i}}x_{t+1}^{j}\) is computed to determine the direction of motion for the particle. This equation quantifies the affinity of the particle \(i\) with its neighborhood. If the affinity is \"good\", the particle \(i\) moves toward the dense region of the normal distribution corresponding to the best global position of the particles. If the affinity is \"bad\", it moves in the opposite direction. Figure 2 illustrates whether the displacement is positive or negative based on the contributions of neighboring particles. Moreover, in Equation (4), the direction of movement for particle \(i\) depends on the distribution of the best-visited positions \(\mathbf{r}_{B}^{i}\) of all particles in the set \(\eta_{I}^{i}\), relative to the position of \(i\), as illustrated in Figure 3.  
Finally, the term \(r_{\mathcal{N}}\) is a vector generated as \(r_{\mathcal{N}}\sim\mathcal{N}(r_{Best},\sigma_{bs})\), where \(r_{\mathcal{N}}=(r_{1},r_{2},\ldots,r_{D})\in\mathbb{R}^{D}\). This introduces a randomness factor that models the uncertainty and variability inherent in social systems, where particles may act unpredictably in response to external influences. In the context of the model, this term can produce effects contrary to expectations, generating deviations in particle displacement and reflecting behavioral diversity within the network. This reinforces the analogy to real social systems, where interactions between agents are not always deterministic. Here, \(\mathcal{N}(\cdot)\) is a normal distribution centered on the best global position \(\mathbf{r}_{Best}\), and \(\sigma_{bs}\) is the standard deviation of the best positions of \(bs\) particles, where \(bs<N\). This term represents the leadership of the best-performing particle, guiding collective movement toward feasible regions with optimal solutions. However, particles may choose to move closer or farther depending on interactions with nearby particles, as illustrated in Figure 4.  
In summary, the displacement of the particles depends on how the position \(\mathbf{r}^{i}\) relates to the best positions found by the set \(\eta_{I}^{i}\) and how similar the next state \(\mathbf{x}_{i+1}\) is to the corresponding \(i\)-th component.