# Revised Gravitational Search Algorithms Based on Evolutionary-Fuzzy Systems
## 2 The Gravitational Search Algorithm
The controller gives the fuzzy output \(\alpha(i+1)\), i.e., the \(i+1\) value of \(\alpha\). In this way, the value of \(\alpha\) is tuned. **S3. ** Give to the output the best-so-far solution. \begin{table}
\begin{tabular}{l l} \hline
**Unimodal Functions** & \(\mathbf{S}\) \\ \hline \(F_{1}(X)=\sum_{i=1}^{r}x_{i}^{2}\) & \([-100;100]^{r}\) \\ \(F_{2}(X)=\sum_{i=1}^{r}|x_{i}|+\prod_{i=1}^{r}|x_{i}|\) & \([-10;10]^{r}\) \\ \(F_{3}(X)=\sum_{i=1}^{r}\left(\sum_{i=1}^{r}x_{i}\right)^{2}\) & \([-100;100]^{r}\) \\ \(F_{4}(X)=max_{i}\{|x_{i}|,1\leq i\leq r\}\) & \([-100;100]^{r}\) \\ \(F_{5}(X)=\sum_{i=1}^{r-1}\left[100\left(x_{i+1}-x_{i}\right)^{2}+\left(x_{i}- 1\right)^{2}\right]\) & \([-30;30]^{r}\) \\ \(F_{6}(X)=\sum_{i=1}^{r}\left([x_{i}+0.5]\right)^{2}\) & \([-100;100]^{r}\) \\ \(F_{7}(X)=\sum_{i=1}^{r}i\cdot x_{i}^{4}+random[0,1)\) & \([-1.28;1.28]^{r}\) \\ \hline
**Multimodal Functions** & \(\mathbf{S}\) \\ \hline \(F_{8}(X)=\sum_{i=1}^{r}-x_{i}sin\sqrt{|x_{i}|}\) & \([-500;500]^{r}\) \\ \(F_{9}(X)=\sum_{i=1}^{r}\left[x_{i}^{2}-10 cos(2\pi x_{i}+10)\right]\) & \([-5.12;5.12]^{r}\) \\ \(F_{10}(X)=-20 xpr\left(-0.2\sqrt{\frac{1}{n}\sum_{i=1}^{r}x_{i}^{2}}\right)+\) & \([-32;32]^{r}\) \\ \(-exp\left(\frac{1}{n}\sum_{i=1}^{n}cos(2\pi x_{i})\right)+20+e\) \\ \(F_{11}(X)=\frac{1}{2000}\sum_{i=1}^{r}x_{i}^{2}-\prod_{i=1}^{r}\left(\frac{x_{ i}}{\sqrt{i}}\right)+1\) & \([-600;600]^{r}\) \\ \(F_{12}(X)=\frac{\pi}{4}\{10 sin(\pi y_{1})+\sum_{i=1}^{r-1}(y_{i}-1)^{2}[1+10 sin^ {2}(\pi y_{i+1})]+[-50;50]^{r}\) \\ \((y_{r}-1)^{2}\}+\sum_{i=1}^{r}u(x_{i},10,100,4)\) \\ \(y_{i}=1+\frac{x_{i}+1}{4}\) & \(\begin{array}{l}k(x_{i}-a)^{m},\quad\quad x_{i}>a\\ 0,\quad\quad a<x_{i}<a\\ k(-x_{i}-a)^{m},\quad x_{i}<-a\end{array}\) \\ \(F_{13}(X)=0.1\{sin^{2}(3\pi x_{1})+\sum_{i=1}^{r}(x_{1}-1)^{2}[1+sin^{2}(3\pi x _{1}+1)]\quad\quad[-50;50]^{r}\) \\ \(+(x_{r}-1)^{2}[1+sin^{2}(2\pi x_{r})]\}+\sum_{i=1}^{r}u(x_{i},5,100,4)\) \\ \hline \end{tabular}
\end{table} 
Table 2: Test functions. ```
S1. Optimize GSA with PSO (DE); in this way, the optimal value \(\alpha_{opt}\) is computed. S2. Calculate a suitable neighborhood of \(\alpha_{opt}\) with the formulas: \(\alpha_{opt_{\mathit{target}}}=\alpha_{opt}-\epsilon\) and \(\alpha_{opt_{\mathit{target}}}=\alpha_{opt}+\epsilon\), with \(\epsilon=0.02\). S3. Compute the membership functions ranges of \(\alpha\) taking into account the neighborhood of \(\alpha_{opt}\). S4. Initialize, in a random way, the position \(X\) of the agents in the search space. The initialization procedure depends on the number of agents \(n\), the dimension of the test functions \(r\) and the allowable range \([up,down]\) for the search space. The positions \(X\)'s are calculated by generating \(n\times r\) random numbers between \(0\) and \(1\), and normalize them on the range \([up,down]\). In other terms, the positions are computed by the formula \(X(i,j)=rand(i,j)*(down-up)+down\), with \(i=1,...,n\) and \(j=1,...,r\). S5. Set the initial value \(\alpha(1)\) and for each iteration \(i\), with \(i=1,2,...,k\), compute the steps from S5.1-S5.5. Compute the fitness of the agents for a certain function. The fitness depends on the position of the agents and the dimension of the function. S5.2. The value of the fitness is necessary to calculate the mass of each agent \(m_{i}(t)\) for \(i=1,2,...,n\). (see (11)). On the other hand, \(m_{i}(t)\) depends on \(best(t)\) and \(worst(t)\) (Equations (13) and (14), respectively), which also depend on fitness. The gravitational constant \(G(t)\) is computed according to \(\alpha(1)\) at the first iteration, whereas, for the other iterations, \(G(t)\) is calculated according to the adjusted value of \(\alpha\) (which comes from fuzzy controller). S5.3. According to \(G(t)\), the total force in different directions is calculated. In particular, the algorithm computes the Euclidean distance between two agents \(R_{ij}(t)\) and the force acting on mass \(i\) from mass \(j\) at a specific time \(t\) (see (3)). Subsequently, the total force \(F_{d}^{i}(t)\) (see (6)) is computed.