Uncertain Inference Control for Balancing an Inverted Pendulum Yuan Gao Department of Mathematical Sciences, Tsinghua University, Beijing 100084, China
[email protected]
Abstract Fuzzy inference control uses fuzzy sets to describe the antecedents and consequents of If-Then rules. However, most surveys show the antecedents and consequents are uncertain sets rather than fuzzy sets. This fact provides a motivation to invent an uncertain inference control method. This paper gives an introduction to the design procedures of uncertain inference controller. As an example, an uncertain inference controller for balancing an inverted pendulum system is successfully designed. The computer simulation shows the developed uncertain inference controller is of good robustness. Keywords: Inference control; Uncertain set; Uncertain inference; Inverted pendulum
1
Introduction
Control theory can be roughly divided into two categories: conventional control and inference control. The conventional control theory was established in 1950s and 1960s. Wiener, Bellman, Pontryagin and Kalman made outstanding contributions on this subject. The focus of the conventional control theory is on model construction and differential or difference equations analysis. However, it may be difficult to construct a sufficiently accurate model or employ too many assumptions to solve a differential equation. Different from conventional control, the focus of the inference control is on understanding and loading inference rules to a controller. As a result, inference control avoids the too high accuracy requirement. Fuzzy inference control is an important class of inference control. In 1974, Mamdani [10] first used fuzzy logic in the control of a steam engine. The Mamdani’s inference rule opens the door of fuzzy inference control. In 1985, Takagi and Sugeno [15] proposed Takagi-Sugeno inference rule. The consequence of If-Then rule is described by a function of the antecedents to simplify the calculation. Turksen and Zhong [17], Guan and Bell [3] and Wang [18] also proposed some new fuzzy inference rules. Many other fuzzy researchers, such as Pedrycz [11], Ray and Majumder [13], Tanaka and Sano [14] and Tsukamoto [16], further enriched fuzzy inference control. An important assumption of fuzzy inference control is that the antecedents and consequents of If-Then rule are fuzzy sets.
1
However, a lot of surveys showed that this assumption is not suitable. Examples can be found in Liu’s works [6]. Liu found that if fuzzy set is employed, paradox will arise. To avoid paradox, uncertain set theory was proposed by Liu [7] in 2010. Liu proposed an uncertain inference rule and applied it to uncertain inference control. Liu [7] and Gao et al [2] completed uncertain inference rule based on uncertain set theory. An uncertain inference controller is a controller based on the uncertain inference rule. The purpose of this paper is to illustrate the design of uncertain inference controller, the procedure of which is demonstrated via an inverted pendulum system. The inverted pendulum system is a nonlinear unstable system and is widely used as a benchmark for testing control algorithms. In this paper, an inverted pendulum on a cart is successfully balanced by the uncertain inference control. The computer simulation results shows this uncertain inference controller is of good robustness. The remainder of this paper is organized as follows. In Section 2, basic concepts and properties on the uncertain set theory used throughout this paper are introduced. In Section 3, uncertain inference and uncertain system are discussed. Section 4 is the main part of this paper, where the design of uncertain inference controller for an inverted pendulum is given in detail. Besides, the result of computer simulation is analyzed. Section 5 concludes the paper with a brief summary.
2
Uncertain Set Theory
Uncertain set theory is the base of uncertain inference control. This section introduces some basic concepts and properties of uncertainty set theory. Uncertain set theory is an important part of uncertainty theory. Since uncertainty theory is a new mathematical branch, we should introduce uncertainty theory in short before uncertain set theory. Before the founding of uncertainty theory, nondeterministic phenomenon was mainly modeled by probability and fuzzy theory. However, lots of surveys show that some nondeterministic phenomenon behaves neither like randomness nor fuzziness, which gave the motivation to propose uncertainty theory (see Liu [8]). Many researchers have done a lot of work in this area, such as Chen et al [1], Huang [4], Peng [12] and Zhang [20]. To learn more, the readers may reference to Liu’s works [5, 6]. Now, we turn to the uncertain set theory, and the rest of this section gives some basic concepts and properties. Definition 1. (Liu [7]) An uncertain set is a measurable function ξ from an uncertainty space (Γ, L, M) to a collection of sets of real numbers, i.e., for any Borel set B of real numbers, both of {B ⊂ ξ} = {γ ∈ Γ|B ⊂ ξ(γ)}
2
and {ξ ⊂ B} = {γ ∈ Γ|ξ(γ) ⊂ B} are events. Definition 2. (Liu [9]) An uncertain set ξ is said to have a membership function µ if for any Borel set B of real numbers, we have M{B ⊂ ξ} = inf µ(x), x∈B
M{ξ ⊂ B} = 1 − sup µ(x). x∈B c
The above equations will be called measure inversion formulas. Let ξ be an uncertain set with membership function µ, and let x0 be a point such that µ(x0 ) = 1. Then the expected value of ξ is 1 E[ξ] = x0 + 2
Z
+∞
x0
1 µ(x)dx − 2
Z
x0
µ(x)dx
−∞
provided that at least one of the two integrals is finite. By a triangular uncertain set (Figure 1), we mean the uncertain set fully determined by the triplet (a, b, c) of crisp numbers with a < b < c, whose membership function is x−a , if a ≤ x ≤ b µ(x) = b − a x−c , if b ≤ x ≤ c. b−c
It is easy to verify that the triangular uncertain set ξ = (a, b, c) has an expected value E[ξ] =
a + 2b + c . 4
µ(x) 6 1
S S S S S S S - x 0 a b c Figure 1: Triangular Membership Function
3
Uncertain Inference and Uncertain System
Inference mechanism is the key part of inference control. In fuzzy inference control, the main inference mechanisms include Zadeh’s CRI method [19], Mamdani’s inference rule [10] and Takagi-Sugeno inference rule [15]. In the If-Then rules of these inference mechanisms, the antecedents and consequences are 3
thought to be fuzzy sets. As mentioned before, through surveys, we find they are not fuzzy sets. Actually, it is better to employ uncertain sets to describe them. In this section, we first introduce properties of uncertain inference. Uncertain inference is a process of deriving consequences from uncertain knowledge or evidence via the tool of conditional uncertain set. Liu [7] gave a basic inference rule with one antecedent and with one If-Then rule. Gao et al [2] extended this basic inference rule to the form with multiple antecedents and with multiple If-Then rules. Liu’s Inference Rule (Gao, Gao and Ralescu [2]) Let X, Y and Z be concepts. Assume rules “if X is ξi and Y is ηi then Z is τi for i = 1, 2. From X1 is a constant a and Y is a constant b we infer that Z is an uncertain set τ∗ =
c1 · τ1∗ + c2 · τ2∗ c1 + c2
(1)
where c1 = M{(a ∈ ξ1 ) ∩ (b ∈ η1 )}, τ1∗ = τ1 |(a∈ξ1 )∩(b∈η1 ) , c2 = M{(a ∈ ξ2 ) ∩ (b ∈ η2 )}, τ2∗ = τ2 |(a∈ξ2 )∩(b∈η2 ) . The inference rule is represented by Rule 1: If X is ξ1 and Y is η1 then Z is τ1 Rule 2: If X is ξ2 and Y is η2 then Z is τ2 From: X is a and Y is b Infer: Z is τ ∗ determined by (1)
Obviously, Liu’s inference rule can be easily extended to multiple case with three or more antecedents. However, Liu’s inference rule is very theoretical. Usually, we employ Z = E[τ ∗ ] instead of Z = τ ∗ in a controller, where E[τ ∗ ] =
c1 · E[τ1∗ ] + c2 · E[τ2∗ ] . c1 + c2
If ξi , ηi , τi are independent uncertain sets with membership functions µi , λi , νi , i = 1, 2, respectively, then τi∗ has a membership functions
νi (y) , if νi (y) < ci /2 ci νi∗ (y) = νi (y) + ci − 1 , if νi (y) > 1 − ci /2 ci 0.5, otherwise
and ci are constants determined by ci = µi (a) ∧ λi (b), for i = 1, 2, respectively.
4
(2)
4
The Design of Uncertain Inference Controller
An uncertain inference controller is a controller based on Liu’s inference rule. Showing the method how to design an uncertain inference controller is the purpose of this paper. Generally speaking, the design of an uncertain inference controller can be divided into the following 5 steps: Step 1: Understand the behavior of control object; Step 2: Choose proper inputs and outputs for the controller; Step 3: Build the rule base; Step 4: Choose proper uncertain sets for the inputs and outputs; Step 5: Construct the uncertain inference controller by employing Liu’s inference rule as the inference mechanism. In this section, we employ an inverted pendulum system to illustrate the design process.
4.1
Introduction of the inverted pendulum system
Inverted pendulum system is widely used as a benchmark for testing control algorithms. The inverted pendulum system we will deal with is shown in Figure 2.
u
˙ s θ θ 9 BBBB 9 BB BB BB 2l BB BB BB BBs ~
~
Figure 2: Inverted Pendulum on a Cart Before modeling, consider notations in the following table. Table 1: Symbols of inverted pendulum model Symbols
Values
Unit
λ1
1
kg
The mass of the cart
λ2
0.5
kg
The mass of the inverted pendulum
l
0.5
m
The half-length of the inverted pendulum
θ
rad
θ˙
rad/s
u
N
g
9.8
m/s2
Description
The angle that the inverted pendulum makes with the vertical The angular velocity of the inverted pendulum The force input that moves the cart The acceleration of gravity 5
The inverted pendulum starts with some angle off the vertical (i.e. θ 6= 0) or some nonzero angular velocity (i.e. θ˙ = 6 0). Our goal is to balance the inverted pendulum in the upright position, that is θ = 0. Here, we set that the positive direction of angle θ is the counterclockwise and the positive direction of force u is the right. Ignoring friction, the dynamic behavior of inverted pendulum shown in Figure 2 can be described as
g sin θ + cos θ(u − λ2 lθ˙2 sin θ) . θ¨ = 4 λ2 cos2 θ − l 3 λ1 + λ2
(3)
In this inference controller, we choose the “angle” θ and “angular velocity” θ˙ as the inputs, the “force” u as output. The uncertain inference control system for this model is shown in Figure 3. Inverted Pendulum ? ˙ θ(t) θ(t)
-
Inference Rule 6 Rule Base
- u∗ (t)
-
u(t) = E[u∗ (t)]
- u(t)
Figure 3: An Uncertain Inference Controller for Inverted Pendulum on a Cart
4.2
Rule base and membership function
For this inference controller, the inputs (“angle” and “angular velocity”) and the output (“force”) can all be described by the following five uncertain sets, the abbreviation of which is also listed behind: “negative large in size”
NS
“negative small in size”
NL
“zero in size”
Z
“positive small in size”
PS
“positive large in size”
PL
Obviously, in the situation shown in Figure 2, the inverted pendulum has a small counterclockwise angle and a small counterclockwise angular velocity. In order to balance it, we should exert a large force to the left on the cart. Using the above symbols, we have the following If-Then rule: If angle is positive small and angular velocity is positive small, Then force is negative large. There are two inputs in each If-Then rule, and the domain of each input is made of five uncertain sets. Thus, we have 5 × 5 = 25 possible rules. As the If-Then rule above, the other 24 If-Then rules can be given in a similar way after simple mechanical analysis. The rule base is usually given in a rule table. For this controller, the rule base is just listed in Table 2.
6
Table 2: Table of Rule Base @ θ˙ @ NL θ @@
NS
Z
PS
PL
NL
PL
PL
PL
PS
Z
NS
PL
PL
PS
Z
NS
Z
PL
PS
Z
NS
NL
PS
PS
Z
NS
NL
NL
PL
Z
NS
NL
NL
NL
The first row of Table 2 is the domain of “angular velocity” and first column is the domain of “angle”. The underlined “NL” in Table 2 represents the If-Then rule quantifying the situation in Figure 2. Now, our work is to choose appropriate uncertain sets for the input and output. The uncertain set we choose should be fairly accurate in reflecting the real situation and also be convenient for calculation. In this controller, the triangular uncertain set is suitable. For this inverted pendulum model, all the uncertain sets for “angle”, “angular velocity” and “force” are respectively given in Figure 4, Figure 5 and Figure 6. NL
NS Z6 PS PL 1 J
J
J
J J
J
J
J
J
J
J
J
J J J
J
J
J
J
J J
J
J
J
J
Jπ
J
J π − π2 h1 − π4 h1 4 h1 2 h1
angle (rad.)
Figure 4: Membership Functions for the Angle NL
NS Z6 PS PL 1 J
J
J
J
J
J
J
J
J
J
J
J
J
J
J J
J
J
J
J J
J
J
J
J
J
J
Jπ π − π4 h2 − π8 h2 8 h2 4 h2
velocity (rad/s) Figure 5: Membership Functions for the Angular Velocity NL NS Z6 PS PL 1
J
J
J
J
J
J
J
J
J
J
J
J
J
J
J
J
J
J
J
J
J
J
J
J J
J
J
J
J J
J
J
J
J J −30k −20k −10k 10k 20k 30k force (N ) Figure 6: Membership Functions for the Force 7
In the membership functions, h1 , h2 and k are scaling gains for “angle”, “angular velocity” and “force”, respectively.
4.3
How to obtain the value of u
Given an arbitrary input of “angle” and “angular velocity”, it may match more than one If-Then rules, each of which gives different output of “force”. Then how can we obtain the value of u from these outputs? Here, we obtain the value of u by u = E[u∗ ], where u∗ is the uncertain set got by Liu’s inference rule. Example 1: Assume that the scaling gains are set as h1 = 1, h2 = 1, k = 2. The input is (π/8, π/32), which is shown in Figure 7. NL
NL
NS Z6 PS PL 1
J J
J
J
J
J
J
J
J
J
J
J
1 J
J
J
J
2
J
J
J
J J
J
J
J
J
Jπ
J J π π − π2 − π4 8 4 2 NS Z6 PS PL 1 J
J
J
J
J
J
43J
J
J
J
J
J
J J
J
J
J
J
J 1 J
J
J
J J 4
J Jπ
J
J
π π − π4 − π8 32 8 4
angle (rad.)
velocity (rad/s) Figure 7: Input Membership Functions with Input Values It is easy to see that input (π/8, π/32) matches four If-Then rules, which are underlined in the following table. Table 3: Matching of Rule Base @ θ˙ @ NL θ @@
NS
Z
PS
PL
NL
PL
PL
PL
PS
Z
NS
PL
PL
PS
Z
NS
Z
PL
PS
Z
NS
NL
PS
PS
Z
NS
NL
NL
PL
Z
NS
NL
NL
NL
According to formula (2), we can easily obtain
8
Z:
c1 =
1 2
∧
3 4
= 12 ,
E[u∗1 ] = 0,
NS:
c2 =
1 2
∧
1 4
= 14 ,
E[u∗2 ] = −10 × k = −20,
NS:
c3 =
1 2
∧
3 4
= 12 ,
E[u∗3 ] = −10 × k = −20,
NL:
c4 =
1 2
∧
1 4
= 14 ,
E[u∗4 ] = −20 × k = −40.
Thus, we have the output
u=
50 c1 · E[u∗1 ] + c2 · E[u∗2 ] + c3 · E[u∗3 ] + c4 · E[u∗4 ] =− . c1 + c2 + c3 + c4 3
This means that if “angle” is π/8 and “angular velocity” is π/32, then “force” should be −50/3.
4.4
Computer simulation
In this section, we will realize this uncertain inference controller by computer simulation. We set the scaling gains as h1 = 1, h2 = 0.1 and k = 5. The mass of the cart is 1kg, the mass of the inverted pendulum is 0.5kg and the half-length of the inverted pendulum is 0.5m, that is λ1 = 1kg, λ2 = 0.5kg and l = 0.5m. Substitution of λ1 , λ2 , l and the acceleration of gravity g = 9.8m/s2 into differential equation (3), we obtain
9.8 sin θ + cos θ(u − 0.25θ˙ 2 sin θ) θ¨ = . 2 0.5 34 − cos3 θ
(4)
˙ the second-order differential equation (4) is equivalent to the following Assuming θ1 = θ and θ2 = θ, first-order differential equations, θ˙1 = θ2 9.8 sin θ1 + cos θ1 (u − 0.25θ22 sin θ1 ) θ˙2 = . 2 0.5 4 − cos θ1
(5)
and obtain the difference equations, θ1 (ns + s) = s · θ2 (ns) + θ1 (ns) 9.8 sin θ1 (ns) + cos θ1 (ns)[u − 0.25θ22 (ns) sin θ1 (ns)] h i θ (ns + s) = s · + θ2 (ns), 2 2 0.5 4 − cos θ1 (ns)
(6)
3
3
For this simulation, we use Euler’s method to approximate the derivative variables in equations (5),
3
3
where s is the integration step size. In this problem, we choose s = 0.001.
In this uncertain inference controller, the system is observed every 0.02 second, that is, the force u is ˙ renewed every 0.02 second. If the initial condition is θ(0) = 0.3 and θ(0) = 0.2, that is θ1 (0) = 0.3 and θ2 (0) = 0.2, Figure 8 shows the simulation result.
9
0.35
5
0.3
0
Force(N)
Angle(rad)
0.25 0.2 0.15
−10 −15
0.1
−20
0.05 0
−5
0
0.5
1
1.5
2
2.5
−25
3
0
0.5
1
Time(s)
1.5
2
2.5
3
Time(s)
˙ Figure 8: Computer simulation when θ(0) = 0.3, θ(0) = 0.2. Under extreme situations, it also works well, which means that this uncertain inference controller is ˙ of good robustness. We set that θ(0) = −π/2 and θ(0) = 1 , that is, the inverted pendulum is horizontal and has a large angular velocity down. Figure 9 shows the simulation result. 3
100
2
80 60
Force(N)
Angle(rad)
1 0 −1
40 20
−2
0
−3 −4
0
0.5
1
1.5
2
2.5
−20
3
0
0.5
1
Time(s)
1.5
2
2.5
3
Time(s)
˙ Figure 9: Computer simulation when θ(0) = −π/2, θ(0) = 1. ˙ Set θ(0) = π and θ(0) = 0, that is, the inverted pendulum is stopping in hanging position. Figure 10 shows the simulation result. 4
100
3 50
1
Force(N)
Angle(rad)
2
0 −1 −2
0
−50
−3 −4
0
0.5
1
1.5
2
2.5
3
−100
Time(s)
0
0.5
1
1.5
2
2.5
3
Time(s)
˙ Figure 10: Computer simulation when θ(0) = π, θ(0) = 0. If random noise is imposed both on the inputs (‘angle” and “angular velocity”) and output (“force”), ˙ what will happen? Set θ(0) = 0.3 and θ(0) = 0.2. Computer simulation gives the following result.
10
0.35
5
0.3
0
0.2
Force(N)
Angle(rad)
0.25
0.15 0.1
−5 −10 −15
0.05 −20
0 −0.05
0
1
2
3
4
5
6
−25
0
1
2
Time(s)
3
4
5
6
Time(s)
˙ Figure 11: Computer simulation when θ(0) = 0.3, θ(0) = 0.2 if random noise is imposed. In Figure 11, the inverted pendulum return to the upright position almost as quickly as in Figure 9. After returning the upright position, the inverted pendulum swings in small-angle around θ = 0.
5
Conclusion
Different from fuzzy inference control, uncertain inference control is a new control method. This paper designed an uncertain inference controller for an inverted pendulum system and successfully balanced it in computer simulation. The simulation results showed this uncertain inference controller is of good robustness.
Acknowledgments This work was supported by National Natural Science Foundation of China Grant No.60874067 and No. 91024032.
References [1] Chen XW and Liu B, Existence and uniqueness theorem for uncertain differential equations, Fuzzy Optimization and Decision Making, Vol.9, No.1, 69-81, 2010. [2] Gao X, Gao Y and Ralescu DA, On Liu’s inference rule for uncertain systems, International Journal of Uncertainty, Fuzziness and Knowledge-Based Systems, Vol.18, No.1, 1-11, 2010. [3] Guan JW and Bell DA, Approximate reasoning and evidence theory. Information Sciences, Vol.96, 207-235, 1997. [4] Huang XX, Mean-risk model for uncertain portfolio selection, Fuzzy Optimization and Decision Making, Vol.10, No.1, 71-89, 2011. [5] Liu B, Uncertainty Theory, 2nd ed., Springer-Verlag, Berlin, 2007. [6] Liu B, Uncertainty Theory: A Branch of Mathematics for Modeling Human Uncertainty, Springer-Verlag, Berlin, 2010.
11
[7] Liu B, Uncertain set theory and uncertain inference rule with application to uncertain control, Journal of Uncertain Systems, Vol.4, No.2, 83-98, 2010. [8] Liu B, Why is there a need for uncertainty theory? Journal of Uncertain Systems, Vol.6, No.1, 3-10, 2012. [9] Liu B, Membership functions and operational law of uncertain sets, Fuzzy Optimization and Decision Making, to be published. [10] Mamdani EH, Applications of fuzzy algorithms for control of a simple dynamic plant, Proceedings of IEEE, Vol.121, No.12, 1585-1588, 1974. [11] Pedrycz W, Fuzzy Control and Fuzzy Systems, 2nd ed., Wiley, New York, 1993. [12] Peng ZX and Iwamura K, A sufficient and necessary condition of uncertainty distribution, Journal of Interdisciplinary Mathematics, Vol.13, No.3, 277-285, 2010. [13] Ray KS and Majumder DD, Application of circle criteria for stability analysis of linear SISO and MIMO syatem associated with fuzzy logic controllers. IEEE Transactions on Systems, Man and Cybernatics, Vol.14, No.2, 345-349, 1984. [14] Tanaka K and Sano M, Stability analysis and design of fuzzy control systems, Fuzzy Sets and Systems, Vol.45, 135-156, 1992. [15] Takagi T and Sugeno M, Fuzzy identification of system and its applications to modeling and control, IEEE Transactions on Systems, Man and Cybernatics, Vol.15, No.1, 116-132, 1985. [16] Tasukamoto Y, Fuzzy logic based on Lukasiewicz logic and its application to diagnosis and control, Ph.D. Dissertation, Tokyo Institute of Technology, 1979. [17] Turksen IB and Zhong Z, An approximate analogical reasoning approach based on similarity measures. IEEE Transactions on Systems, Man and Cybernetics, Vol.18, No.6, 1049-1056, 1988. [18] Wang GJ, On the logic foundation of fuzzy reasoning, Information Sciences, Vol.117, 47-88, 1999. [19] Zadeh LA, Outline of a new approach to the analysis of complex systems and decision processes, IEEE Transactions on Systems, Man, and Cybernetics, Vol.3, No.1, 28-44, 1973. [20] Zhang ZM, Some discussions on uncertain measure, Fuzzy Optimization and Decision Making, Vol.10, No.1, 31-43, 2011.
12