**3. Problem formulation**

making them good candidates for stochastic systems. One of the main challenges facing fuzzy logic control designers is the tuning of the membership functions and the heuristics involved. GA is used in this study to provide an autonomous guided search of the design space to

Double pendulum is an example of a dynamic system that exhibits chaotic behavior. The inverted double pendulum is an archetype for thrust vector controlled multi-staged rocket or missile or even multi-rotor UAV flight control. The problem of controlling an inverted double pendulum has been studied for decades using different types of controllers. One of the approaches that has been used is a self-tuned neuro-PID controller to control the inverted pendulum on a cart [1]. The controller was realized by summing up two controllers for position and angle controls. They proved the effectiveness and robustness of this technique. An angular momentum based

With the increase in computational capability and the advent of new and improved machine learning algorithms over the last decade, there has been an increase in the development of intelligent systems for various engineering applications such as path planning, target tracking, satellite attitude control systems [3], collaborative control of a swarm of UAVs [4], etc. Such intelligent systems provide various advantages, a few of which include adaptability,

Fuzzy logic is one such intelligent system that can provide robustness and adaptability to controllers. Fuzzy logic was used in combination with optimal control theory to design a highly effective controller [5]. In a related research [6], fuzzy logic was used for stabilizing a parallel type double inverted pendulum. This is different from the inverted double pendulum in that it involves two separate pendulums being controlled simultaneously on a cart. Simulation results showed that the controller was able to stabilize completely the parallel-type double inverted pendulum system within 10s for a wide range of the initial angles of the two pendulums. The performance of fuzzy logic was compared to a PID controller in controlling an inverted pendulum [7]. Simulation results showed that the fuzzy logic controllers (FLCs) are far superior compared to PID controllers in terms of overshoot, settling time and response to parameter changes. The performance of fuzzy controller tuned with noisy data was compared to that of a controller tuned without noise [8]. Optimizing the fuzzy system for a higher noise level results in good performance at lower noise levels. Lee presented three fuzzy system architectures and methods for automatically designing them for high dimensional problems [9]. The results indicate that the real coded algorithms consistently outperformed the binary coded algorithms in both the final performance of the system and the performance of the search algorithm. The Asymmetric-Triangular fuzzy systems consistently improved faster than the

Designing an FLS includes tuning the membership functions and the rulebase. This process can be automated by coupling GA with FLS to obtain the methodology known as Genetic

develop a more optimized solution in accordance with the design requirements.

28 Fuzzy Logic Based in Optimization Methods and Control Systems and Its Applications

controller was able to control the double pendulum at any unstable position [2].

robustness to uncertainties and improved efficiency.

hyper-ellipsoidal and shared triangular representations in all cases.

**2. Literature review**

The objective is to design two fuzzy logic controllers that control the torques at the two joints to bring the double pendulum to its inverted position from any initial condition as shown in **Figure 1**. *T1* and *T2* are the torques applied by the controller at the joints. GA is used to tune the fuzzy membership functions as well as the rule base to come up with the best possible solution, which settles at *θ<sup>1</sup>* = *0*, *θ<sup>2</sup> = 0*, in minimum time. The position of the masses m1 and m2 are given by

$$\mathbf{x}\_{\mathbf{i}} = l\_{\mathbf{i}} \sin \theta\_{\mathbf{i}} \tag{1}$$

$$y\_1 = l\_1 \cos \theta\_1 \tag{2}$$

**Figure 1.** Double pendulum schematic with controllers at the joints.

$$\mathbf{x}\_2 = l\_1 \sin \theta\_1 + l\_2 \sin \theta\_2 \tag{3}$$

$$y\_2 = l\_1 \cos \theta\_1 + l\_2 \cos \theta\_2 \tag{4}$$

The crossover requires two individuals and some portion of the two solution vectors are interchanged to obtain two child individuals. In a mutation, some values in a chosen individual are arbitrarily changed to obtain a new individual. The cost functions of all the resulting individuals are evaluated and the ones with lower cost values have higher probability of

**Figure 2.** Flowchart showing the genetic fuzzy logic methodology used for designing controllers for the inverted double

Development of a Genetic Fuzzy Controller and Its Application to a Noisy Inverted Double…

http://dx.doi.org/10.5772/intechopen.78786

31

The first 9 elements in the vector, *R(1–9)*, represent the rules as shown in **Table 1** and *R(10–15)* represent the boundaries of the membership functions as shown in **Figure 3**. The membership functions are assumed to be symmetric around zero. *R(1–9)* are integers with values from one to three. One, two and three represent negative (N), zero (ZO) and positive (P) membership

For this research, we use centroid defuzzification to obtain the crisp output values. The rulebase is assumed to be same for both the controllers T1 and T2. AND operator connects the

**N ZO P**

N R(1) R(2) R(3) ZO R(4) R(5) R(6) P R(7) R(8) R(9)

moving onto the next generation.

pendulum problem [13].

functions for the inputs, respectively.

. For example,

**Table 1.** GA string values assigned to the rulebase during training.

inputs *θ* and *θ*̇

̇ **θ**

The equations of motion of the double pendulum when torques *T1* and *T2* act at the joints are given below.

given below.

$$\begin{aligned} T\_1 &+ (m\_1 + m\_2)L\_1^2 \, \vec{\theta}\_1 + m\_2 L\_1 L\_2 \, \vec{\theta}\_2 \cos(\theta\_1 - \theta\_2) + m\_2 L\_1 L\_2 \, \dot{\theta}\_2^2 \sin(\theta\_1 - \theta\_2) \\ &+ (m\_1 + m\_2) \, \text{g}L\_1 \sin \theta\_1 = 0 \end{aligned} \tag{5}$$

$$\begin{aligned} T\_2 + m\_2 L\_2^2 \, \vec{\varTheta}\_2 + m\_2 L\_1 L\_2 \, \vec{\varTheta}\_1 \cos(\Theta\_1 - \Theta\_2) - m\_2 L\_1 L\_2 \, \dot{\varTheta}\_1^2 \sin(\Theta\_1 - \Theta\_2) \\ + m\_2 g L\_2 \sin \Theta\_2 = 0 \end{aligned} \tag{6}$$

#### Assumptions


#### **4. Methodology**

The flow chart showing the process of genetic fuzzy logic design as applied to the case of the inverted double pendulum is shown in **Figure 2**. Fuzzy logic is used to determine the torques acting on the two joints, *T1* and *T2* . In order to reduce the computational complexity, each of the inputs and outputs are defined by just three membership functions as shown in **Figure 3**.

GA is used to tune a 15-element vector *R*. GA is a search heuristic inspired from the process of natural selection that can perform an extensive search of a complicated *n-D* space, where n is the number of variables, to find a near optimal solution. For this research, *n = 15*. GA starts off with an initial set of random solutions also called a population of individuals, the size of which is pre-defined. There are two main operators in GA viz., crossover and mutation. Development of a Genetic Fuzzy Controller and Its Application to a Noisy Inverted Double… http://dx.doi.org/10.5772/intechopen.78786 31

*x*<sup>2</sup> = *l*

*y*<sup>2</sup> = *l*

*<sup>T</sup>*<sup>1</sup> <sup>+</sup> (*m*<sup>1</sup> <sup>+</sup> *<sup>m</sup>*2) *<sup>L</sup>*<sup>1</sup>

*<sup>T</sup>*<sup>2</sup> <sup>+</sup> *<sup>m</sup>*<sup>2</sup> *<sup>L</sup>*<sup>2</sup>

given below.

Assumptions

**1.** The masses *m1*

**2.** The masses *m1*

**4. Methodology**

shown in **Figure 3**.

The equations of motion of the double pendulum when torques *T1*

30 Fuzzy Logic Based in Optimization Methods and Control Systems and Its Applications

2 *θ*¨

<sup>2</sup> + *m*<sup>2</sup> *L*<sup>1</sup> *L*<sup>2</sup> *θ*¨

2 *θ*¨

and *m2*

and *m2*

**3.** The rods are assumed to be massless.

the torques acting on the two joints, *T1*

<sup>1</sup> + *m*<sup>2</sup> *L*<sup>1</sup> *L*<sup>2</sup> *θ*¨

are considered as particles.

**4.** Non-conservative forces like friction, air resistance, etc., are not considered.

**6.** The motion is constrained to two dimensions. Hence *z = 0*.

**5.** There is no delay in the transmission of torque from the controller to the joint.

**7.** The rods do not undergo expansion or compression. Thus, Eqs. (1)–(4) are satisfied.

The flow chart showing the process of genetic fuzzy logic design as applied to the case of the inverted double pendulum is shown in **Figure 2**. Fuzzy logic is used to determine

plexity, each of the inputs and outputs are defined by just three membership functions as

GA is used to tune a 15-element vector *R*. GA is a search heuristic inspired from the process of natural selection that can perform an extensive search of a complicated *n-D* space, where n is the number of variables, to find a near optimal solution. For this research, *n = 15*. GA starts off with an initial set of random solutions also called a population of individuals, the size of which is pre-defined. There are two main operators in GA viz., crossover and mutation.

and *T2*

<sup>1</sup> *sinθ*<sup>1</sup> + *l*

<sup>1</sup> *cosθ*<sup>1</sup> + *l*

<sup>2</sup> cos(*θ*<sup>1</sup> <sup>−</sup> *<sup>θ</sup>*2) <sup>+</sup> *<sup>m</sup>*<sup>2</sup> *<sup>L</sup>*<sup>1</sup> *<sup>L</sup>*<sup>2</sup> *<sup>θ</sup>*̇

+*<sup>m</sup>*<sup>2</sup> *gL*<sup>2</sup> *sinθ*<sup>2</sup> <sup>=</sup> <sup>0</sup> (6)

+(*m*<sup>1</sup> <sup>+</sup> *<sup>m</sup>*2) *gL*<sup>1</sup> *sinθ*<sup>1</sup> <sup>=</sup> <sup>0</sup> (5)

<sup>1</sup> cos(*θ*<sup>1</sup> <sup>−</sup> *<sup>θ</sup>*2) <sup>−</sup> *<sup>m</sup>*<sup>2</sup> *<sup>L</sup>*<sup>1</sup> *<sup>L</sup>*<sup>2</sup> *<sup>θ</sup>*̇

are assumed to be concentrated at the joints.

<sup>2</sup> *sinθ*<sup>2</sup> (3)

<sup>2</sup> *cosθ*<sup>2</sup> (4)

act at the joints are

and *T2*

2 2

sin(*θ*<sup>1</sup> − *θ*2)

. In order to reduce the computational com-

1 2 sin(*θ*<sup>1</sup> − *θ*2)

**Figure 2.** Flowchart showing the genetic fuzzy logic methodology used for designing controllers for the inverted double pendulum problem [13].

The crossover requires two individuals and some portion of the two solution vectors are interchanged to obtain two child individuals. In a mutation, some values in a chosen individual are arbitrarily changed to obtain a new individual. The cost functions of all the resulting individuals are evaluated and the ones with lower cost values have higher probability of moving onto the next generation.

The first 9 elements in the vector, *R(1–9)*, represent the rules as shown in **Table 1** and *R(10–15)* represent the boundaries of the membership functions as shown in **Figure 3**. The membership functions are assumed to be symmetric around zero. *R(1–9)* are integers with values from one to three. One, two and three represent negative (N), zero (ZO) and positive (P) membership functions for the inputs, respectively.

For this research, we use centroid defuzzification to obtain the crisp output values. The rulebase is assumed to be same for both the controllers T1 and T2. AND operator connects the inputs *θ* and *θ*̇ . For example,


**Table 1.** GA string values assigned to the rulebase during training.

*f* = ∫

**5. Numerical results and discussion**

*m*<sup>1</sup> = 0.1*kg*

*m*<sup>2</sup> = 0.1*kg*

*l*

*l*

to the inputs.

̇ **θ**

**5.1. FIS tuned without noise**

*5.1.1. With zero initial angular velocity*

close to 10 s to settle. The response for *θ<sup>2</sup>*

**Table 2.** Rulebase obtained after training [13].

0 *T* (*θ*<sup>1</sup> <sup>2</sup> + *θ*<sup>2</sup> <sup>2</sup> + *θ*̇ 1 2 + *θ*̇ 2 2

<sup>1</sup> = 1*m*

<sup>2</sup> = 1*m*

The FISs are tuned for 2 cases: (1) Without noise and (2) With 5% measurement noise applied

The rulebase obtained after tuning is shown in **Table 2**. The membership function boundaries

The system response, with zero initial angular velocity, is shown in **Figure 4**. The system was tested for different starting positions and in each case, the response settles within 5 s. Settling time is the time it takes the response to settle within an absolute value of 0.01 rad. The genetic fuzzy controller works well even when it is subjected to noise in the angle measurements. The responses for 5 and 10% noise are shown in **Figure 5**. For the 5% noise scenario shown in

**N ZO P**

**Figure 5(a)**, the controller brings the system to settle in a very smooth manner. Both *θ<sup>1</sup>*

The system response is simulated for the following parameter values:

are obtained as *R(10,15) = [0.5642 8.3738 7.1121 1.0264 4.2160 3.1641].*

settle within 5 s. In the case of 10% noise shown in **Figure 5(b)**, *θ<sup>1</sup>*

N P P ZO ZO P ZO N P ZO N N

)*dt* (7)

http://dx.doi.org/10.5772/intechopen.78786

33

Development of a Genetic Fuzzy Controller and Its Application to a Noisy Inverted Double…

and *θ<sup>2</sup>*

takes

settles within 5 s, but *θ<sup>2</sup>*

also shows a slight oscillation before settling down.

**Figure 3.** GA string values assigned to the input and output membership function boundaries for FIS1 [13].

*If θ*<sup>1</sup> *is N AND is P*, *thenT* 1 *is R*(3).

The cost function that needs to be minimized by GA is given in Eq. (7). Since the cost function is an integral over time, it ensures that the system settles to the inverted position quickly. In our simulations, the simulation is performed for 5 s and hence *T = 5*.

Development of a Genetic Fuzzy Controller and Its Application to a Noisy Inverted Double… http://dx.doi.org/10.5772/intechopen.78786 33

$$f = \int\_0^{\frac{\pi}{2}} (\boldsymbol{\Theta}\_1^2 + \boldsymbol{\Theta}\_2^2 + \dot{\boldsymbol{\Theta}}\_1^2 + \dot{\boldsymbol{\Theta}}\_2^2) dt\tag{7}$$
