Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
EE7207 CA2
1. In this problem, we develop a simple model of an inverted pendulum system. In this system, illustrated in Figure
1.1, a rod is hinged on top of a cart. The cart is free to move in the horizontal plane, and the objective is to balance
the rod in the vertical position. Without any control action u on the cart, if the rod were initially in the vertical
position then even the smallest external disturbance on the cart would make the rod lose balance and hence the
system is unstable. The objective is to design control action u so that the rod is maintained in the vertical position,
i.e. θ = 0.
Figure 1.1 Inverted Pendulum on a Cart
The following model parameters are defined to develop the mathematical model of the system: M is the mass of
the cart; m is the mass of the pendulum assumed to be located on the pendulum tip, L is the length of the pendulum,
x is the displacement made by the cart, I is the inertial of the pendulum, θ is the angle in radians of the pendulum
measured from the vertical and is positive in clockwise direction, b is the friction of the cart, u is the control force
applied to the cart.
The mathematical model of the system can be derived from the free-body diagrams of the cart and the pendulum
shown in Figure 1.2. Consider first the motion of the cart in the horizontal direction:
mx u H bx= − − (1)
By summing the forces along the horizontal for the pendulum, we obtain the following equation of motion
( )
2
2
2
sin cos sin
d
H m x L mx mL mL
dt
= + = + − (2)
Substitute Equation (2) into Equation (1), we obtain,
( ) 2cos sinM m x bx mL mL u + + + − = (3)
Figure 1.2 Free-body diagrams of the cart and the pendulum
The second equation of motion is obtained by summing all the forces in the vertical direction (note that θ decreases
as y increases) to the pendulum.
( )
2
2
2
cos sin cos
d
V mg m L mL mL
dt
− = − = + (4)
Multiplying Equation (2) by cos θ and Equation (4) by sin θ, and then adding them, we have
sin cos sin cosV H mg mL mx + − = + (5)
Also, taking moment about the c.g. of the pendulum, we get
sin cosVL HL I − − = (6)
Substituting Equation (6) into Equation (5) results in
( )2 sin cosmL I mgL mLx + + = − (7)
Equations (3) and (7) are the equations of motion describing the nonlinear behaviour of the inverted pendulum on
a cart.
For this problem, we shall assume the following parameters:
M = 1.5 kg
m = 0.3 kg
L = 0.3 m
b = 0.05 Ns/m
I = 0.006 kg m2
g = 9.81 m/s2
a) Let us use Mamdani method to design a fuzzy controller for the inverted pendulum on a cart as shown in Figure
1.3. The input to the controller is the pair ( ), . Let us take the input space to be X x Y, where X and Y are
intervals representing radians for and radians per second for . The fuzzy controller output space U for u is
force in unit of Newtons. The plant dynamics is described by Equations (3) and (7).
Figure 1.3 Fuzzy Controller
The linguistic labels are modelled as fuzzy subsets of the spaces X, Y and U by specifying their membership
functions. For example, these linguistic labels correspond to negative big (NB), negative medium (NM), negative
small (NS), positive small (PS), positive medium (PM) and positive big (PB) as shown in Figures 1.4, 1.5 and 1.6.
Figure 1.4 Fuzzy Sets for Angle
Figure 1.5 Fuzzy Sets for Angular Rate
Figure 1.6 Fuzzy Sets for Force u
With 6 membership functions for each of X and Y, we can formulate rules of the form:
: If is and is then is
where , and are the fuzzy subsets of , and depicted above.
j j j j
j j j
R A B u C
A B C X Y U
Knowledge of the system behaviour allows us to formulate a set of 36 general rules as shown in the below table
called a fuzzy associative memory or decision table:
Table 1.1 Look-Up Decision Table
Design the membership functions in Figure 1.4 to Figure 1.6 (for example, by using the minimum and maximum
to be +/- π/2; the minimum and maximum to be +/- 30/180*π, and the minimum and control u to be +/- 10N
and then adjusting it accordingly) and the fuzzy associative memory rules in Table 1.1, design the fuzzy logic
controller in Figure 1.3 to ensure that the pendulum returns to vertical, θ=0 for the following 4 initial conditions:
No. Angle
(rad)
Angular Velocity
(rad/s)
Distance
x (m)
Velocity
x (m/s)
1 -5/180*π -0.5/180*π 0 0
2 5/180*π -1/180*π 10 0
3 5/180*π 1/180*π 0 -0.5
4 -10/180*π 0 20 1
Table 1.2 Different Initial Conditions
Try to adjust the membership function to achieve an allowable pendulum overshoot of 20 degrees and it should
target to settle in under 5 seconds. Plot the angle, angular rate, distance, velocity and the fuzzy controller output
for each case.
b) One potential solution to reduce the number of rules in Table 1.1 is to introduce one additional fuzzy set, namely
approximately zero (AZ) for each of the variable , and .u The resulting reduced 7 rules are as follows:
Table 1.3 Reduced Look-Up Decision Table
Design the appropriate membership functions for the fuzzy associative memory rules in Table 1.3 to generate a
fuzzy controller in Figure 1.3 and show the results for the 4 initial conditions shown in Table 1.2.
2. Clustering is one of the most fundamental issues in pattern recognition. It plays a key role in searching for structures
in data. Given a finite set of data, X, the problem of clustering in X is to find several cluster centres that can properly
characterize relevant classes of X. In classical cluster analysis, these classes are required to form a partition of X
such that the degree of association is strong for data within blocks of the partition and weak for data in different
blocks. However, this requirement is too strong in many practical applications, and it is thus desirable to replace it with
a weaker requirement. When the requirement of a crisp partition of X is replaced with a weaker requirement of a
fuzzy partition or a fuzzy pseudopartition on X, we refer to the emerging problem area as fuzzy clustering. Fuzzy
pseudopartitions are often called fuzzy c partitions, where c designates the number of fuzzy classes in the partition.
There are two basic methods of fuzzy clustering. One of them, which is based on fuzzy c-partitions, is called a fuzzy c-
means (FCM) clustering method. The other method, based on fuzzy equivalence relations, is called a fuzzy
equivalence relation-based hierarchical clustering method.
Let X = {x1, x2,... , xn} be a set of given data. A fuzzy pseudopartition or fuzzy c-partition of X is a family of fuzzy
subsets of X, denoted by 1 2, , , cP A A A= , which satisfies
( )
1
1 for all 1,2, ,
c
i k
i
A x k n
=
= and
( )
1
0 for all 1,2, ,
n
i k
k
A x n i c
=
The goal of the fuzzy c-means (FCM) clustering method is to find a fuzzy pseudopartition P that minimizes the
performance index Jm(P) given by
( ) ( )
( )
2
1 1
1
where (13.1)
1 (13.2)
mn c
m i k k i
k i
n
m
k i k
k
i
J P A x x v
m
x A x
v
= =
=
= −
=
( )
1
, 1, 2, , are the cluster centres (13.3)
n
m
i k
k
i c
A x
=
=
That is, the clustering problem is an optimization problem. The following fuzzy c-means algorithm was developed
by Bezdek [1981] for solving this optimization problem.
( ) ( )
( ) ( )1 1
1,2, , , 1,2,
max
t t t t
i k i k
k n i c
P P A x A x
+ +
− = −
(a) Apply Bezdek fuzzy c-means (FCM) clustering algorithm, as shown above, for the following set of data with
15 points each with 2 features:
Table 2.1
Assume that we want to determine a fuzzy pseudopartition with two clusters (i.e., c = 2). Assume further that we
choose m = 1.25, = 0.01; in Equation (13.1) is the Euclidean distance, and the initial fuzzy pseudopartition
is
( ) 0 1 2,P A A= with
1 1 8 9 15
2 1 8 9 15
0.8 / 0.8 / 0.2 / 0.2 / ,
0.2 / 0.2 / 0.8 / 0.8 / .
A x x x x
A x x x x
= + + + + +
= + + + + +
Determine the cluster centres 1 2 and v v after convergence of the iteration procedure.
(b) Next, we shall consider the classical hard c-means (HCM) approach.
In classical HCM, let ( )
iij A j
x denote the jth data point in the ith class cluster. Now define a partition
matrix U with c rows and n columns, comprising elements ( ) 1,2, , ; 1,2, , .ij i c j n = = We define a
hard c-partition space for X as the following matrix set
1 1
M U 0,1 , 1, 0
c n
c ij ik ik
i k
n
= =
= =
,
Any matrix U Mc is a hard c-partition. The cardinality (number of distinct U ) of any hard c-partition, Mc , is
( )M
1
1
1
!c
c
c i n
i
c
i
ic
−
=
= −
,
where the expression
c
i
is the binomial coefficient of c things taken i at a time. One of the more popular HCM
algorithm is known as a within-class sum of squared errors approach using a Euclidean norm to characterize
distance. This algorithm uses an objective function of the following form:
( ) ( )
2
1 1
min U, , (13.4)
n c
ik ik
k i
J v d
= =
=
dik is a Euclidean distance measure given as follows
( )
1/2
2
1
m
ik k i kj ij
j
d x v x v
=
= − = −
between the kth data sample
m
kx and the ith cluster centre
m
iv , which is given by
1
1
, 1, ,
n
ik kj
k
ij n
ik
k
x
v j m
=
=
= =
The iterative optimization algorithm (Bezdeck 1981) to solve the problem (13.4) is as follows:
Apply the above iterative optimization algorithm to determine the hard c-cluster solution for the dataset given in
Problem 2(a).
(c) There are two popular methods, among many others, to defuzzify the final fuzzy partitions,
1
c
A
U
A
=
, that
is, for hardening the fuzzy classification matrix. This defuzzification may be required in the ultimate assignment
of data to a particular class. These two methods are called the maximum membership method and the nearest
centre classifier.
In the max membership method, the largest element uik in each column of the partition matrixU is assigned a
membership of unity and all other elements in each column are assigned a membership value of zero. In
mathematical terms, if the largest membership in the kth column is uik, , then xk belongs to class i, that is, if
1,2, ,
max 1; 0 for
for 1,2, , , 1, 2, ,
ik jk jk
j c
u u u j i
j c k n
= = =
In the nearest centre classifier, each of the data points is assigned to the class that it is closest to; that is, the
minimum Euclidean distance from a given data point and the cluster centres 1 2 and v v dictate the class
assignment of that point.