# Revised Gravitational Search Algorithms Based on Evolutionary-Fuzzy Systems
## 2 The Gravitational Search Algorithm
Therefore, the acceleration of the agents, their velocity and position at \(t\) time are calculated by means of (7), (8) and (9), respectively. **S4.3.4**. Compute the fuzzy output \(\alpha(i+1)\), i.e., the \(i+1\) value of \(\alpha\), through the fuzzy controller, which receives the following inputs: iteration number \(i\), population diversity \(P_{d}(i)\), population progress \(P_{p}(i)\) and \(\alpha(i)\). **S4.4**. Calculate the \(j\)-th value of the fitness function \(f_{j}(x)\) defined in (18). **S5**. Update the termination criteria parameters, which depend on fitness function values. **S6**. Compute the parents \(parent(i)\) with \(i=1,...,l\) through the selection method by using the Algorithm 2. **S7**. Compute the parameters \(p\) through the crossover method described in the Algorithm 3. **S8**. Compute some parameters \(p\) with the mutation (Algorithm 4). **S9**. Go to Step **S3**. **S10**. Give to the output the optimal parameters of the membership functions. ```

**Algorithm 5**

In order to test the algorithms, unimodal and multimodal benchmark functions [48] are considered. Table 2 shows the test functions, where \(r\) is the dimension of the function and \(S\) is a subset of \(R^{r}\). The membership functions of the fuzzy controller can be optimized also through evolutionary algorithms such as PSO and DE. The idea is to optimize the parameter \(\alpha\) of GSA by PSO and DE. In this case, only the ranges of the \(\alpha\) membership functions are optimized. Therefore, 3 \(\times\) 4 (alpha previous state) + 3 \(\times\) 4 (alpha current state) = 24 parameters are optimized. In the PSO and DE case, the membership functions ranges of \(\alpha\) are defined considering a neighborhood of the optimal value of \(\alpha\) that come from PSO [10] (DE [16]) optimization. The steps of FGSA-PSO (DE) algorithm are illustrated in Algorithm 7. **S1. ** 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\). **S2. ** Set the initial value \(a(1)\) and for each iteration \(i\), with \(i=1,2,...,k\), compute the steps from **S2.1-S2.5**. **S2.1. ** 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. **S2.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). **S2.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_{i}^{d}(t)\) (see (6)) is computed. Therefore, the acceleration of the agents, their velocity and position at \(t\) time, are calculated by means of (7), (8) and (9), respectively. **S2.4. ** Calculate the population diversity \(P_{d}(i)\) and the population progress \(P_{p}(i)\) as defined in (16) and (17). **S2.5. ** The GA-optimized fuzzy controller receives the inputs: iteration number \(i\), population diversity \(P_{d}(i)\), population progress \(P_{p}(i)\) and \(\alpha(i)\).