1 Introduction

Optimization is a term used to refer to a branch of computational science concerned with finding the “best” solution to a problem. Here, “best” refers to an acceptable (or satisfactory) solution to a problem, which may be the absolute best over a set of candidate solutions, or a good alternative of the candidate solutions. The characteristics and requirements of the problem determine whether the overall best solution can be found [10]. Bio-inspired optimization algorithms are search methods, where the goal is to find a solution to an optimization problem, such that a given objective function is optimized, possibly subject to a set of constraints [10, 2325, 30]. Some optimization methods are based on populations of solutions [30]. Unlike the classic methods of optimization, in this case, each iteration of the algorithm maintains a set of solutions. These methods are based on generating, selecting, combining and replacing a set of solutions. Since they maintain and they manipulate a set, instead of a unique solution throughout the entire search process, they use more computer time than other meta-heuristic methods. This fact can be aggravated because the “convergence” of the population requires a great number of iterations. For this reason a concerted effort has been dedicated to obtaining methods that are more aggressive and manage to obtain solutions of quality in a nearer horizon.

This paper is concerned with bio-inspired optimization methods, and in particular the hybrid PSO-GA approach that is proposed. In this case, we combine each individual method in order to obtain the best features to design an optimal fuzzy logic controller (FLC) applied to the benchmark problems. Better results are expected of the hybrid PSO-GA method than those of traditional methods, like GA and PSO, because of the mixing of the best characteristics of both individual methods. We are also comparing the proposed method with genetic algorithms and particle swarm optimization used separately. The bio-inspired methods are used to find the parameters of the membership functions to obtain the optimal fuzzy controller to stabilize the plant, in particular for the Type-2 fuzzy controller, which is more difficult to design [21].

1.1 Related work

Up to date there are several research papers using genetic algorithms and particle swarm optimization for different optimization problems, like mathematical functions [1, 14, 32], fuzzy controllers [17, 3335] control parameters [31], the vehicle trajectories [22], scheduling problems [28] and many more. However, in this paper we used the hybrid PSO-GA approach to generate an optimal fuzzy logic controller finding the best parameters of the membership functions to control stable and unstable linear systems and this is the difference between our method and the methods of the following authors. For example, Valdez et al. [32] uses fuzzy logic to integrate the results obtained by PSO and GA applied to benchmark functions. Muhammad et al. [27] proposed a hybrid method that optimizes the rule base of the k-means method that is used to detect an impostor in a call on the Smartphones. Marinakis et al. [22] proposed a hybrid Genetic-PSO to help in the offspring of the individuals to be transmitted to all the population to get the best solution that in this case was applied to vehicle routing. Niu et al. [28] proposed a hybrid PSO using genetic operators inside the PSO to help to optimize the fuzzy ranking numbers for job scheduling.

This paper is organized as follows: Section 2 presents the theoretical basis and problem statement. Section 3 introduces the controller design where a Hybrid PSO-GA is used to select the parameters of the membership functions of the FLC, and the GA and PSO are also applied for comparison purposes. Robustness properties of the closed-loop system are achieved with a fuzzy logic control system using a Takagi–Sugeno model where the error and the change of error, are considered as the linguistic variables. Section 4 provides a simulation study of the plants using the controllers described in Sect. 3. Finally, Sect. 5 presents the conclusions.

2 Theoretical basis and problem statement

2.1 Particle swarm optimization (PSO)

PSO is a population based stochastic optimization technique developed by Eberhart and Kennedy [11], inspired by social behavior of bird flocking or fish schooling. PSO shares many similarities with evolutionary computation techniques, such as genetic algorithms (GA) [12]. The system is initialized with a population of random solutions and searches for optima by updating generations. However, unlike the GA, the PSO has no evolution operators such as crossover and mutation. In the PSO, the potential solutions, called particles, fly through the problem space by following the current optimum particles [5]. Each particle keeps track of its coordinates in the problem space, which are associated with the best solution (fitness) it has achieved so far (the fitness value is also stored). This value is called pbest. Another “best” value that is tracked by the particle swarm optimizer is the best value, obtained so far by any particle in the neighbors of the particle. This location is called lbest. When a particle takes all the population as its topological neighbors, the best value is a global best and is called gbest [15].

The particle swarm optimization concept consists of, at each time step, changing the velocity of (accelerating) each particle toward its pbest and lbest locations (local version of PSO). Acceleration is weighted by a random term, with separate random numbers being generated for acceleration toward pbest and lbest locations [5]. In the past several years, PSO has been successfully applied in many research and application areas. It has been demonstrated that PSO gets better results in a faster, cheaper way compared with other methods [16, 4, 3638]. Another reason that PSO is attractive is that there are few parameters to adjust. One version, with slight variations, works well in a wide variety of applications. Particle swarm optimization has been used for problems across a wide range of applications, as well as for the particular case of designing fuzzy controllers [16].

2.2 Genetic algorithms (GAs)

Genetic algorithms (GAs) are adaptive heuristic search algorithms based on the evolutionary ideas of natural selection and genetic processes [2]. The basic principles of GAs were first proposed by John Holland in 1975, inspired by the mechanism of natural selection where stronger individuals are likely the winners in a competing environment [3, 6, 8]. The GA assumes that the potential solution to any problem is an individual and can be represented by a set of parameters. These parameters are regarded as the genes of a chromosome and can be structured by a string of values in binary form. A positive value, generally know as a fitness value, is used to reflect the degree of “goodness” of the chromosome for solving the problem, which is highly related with its objective value. The GA works as follows:

  1. 1.

    Start with a randomly generated population of n chromosomes (candidate solutions to a problem).

  2. 2.

    Calculate the fitness of each chromosome in the population.

  3. 3.

    Repeat the following steps until n offspring have been created:

    1. a.

      Select a pair of parent chromosomes from the current population, the probability of selection being an increasing function of fitness. Selection is done with replacement, meaning that the same chromosome can be selected more than once to become a parent.

    2. b.

      With a particular probability (crossover rate), perform crossover to the pair at a randomly chosen point to a form two offspring.

    3. c.

      Mutate the two offspring at each locus with probability (mutation rate), and place the resulting chromosomes in the new population.

  4. 4.

    Replace the current population with the new population.

  5. 5.

    Go to step 2.

The simple procedure just described above is the basis for most applications of GAs.

2.3 Hybrid PSO-GA

We propose a hybrid method using particle swarm optimization and genetic algorithms to find an optimal FLC to control the benchmark plants. The hybrid method uses the same population/swarm in the two methods in the same iteration obtaining the best individual/particle. PSO and GA communicate with each other; every four iterations the best individual/particle is inserted into the population of the worst method and vice versa. We used the maximum number of iteration/generations to stop the method, keeping only the best FLC obtained [27]. The proposed method works as follows:

  1. 1.

    Start with a randomly generated particles/population (candidate solutions to a problem).

  2. 2.

    Assign to the variables S and Chrom the particles/population generated.

  3. 3.

    Repeat the following steps until max number of iteration/generations

    1. 3.1

      Start PSO method.

      1. 3.1.1

        For each particle do.

        1. 3.1.1.1

          Calculate fitness value.

        2. 3.1.1.2

          If the fitness value is better than the best fitness value (pBest) in history then, set the current value as the new pBest.

        3. 3.1.1.3

          Choose the particle with the best fitness value of all particles as the gBest.

        4. 3.1.1.4

          Update all particle velocities.

        5. 3.1.1.5

          Update all particle positions.

        6. 3.1.1.6

          Until “n” particles.

        7. 3.1.1.7

          Save the best particle information in variable BM.

    2. 3.2

      Terminate PSO.

    3. 3.3

      Start GA method.

      1. 3.3.1

        Calculate the fitness of each chromosome in the population.

      2. 3.3.2

        Repeat the following steps until n offspring have been created:

        1. 3.3.2.1

          Select a pair of parent chromosomes from the current population, the probability of selection being an increasing function of fitness. Selection is done with replacement, meaning that the same chromosome can be selected more than once to become a parent.

        2. 3.3.2.2

          With probability (crossover rate), perform crossover to the pair at a randomly chosen point to a form two offspring.

        3. 3.3.2.3

          Mutate the two offspring at each locus with probability (mutation rate), and place the resulting chromosomes in the new population.

      3. 3.3.3

        Replace the current population with the new population.

      4. 3.3.4

        Go to step 5.

      5. 3.3.5

        Save the best individual information in variable BM

    4. 3.4

      Terminate GA.

  4. 4.

    if counter = 4

    1. 4.1

      Obtain the minimum result of the BM variable

    2. 4.2

      if minimum value was obtained by PSO method then

    3. 4.3

      reinsert the information of the particle in the GA population (Chrom) 4.3 else

    4. 4.4

      reinsert the information of the best individual of GA in the Swarm of the PSO

  5. 5.

    Terminate the validation.

  6. 6.

    Terminate the hybrid method until maximum number of iterations/generations.

The procedure described above is used to find an optimal fuzzy logic controller combining the PSO and GA to exploit more completely the space of solutions.

2.4 Problem statement

To test the optimized FLCs obtained with the bio-inspired methods; we used two different benchmark plants. We consider two benchmark problems called Plant 1 and Plant 2 with different levels of complexity. We used this kind of applications to observe the behavior of the proposed method with respect to the GA and PSO methods [21].

Plant 1 is given by the following stable second order transfer function:

$$ g(s) = \frac{{w_{n}^{2} }}{{s^{2} + 2\varepsilon w_{n} s + w_{n}^{2} }}\quad \varepsilon = 0.5,\,w_{n} = 2 $$
(1)

where \( w_{n} \) is the natural frequency and \( \varepsilon \)is the coefficient damping.

Plant 2 is given by the following transfer function:

$$ g(s) = \frac{1}{{s^{2} + 4}} $$
(2)

The behavior of Plant 2 is more complex as will be seen later. The main idea in using these two plants is to illustrate the proposed hybrid approach in designing the fuzzy controllers, especially for Type-2 fuzzy logic, which are more complex to design than Type-1. Of course, it is well known that even for designing Type-1 fuzzy controllers the problem could be challenging, but this is even more critical for designing optimal Type-2 fuzzy controllers.

3 Fuzzy logic control design

In this section we show the design of a fuzzy logic controller (FLC), where the optimal controller was found using the proposed hybrid PSO-GA, GAs and the PSO. For the FLC a Takagi–Sugeno type of fuzzy system is used with two inputs (a) error, and (b) error change, with three membership functions for each input, “negative, zero and positive” (Gaussian and triangular), and one output, defined with constant values [7, 9, 13, 1821, 26, 29]. Figure 1 shows the FLC membership functions for the plant control and Table 1 shows the Fuzzy Rules.

Fig. 1
figure 1

Gaussian and triangular membership functions and Table 1 show the fuzzy rules

Table 1 Fuzzy rules of the FLC

Once we obtained the FLC design, we set the parameters of both methods: the GA chromosome has 17 genes of real values that represent the two inputs, error and error change and one output with constant values and using different values in the genetic operator’s; mutation and single point crossover and roulette wheel selection method. For PSO method we use different values for the cognitive and social parameters also an inertial value to balance the swarm. For the hybrid PSO-GA method we apply the same parameter configuration used in GA and PSO; from an initial space search we generate two subpopulations to work inside of the hybrid method. The three bio-inspired methods use the same space of solutions (population) that we consider to find the optimal values of the parameters of the membership functions. Table 2 shows the parameters of the membership functions, the minimal and the maximum values in the search range for the Hybrid PSO-GA, GA and PSO to find the best fuzzy controller system for the benchmark plants.

Table 2 Parameters of the membership functions

4 Simulation results

In this section we present the simulation results for each bio-inspired method applied to Plant 1 and Plant 2. We organized the presentation of the simulation results as follows:

4.1 Optimal FLC results obtained with the PSO method for Plant 1

The simulation results for the Type-1 FLC obtained with the PSO method applied to Plant 1 are presented in this section. Table 3 contains the configuration values of the PSO method, the execution time of PSO and the average error for each configuration. The first row shows the best controller obtained by PSO.

Table 3 Results of the Type-1 FLC obtained with PSO for Plant 1

Figure 2a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 2b shows the particles behavior of the PSO method giving the best FLC to control the Plant 1 and Fig. 2c shows FLC Type-1 result for Plant 1 obtaining the control before the 10 s on stable manner.

Fig. 2
figure 2

a Input 1 and input 2 membership functions of the Type-1 FLC, b particles behavior of the PSO method and c closed-loop response of Plant 1 with the optimized FLC

Continuing with the simulation results using the PSO method for Plant 1 we present the optimal Type-2 FLC, showing in Table 4 the configuration values of the PSO method, the execution time and the average error of each configuration. The first row shows the best Type-2 controller obtained by PSO.

Table 4 Results of the Type-2 FLC obtained by PSO for Plant 1

Figure 3a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 3b shows the particles behavior of the PSO method giving the best FLC to control the Plant 1 and Fig. 3c shows FLC Type-2 result for Plant 1 obtaining the control before of the 10 s with a little overshoot.

Fig. 3
figure 3

a Input 1 and input 2 membership functions of the Type-2 FLC, b particles behavior of the PSO method and c closed-loop response of Plant 1 with the optimized FLC

4.2 Optimal FLC results obtained by the PSO method for Plant 2

In this section we present the simulation results for the Type-1 FLC obtained by the PSO method applied to Plant 2. Table 5 contains the configuration values of the PSO method, the execution time of PSO and the average error for each configuration. The first row shows the best controller obtained by PSO.

Table 5 Results of the Type-1 FLC obtained by PSO for Plant 2

Figure 4a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 4b shows the particles behavior of the PSO method giving the best FLC to control the Plant 2 and Fig. 4c shows FLC Type-1 result for Plant 2 obtaining the control before of the 5 s on stable manner.

Fig. 4
figure 4

a Input 1 and input 2 membership functions of the Type-1 FLC, b particles behavior of the PSO method and c closed-loop response of Plant 2 with the optimized FLC

Continuing with the simulation results using the PSO method for Plant 2 we present the optimal Type-2 FLC, showing in Table 6 the configuration values of the PSO method, the execution time and the average error of each configuration. The first row shows the best Type-2 controller obtained by PSO.

Table 6 Results of the Type-2 FLC obtained by PSO for Plant 2

Figure 5a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 5b shows the particles behavior of the PSO method giving the best FLC to control the Plant 1 and Fig. 5c shows FLC Type-2 result for Plant 1 obtaining the control before of the 5 s but with an overshoot.

Fig. 5
figure 5

a Input 1 and input 2 membership functions of the Type-2 FLC, b particles behavior of the PSO method and c closed-loop response of Plant 2 with the optimized FLC

4.3 Optimal FLC results obtained by the GA method for Plant 1

This section presents the simulation results for the Type-1 FLC obtained by the GA method applied to Plant 1. Table 7 contains the configuration values of the GA method, the execution time of GA and the average error for each configuration. The third row shows the best controller obtained by GA.

Table 7 Results of the Type-1 FLC obtained by GA for Plant 1

Figure 6a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 6b shows the evolution of the GA method giving the best FLC to control the Plant 1 and Fig. 6c shows FLC Type-1 result for Plant 1 obtaining the control before the 10 s on stable manner.

Fig. 6
figure 6

a Input 1 and input 2 membership functions of the Type-1 FLC, b evolution of the GA method and c closed-loop response of Plant 1 with the optimized FLC

Continuing with the simulation results using the GA method for Plant 1 we present the optimal Type-2 FLC, showing in Table 8 the configuration values of the PSO method, the execution time and the average error of each configuration. The first row shows the best Type-2 controller obtained by PSO.

Table 8 Results of the Type-2 FLC obtained by PSO for Plant 1

Figure 7a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 7b shows the evolution of the GA method giving the best FLC to control the Plant 1 and Fig. 7c shows FLC Type-2 result for Plant 1 obtaining the control before of the 5 s with a small overshoot.

Fig. 7
figure 7

a Input 1 and input 2 membership functions of the Type-2 FLC, b evolution of the GA method and c closed-loop response of Plant 1 with the optimized FLC

4.4 Optimal FLC results obtained by the GA method for Plant 2

This section presents the simulation results for the Type-1 FLC obtained by the GA method applied to Plant 2. Table 9 contains the configuration values of the GA method, the execution time of GA and the average error for each configuration. The tenth row shows the best controller obtained by GA.

Table 9 Results of the Type-1 FLC obtained by GA for Plant 2

Figure 8a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 8b shows the evolution of the GA method giving the best FLC to control the Plant 2 and Fig. 8c shows FLC Type-1 result for Plant 2 obtaining the control before the 5 s with a small overshoot and undershoot.

Fig. 8
figure 8

a Input 1 and input 2 membership functions of the Type-1 FLC, b evolution of the GA method and c closed-loop response of Plant 2 with the optimized FLC

Continuing with the simulation results using the GA method for Plant 2 we present the optimal Type-2 FLC, showing in Table 10 the configuration values of the PSO method, the execution time and the average error of each configuration. The sixth row shows the best Type-2 controller obtained by PSO.

Table 10 Results of the Type-2 FLC obtained by PSO for Plant 2

Figure 9a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 9b shows the evolution of the GA method giving the best FLC to control the Plant 2 and Fig. 9c shows FLC Type-2 result for Plant 2 obtaining the control before of the 5 s with a large overshoot and a small undershoot.

Fig. 9
figure 9

a Input 1 and input 2 membership functions of the Type-2 FLC, b evolution of the GA method and c closed-loop response of Plant 2 with the optimized FLC

4.5 Optimal FLC results obtained by the hybrid PSO-GA method for Plant 1

This section presents the simulation results of the proposed method called hybrid PSO-GA to obtain the Type-1 FLC applied to Plant 1. Table 11 contains the configuration values of the hybrid method, the execution time of hybrid PSO-GA and the average error for each configuration. The first row shows the best controller obtained by the proposed method.

Table 11 Results of the Type-1 FLC obtained by hybrid PSO-GA method for Plant 1

Figure 10a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 10b shows the behavior of the individuals/particles of the hybrid method giving the best FLC to control Plant 1 and Fig. 10c shows FLC Type-1 result for Plant 1 obtaining the control before 10 s in a stable manner.

Fig. 10
figure 10

a Input 1 and input 2 membership functions of the Type-1 FLC, b behavior of the individuals/particles of the hybrid PSO-GA method and c closed-loop response of Plant 1 with the optimized FLC

Continuing with the simulation results using the hybrid method for Plant 1 we present the optimal Type-2 FLC, showing in Table 12 the configuration values of the hybrid PSO-GA method, the execution time and the average error of each configuration. The first row shows the best Type-2 controller obtained by the hybrid PSO-GA.

Table 12 Results of the Type-2 FLC obtained by hybrid method for Plant 1

Figure 11a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 11b shows the individuals/particles behavior of the hybrid PSO-GA method giving the best FLC to control the Plant 1 and Fig. 11c shows FLC Type-2 result for Plant 1 obtaining the control before 5 s with a large overshoot and a small undershoot.

Fig. 11
figure 11

a Input 1 and input 2 membership functions of the Type-2 FLC, b individuals/particles behavior of the hybrid PSO-GA method and c closed-loop response of Plant 1 with the optimized FLC

4.6 Optimal FLC results obtained by the hybrid PSO-GA method for Plant 2

This section presents the simulation results of the proposed method called hybrid PSO-GA to obtain the Type-1 FLC applied to Plant 2. Table 13 contains the configuration values of the hybrid method, the execution time of hybrid PSO-GA and the average error for each configuration. The second row shows the best controller obtained by the proposed method.

Table 13 Results of the Type-1 FLC obtained by hybrid PSO-GA method for Plant 2

Figure 12a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 12b shows the behavior of the individuals/particles of the hybrid method giving the best FLC to control the Plant 1 and Fig. 12c shows the FLC Type-1 result for Plant 2 obtaining the control before 5 s in a stable manner.

Fig. 12
figure 12

a Input 1 and input 2 membership functions of the Type-1 FLC, b behavior of the individuals/particles of the hybrid PSO-GA method and c closed-loop response of Plant 2 with the optimized FLC

Continuing with the simulation results using the hybrid method for Plant 2 we present the optimal Type-2 FLC, showing in Table 14 the configuration values of the hybrid PSO-GA method, the execution time and the average error of each configuration. The first row shows the best Type-2 controller obtained by the hybrid PSO-GA.

Table 14 Results of the Type-2 FLC obtained by hybrid method for Plant 2

Figure 13a shows the membership functions of input 1 and input 2 of the optimal FLC, Fig. 13b shows the individuals/particles behavior of the hybrid PSO-GA method giving the best FLC to control the Plant 2 and Fig. 13c shows the FLC Type-2 result for Plant 1 obtaining the control before 10 s with a small overshoot.

Fig. 13
figure 13

a Input 1 and input 2 membership functions of the Type-2 FLC, b individuals/particles behavior of the hybrid PSO-GA method and c closed-loop response of Plant 2 with the optimized FLC

4.7 Comparison of results of the optimization methods

In this section we present a comparison of results among bio-inspired methods, based on the average error obtained for the simulations. Table 12 show the comparison of results of the Best FLC obtained with the GA, PSO and the hybrid PSO-GA method applied to Plant 1 and Plant 2.

In Table 12 we show the comparison of the optimization methods and we can observe that the FLCs of Type-1 and Type-2 show the best results with the PSO and Hybrid PSO-GA, however the Hybrid PSO-GA shows a significant difference in the results with respect to the GA and PSO results obtained separately in Plant 2, which is more complex to solve (Table 15).

Table 15 Comparison of the average error of the Best FLC obtained by the optimization methods

5 Conclusions

We described in this paper the application of bio-inspired methods to design optimized fuzzy logic controllers using genetic algorithms, particle swarm optimization and the proposed hybrid PSO-GA method. To test these optimized FLCs we use two different plants. In particular we presented results of a genetic algorithm (GA), particle swarm optimization (PSO) and a hybrid PSO-GA, using two benchmark problems with different levels of complexity. The main result shows that the optimal FLC gets stability in less than 10 s. On the other hand, the FLCs obtained by GA are better than the FLCs obtained by the PSO because the controller obtained with the GA shows more stability and less steady state error with respect to the reference, the plots of the results shows this difference. We can observe that the Type-1 FLCs obtained by GA and PSO show lower steady state errors than the FLCs obtained by the hybrid PSO-GA due to the simplicity of the problem. However the Type-1 and Type-2 FLCs obtained by the proposed hybrid method applied to Plant 2 improved with respect of the FLCs obtained by GA and PSO obtaining lower steady state error and better stability, that we can observe in the simulation results. Based in this fact we expect that the hybrid method will obtain better results when used in more complex problems.

We have achieved satisfactory results with the GA, PSO and the hybrid PSO-GA; the next step is to solve the problem in a perturbed environment and considering multiple objective optimization to obtain better results in more complex problems. Moreover, in the future we will extend the results for nonlinear systems.