Optimization of Membership Functions for the Fuzzy Controllers of the Water Tank and Inverted Pendulum with Differents PSO Variants

In this paper the particle swarm optimization metaheuristic and two of its variants (inertia weight and constriction coefficient) are used as an optimization strategy for the design of optimal membership functions of fuzzy control systems for the water tank and inverted pendulum benchmark problems. Each variant has its own advantages in the algorithm, allowing the exploration and exploitation in different ways and this allows finding the optimal solution in a better way.


Introduction
At present time and within the computer science area, optimization is a key issue specifically in real-world problems.In analyzing these problems there is the difficulty of ensuring a good solution in a reasonably short time.
There are a variety of methods used to solve optimization problems.In particular, it is interesting to find heuristics that are approximate methods of solution, using an iterative process to guide the search for solutions, thus combining different concepts derived from fields such as Artificial Intelligence, Biological Evolution and Collective Intelligence.
This work is no exception in that we use the metaheuristic of Optimization by Swarm of Particles (PSO -Particle Swarm Optimization) developed by Kennedy and Eberhart in 1995 [1], where this is inspired by the behavior of flocks of birds, of fish and bees.This algorithm will be considered in this paper along with two of its variants, inertia and constriction.In the literature it has been mentioned that since this metaheuristic appeared in 1995 to the present it has had a major impact in the optimization of complex problems.Fuzzy Logic was initially proposed in 1965, at the University of California at Berkeley, by Lotfi A. Zadeh [2].Fuzzy Logic represents the common knowledge of linguistic qualitative and not necessarily quantitative mathematical language through fuzzy set theory and functions associated with them.
The rest of the paper is organized as follows.Section 2 and 3 discusses the variants of PSO (inertia and constriction coefficient) giving a brief definition of how they work and how their equations are used.Section 4 and 5 shows the architecture and methodology of how they work, also tables and graphs the best error found and a comparison chart with other algorithms are presented.In Section 6 shows simulation results of water tank and inverted pendulum.In Section 7 shows results using only inertia in the case of the water tank.In Section 8 we can find

Metaheuristic Optimization by Swarms of Particles
Basically the PSO metaheuristic is based on an iterative algorithm where a population of individuals is called Swarm and the individuals are called particles, which fly over a search space to find optimal solutions, where each particle is a possible solution to a particular problem.
More precisely we have particles flying in a multidimensional space, where the position of each particle is adjusted according to its own experience and that of their neighbors.It is a technique inspired by the flight patterns of birds; this simulates the movements of a flock trying to find food and it was developed initially by Kennedy and Eberhart in 1995 [1], [3][4][5][6].
We have that x i (t) is the position of the particle in the search space in a time t, and unless otherwise indicated, t denotes the time steps.The position of the particle is the change in velocity v i (t), to the current position, i.e.: i : index of particles t: time index x i : position of the particle v i : velocity of the particle To calculate the velocity of the particle the following equation is used: Where we have the following parameters forming this Equation: i: index of particles t: time index v i : velocity of the particle x i : position of the particle y ij : best position found by particle i (personal best) ŷ j : best position found by the swarm (best overall) c 1 ,c 2 : constant acceleration r 1 ,r 2 : random numbers in the interval [0,1] applied to the particle.
Table 1 shows the classical PSO algorithm and Figure 1 illustrates the particle movement based on the algorithm.1.

Variants of PSO
In this section several variants of PSO are presented [7].

Inertia factor
PSO calculates the new position of each particle as a function of the flight, updating its position after having calculated the new position.This inertia factor was introduced to reduce the influence that the search direction brings to the particle.The equation for calculating the new speed of the particle is as follows, but now accompanied by w that represents the inertia: Now the new speed (v ij (t+1)) is determined by taking into account the following parameters: -"w".The inertia weight or inertia factor is a value, which regulates the influence of the previous velocity of the particle v (t) in calculating the new speed v (t + 1), by way of regulating the flight of the particle making a balance between exploitation and exploration of the search space.The inertia factor under certain conditions promotes the convergence of the swarm, i.e. all the particles approach the leader of the Swarm.-Now v (t), Represents the current speed of the particle that was previously calculated by the same equation,and refers to the direction of flight is the particle having.The Acceleration coefficients c 1 *r 1j () and c 2 *r 2j () and r represents a random real number uniformly distributed between 0.0 and 1.0.The coefficient c 1 regulates the influence of cognitive knowledge of the particle and the coefficient c 2 regulates the influence of knowledge social.c 1 regulates the influence of the best position reached by the particle (y ij ) to guide your new address and c 2 regulates the influence of the cluster leader ( j ) in the search direction of the particle.
y ij .Represents the memory of the particle, its best position achieved so for in that generation.ŷ j .Represents the best position of the swarm, i.e. the leader.
x. Represents the current position of the particle is taken as reference for calculating the new speed.v (t+1) is the speed of the current particle will determine the new search direction of the particle in generation t + 1.After calculating the current speed v (t +1) updates the particle position using equation (1).

Constriction coefficient
Proposed by Clerc, where this variant affects the velocity and the update is calculated with the equation modified as follows: Where (5) Using constraints where ϕ ≥ 4 y k  [0, 1], k controls the exploration and exploitation capabilities of the swarm.

Statement of the Problem
The problem is to optimize the membership functions of the fuzzy controllers for the Benchmark cases The first case is the water tank, where the 2 variants are used to find out which one works best to find the results.Below in Figure 2 the proposed architecture is presented: In the case of the water tank the fuzzy system has two input variables, each with three membership functions, and an output variable that has five membership functions as shown in Figure 3.The Input1 variable Level (level) membership functions are: Gaussian, Gaussian, triangular is as shown in Figure 4.

Figure 4 Variable Input
The Input Variable 2 Speed (Rate): Gaussian, triangular and Gaussian is as shown in Figure 5.We are using three types of membership functions: Gaussian, triangular and generalized bell.
To evaluate the performance of the algorithm of particle swarm optimization (PSO) the equation of the mean absolute error was used, with the aim of finding the smallest error possible.(6) We considered the representation of the particle as shown in Fig. 7 where there is a vector with 33 positions, the first 18 positions representing the membership functions of the two input variables, and the remaining 15 positions are the membership functions of the output variable.
It is known in advance by reviewing the literature and previous works that to develop fuzzy controllers and obtain good results optimizing membership functions is not easy, as it takes time to obtain a good design [8]- [13], [16]- [20].That's why this work intends to make the optimization of membership functions with variants of the PSO and find out how efficient and fast they can be to find good results.

Inverted Pendulum
As in the previous case optimizing the membership functions of the fuzzy system the inverted pendulum is a similar problem.In this case, the control system has two inputs, each with five membership functions, and an output variable with five membership functions as shown in Figure 8.The variable rate input 2: triangular as shown in Figure 10.The output variable force: triangular as shown in Figure 11.We are using two types of membership functions: triangular and trapezoidal.
To evaluate the performance of the algorithm of particle swarm optimization (PSO) the mean absolute error equation was used, with the aim of finding the smallest error as in the previous case shown in Equation 6.
We considered the representation of the particle as shown in Figure 12, where there is a vector with 45 positions, the first 30 positions represent the membership functions of the two input variables, and the remaining 15 positions are the membership functions of the output variable.It is known in advance by reviewing the literature and previous works that to develop fuzzy controllers and obtain good results optimizing membership functions is not easy, as it takes time to obtain a good design [8]- [13].That's why this work intends to make the optimization of membership functions with variants of the PSO and find out how efficient and fast they can be to find good results.

Simulation Results for the water tank and the Inverted Pendulum
In this section we show results obtained from the two cases mentioned above.

Water Tank
Results are presented below in first the case (water tank).Table 2 shows results with the two variants of PSO and can be observed that only in Experiment 5 yielded a good error compared 0.011315 tank water that comes standard in Simulink without optimization that has an error of 0.0107.Figure 13 shows the behavior of the PSO that as shown in iteration 4 found the best results for that run.2.
Figure 14 Benchmark simulation of water tank according to Table 2. Now we show in Fig. 14, the resulting simulation using the two variants of PSO, and we can note that it follows very closely the reference.Below we show in Table 3 the updated results of the optimized water tank with PSO using only the two variants.In the experiments shown in Table 3 we have that the best error is shown in row number 15 with 0.00038353, and in this experiment we use the inertia factor of 1 and constriction of 0.2.These experiments are illustrated in the following Figures 15,16 3.
Figure 16.This figure shows the performance of PSO to Table 3.
Figure 17.Membership functions optimized with PSO according to Table 3.
Table 4 shows 15 new experiments using inertia with a value of 2 and constriction of 0.8 with the best result in experiment 3 with an error of 0.009892.Below we show for experiment 3 the results in Figure 18-20.We can see in Figure 13 that control stopped short of reaching the water tank reference, in Figure 14 shows the behavior of PSO where we observe that since the first iteration it was found small error in Figure 15 shows the memberships functions and optimized with PSO variants.
Table 5 shows a comparison with the two other algorithms, which are the Fuzzy Lyapunov Synthesis and the GA, of which we can be see that we have performed well compared to these algorithms reponted in [14] [15].Table 7 shows results with the two variants of PSO, and it can be noted that in Experiment 19 we obtain an error of 0.0038974, which compared to the non-optimized pendulum experiment number 1 we can see that we obtain a good result.22 we observe the simulation of the Inverted Pendulum optimization and in Figure 23 the behavior of the PSO.
Figure 22.Inverted pendulum simulation according to Table 7.
Figure 23.PSO Behavior according to Table 7.
Table 8 shows the results with the two variants of PSO, which can be noted that in Experiment an error of 6 9.326e-005 is obtained being the best result to the moment in this work.In Figure 24 shows the simulation of the optimization of the Inverted vertical pendulum and Figure 25 the PSO behavior with the good error mentioned above.

Results with only one variant (Inertia) of PSO for the Water Tank
The experiments carried out are to the water plant with a value of inertia of 0.7 and 0.9 to take these recommended values in the literature.Table 9 shows the results of experiments using only a value of 0.7 inerciacon and Table 10 shows the results of 10 experiments using inertia with a value of 0.9.In paragraph 7.1 in Table 11 and 12 show results using only 1 value constriction in Table 11 and worth 2 in Table 12.  8.
Figure 25.PSO Behavior according to Table 8.

Figure 2 .
Figure 2. Architecture of PSO optimization for fuzzy control

Figure 3 .
Figure 3. Mamdani Type Fuzzy System for first case

Figure 8 .
Figure 8. Mamdani Fuzzy system for the inverted pendulum Figure7.Vector representation in PSO

Figure 9 .
Figure 9. Membership functions of input variable (position)

Figure 12 .
Figure 12.PSO vector representation for the second case (inverted pendulum).

707 Figure 13 .
Figure 13.The perfomance of the PSO to Table2.

Figure 15 .
Figure 15.Benchmark simulation of water tank according to Table3.

Figure 21
Figure 21 Pendulum simulation not optimized.


Figure 24 Pendulum simulation according to Table8.

Table 2
Experiments with two Variants of PSO Case Tank Water.

Table 3 .
New water tank experiments with only two variants of PSO.

Table 4 .
New water tank experiments with only two variants of PSO.

Table 4 .
Figure 19.PSO Behavior according to

Table 4 .
Figure 20 Membership functions optimized with PSO according to Table 4.

Table 5
Comparison table with other optimization algorithms Below are the results in Table 6 of the Inverted Pendulum optimization

Table 6
Results of the Optimized Inverted Pendulum

Table 7 .
Results the Inverted Pendulum Optimized ISSN: 1693-6930  Optimization of Membership Functions for the Fuzzy Controllers of the Water ... (Resffa Fierro) 711 Below is the best result figure in the above table which is experiment No. 19 with an error of 0.0038974.In figure

Table 8 New
Results for the Inverted Pendulum Optimization

Table 9
Results with Inertia 0.7 for Water Tank

Table 10
Results with inertia 0.9 for Water Tank Optimization of Membership Functions for the Fuzzy Controllers of the Water ...(Resffa Fierro)713

Table 12
Results with constriction value of 2 for the Water Tank problem