180214 Lecture 2 Fuzzy Control II
180214 Lecture 2 Fuzzy Control II
Cognitive Robotics
3mE, Delft University of Technology, The Netherlands
07-04-2018
Outline
3 Data-driven construction.
2 / 81
Singleton Fuzzy Model
If x is Ai then y = bi
Inference/defuzzification:
PK
—Ai (x)bi
y = Pi=1
K
i=1 —Ai (x)
3 / 81
Piece-wise Linear Approximation
y y = f(x)
b2
b4
b3
b1
x
A1 A2 A3 A4
1
4 / 81
Linear Mapping with a Singleton Model
p
X
y = kT x + q = kj xj + q
j=1
• Triangular partition:
A1 A2 A3 A4 A5
a1 a2 a3 a4 a5
5 / 81
Takagi–Sugeno (TS) Fuzzy Model
If x is Ai then yi = ai x + bi
K
X K
X
—Ai (x)yi —Ai (x)(ai x + bi )
i=1 i=1
y = K
= K
X X
—Ai (x) —Ai (x)
i=1 i=1
6 / 81
Input-Output Mapping of the TS Model
y
y=
a2
b1
x+
x+
b2
a1
y=
y = a3 x + b3
x
Small Medium Large
µ
x
Consequents are approximate local linear models of the system.
7 / 81
TS Model is a Quasi-Linear System
K
X K
X
—Ai (x)yi —Ai (x)(aiT x + bi )
i=1 i=1
y = K
= K
X X
—Aj (x) —Aj (x)
j=1 j=1
8 / 81
TS Model is a Quasi-Linear System
K
X K
X
—Ai (x)yi —Ai (x)(aiT x + bi )
i=1 i=1
y = K
= K
X X
—Aj (x) —Aj (x)
j=1 j=1
K K
!
X X
y = ‚i (x)aiT x+ ‚i (x)bi
i=1 i=1
| {z } | {z }
a(x)T b(x)
8 / 81
TS Model is a Polytopic System
Parameter space
Rules
Antecedent space
Big
Medium
Polytope
a2
Small
x2 a1
Small Medium Big
Parameters of a consequent
function: y = a1x1 + a2x2
x1
9 / 81
Construction of Fuzzy Models
10 / 81
Modeling Paradigms
11 / 81
Parameterization of nonlinear models
• polynomials, splines
• look-up tables
• fuzzy systems
• neural networks
• (neuro-)fuzzy systems
• radial basis function networks
• wavelet networks
• ...
12 / 81
Modeling of Complex Systems
Data Model
- static
- dynamic
13 / 81
Modeling of Complex Systems
Data Model
- static
- dynamic
Prior knowledge
- partial models
- stability
- gain, nonlinearity
- settling time
13 / 81
Modeling of Complex Systems
13 / 81
Building Fuzzy Models
Knowledge-based approach:
• expert knowledge → rules & membership functions
• fuzzy model of human operator
• linguistic interpretation
14 / 81
Building Fuzzy Models
Knowledge-based approach:
• expert knowledge → rules & membership functions
• fuzzy model of human operator
• linguistic interpretation
Data-driven approach:
• nonlinear mapping, universal approximation
• extract rules & membership functions from data
14 / 81
Knowledge-Based Modeling
15 / 81
Wear Prediction for a Trencher
Goal: Given the terrain properties, predict bit wear and production rate
of trencher.
16 / 81
Why Knowledge-Based Modeling?
17 / 81
Dimensionality Problem: Hierarchical Structure
18 / 81
Trencher: Fuzzy Rule Bases
Orientation
Rock strength
Defuzzification
Joint set 1
Rule base 1 Block size Production rate
Joint set 2 (numerical output)
(block size)
Joint set 3
19 / 81
Example of Membership Functions
VS SM ME LA VL Low Medium High
1 1
Membership grade
Membership grade
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.2 0.4 0.6 0.8 1 0 50 100 150 200
VL LO ME HI VH
1
Membership grade
0.8
0.6
0.4
0.2
0
0 1 2 3 4 5
Bit consumption [bit/m^3]
20 / 81
Output: Prediction of Production Rate
21 / 81
Data-Driven Construction
22 / 81
Structure and Parameters
Structure:
• Input and output variables. For dynamic systems also the
representation of the dynamics.
• Number of membership functions per variable, type of membership
functions, number of rules.
Parameters:
• Consequent parameters (least squares).
• Antecedent membership functions (various methods).
23 / 81
Least-Squares Estimation of Singletons
Ri : If x is Ai then y = bi
{(xk ; yk ) | k = 1; 2; : : : ; N}
• Estimate optimal consequent parameters bi .
24 / 81
Least-Squares Estimation of Singletons
25 / 81
Least-Square Estimation of TS Consequents
2 3 2 3 2 3
x1T y1 ‚i1 0 · · · 0
6 T7
6x2 7 y 6 0 ‚i2 · · · 0
6 7 6 7
6 27 7
X=6
6 .. 7 ;
7 y =6 .
6 . 7
7 ; Γi = 6 .
6 . .. .. .. 7
4 . 5 4 . 5 4 . . . .
7
5
xNT yN 0 0 ··· ‚iN
h iT
„i = aiT bi ; Xe = [X 1]
26 / 81
Least-Square Estimation of TS Consequents
h i−1
• Global LS: „ 0 = (X 0 )T X 0 (X 0 )T y
27 / 81
Least-Square Estimation of TS Consequents
h i−1
• Global LS: „ 0 = (X 0 )T X 0 (X 0 )T y
27 / 81
Antecedent Membership Functions
28 / 81
Fuzzy Clustering: Data
29 / 81
Fuzzy Clustering: Prototypes
v2
29 / 81
Fuzzy Clustering: Distance
v2
29 / 81
Fuzzy Clustering: Distance
v2
)
,2
v
zk
d(
Cluster centers (means):
v1 d(zk v, 1) zk
V= [ v1 v2 ]
29 / 81
Fuzzy Clustering: Partition Matrix
v2
)
,2
v
zk
d(
Cluster centers (means):
v1 d(zk v, 1) zk
V= [ v1 v2 ]
U=
[ ]
29 / 81
Fuzzy Clustering: Shapes
v2
)
,2
v
zk
d(
Cluster centers (means):
v1 d(zk v, 1) zk
V= [ v1 v2 ]
U=
[ ]
29 / 81
Fuzzy Clustering Problem
Find:
the fuzzy partition matrix:
V = {v1 ; v2 ; : : : ; vc }; vi ∈ Rn
30 / 81
Fuzzy Clustering: an Optimization Approach
subject to constraints:
31 / 81
Fuzzy c-Means Algorithm
Repeat:
PN m
— z
k=1 i;k k
1 Compute cluster prototypes (means): vi = P N m
k=1
—i;k
32 / 81
Fuzzy c-Means Algorithm
Repeat:
PN m
— z
k=1 i;k k
1 Compute cluster prototypes (means): vi = P N m
k=1
—i;k
32 / 81
Fuzzy c-Means Algorithm
Repeat:
PN m
— z
k=1 i;k k
1 Compute cluster prototypes (means): vi = P N m
k=1
—i;k
1
3 Update partition matrix: —ik = Pc (dik =djk )1=(m−1)
j=1
32 / 81
Distance Measures
• Euclidean norm:
• Inner-product norm:
33 / 81
Fuzzy Clustering – Demo
1 Fuzzy c-means
34 / 81
Extraction of Rules by Fuzzy Clustering
y
10
2 4 6 8 x
35 / 81
Extraction of Rules by Fuzzy Clustering
y Cluster 4
10 x
r3
8
ste
6
Clu
x
4
r2
te
2
Cluster 1 x
us
Cl
x
2 4 6 8 x
35 / 81
Extraction of Rules by Fuzzy Clustering
y Cluster 4
10 x
r3
8
ste
projection
6
Clu
x
4
r2
te
2
Cluster 1 x
us
Cl
x
Takagi-Sugeno model 2 4 6 8 x
1
m(x)
If x is A1 then y = a1x + b1
0.6
A1 A2 A3 A4
0.4
If x is A2 then y = a2x + b2
0.2
etc... 0
2 4 6 8
x
35 / 81
Extraction of Rules by Fuzzy Clustering
y
B4 y Cluster 4
10
10 x
projection
r3
8
B3
ste
6
6
Clu
4
x
4
2
B1 B2
r
te
2
2
Cluster 1 x
us
Cl
x
1
0
0.8
0.6
0.4
0.2
2 4 6 8 x
m(y)
Rule-based description:
If y is B1 then x = a1y + b1 Inverse Takagi-Sugeno model
If y is B2 then x = a2y + b2
etc...
35 / 81
Rule Extraction – Demo
36 / 81
Fuzzy Control
37 / 81
Fuzzy Control: Background
38 / 81
Parameterization of Nonlinear Controllers
Controller Process
1
0.5
theta
−0.5
1
0.5
−1
−1 0
−0.5
0 −0.5
0.5
1 −1 x
phi
Parameterizations
PL PS Z
PS Z NS
Z NS NL
39 / 81
Fuzzy System is a Nonlinear Mapping
40 / 81
Basic Fuzzy Control Schemes
41 / 81
Process Controlled by Operators
Goal (reference) Disturbances
Human u y
operator Process
42 / 81
Knowledge Acquisition
Goal (reference) Disturbances
Human u y
operator Process
Knowledge
acquisition
Fuzzy if-then
rules
42 / 81
Direct Fuzzy Control
Goal (reference) Disturbances
Fuzzy u y
controller Process
Implementation
Fuzzy if-then
rules
42 / 81
Example of Operator Knowledge
43 / 81
FLC Analogue to PID Control
r e u y
PID Process
-
44 / 81
PID Control: Internal View
e(fi )dfi + D de(t)
Rt
u(t) = P e(t) + I 0 dt
P
e u
I +
d
dt D
45 / 81
PID Control: Internal View
e(fi )dfi + D de(t)
Rt
u(t) = P e(t) + I 0 dt
P
e u
I +
d
dt D
45 / 81
Fuzzy PID Control
“ ”
e(fi )dfi; de(t)
Rt
u(t) = f e(t); 0 dt
knowledge-based
system
e u
Fuzzy
d
dt
dynamic filter
46 / 81
Fuzzy PID Control
r e Fuzzy u y
Controller Process
-
e e Du Dynamic u
Dynamic
Pre-filter òe Static map
Post-filter
De
Knowledge base
Fuzzifier Defuzzifier
Inference
47 / 81
Example: Proportional Control
r e u y
P Process
-
48 / 81
Controller’s Input–Output Mapping
u
u=Pe
49 / 81
Fuzzy Proportional Control: Rules
50 / 81
Controller’s Input–Output Mapping
u
PB
ZE
e
NB
NB ZE PB
51 / 81
Example: Friction Compensation
52 / 81
DC Motor: Model
Armature Load
Friction
K(s) 1 1
1 1
L.s+R J.s+b s
voltage angle
53 / 81
Proportional Controller
Control u
P Motor
Mux
Angle
54 / 81
Linear Control
0.15
shaft angle [rad] 0.1
0.05
−0.05
−0.1
0 5 10 15 20 25 30
time [s]
1.5
1
control input [V]
0.5
−0.5
−1
−1.5
0 5 10 15 20 25 30
time [s]
55 / 81
Fuzzy Control Rule Base
56 / 81
Membership Functions for Error
0
-0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2
57 / 81
Additional Rules
58 / 81
Membership Functions for Error
0
-0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2
59 / 81
Fuzzy Control
0.15
shaft angle [rad] 0.1
0.05
−0.05
−0.1
0 5 10 15 20 25 30
time [s]
1.5
1
control input [V]
0.5
−0.5
−1
−1.5
0 5 10 15 20 25 30
time [s]
60 / 81
Input–Output Mapping of the Controller
u
1
local nonlinearity
0.5
-1
61 / 81
Another Solution: Sliding Mode Control
0.15
shaft angle [rad] 0.1
0.05
−0.05
−0.1
0 5 10 15 20 25 30
time [s]
1.5
1
control input [V]
0.5
−0.5
−1
−1.5
0 5 10 15 20 25 30
time [s]
62 / 81
Experimental Results
0.2
0.1
position [rad]
−0.1
Proportional Control
−0.2
0 2 4 6 8 10 12 14 16 18 20
time [s]
10
control input [V]
−5
−10
0 2 4 6 8 10 12 14 16 18 20
time [s]
63 / 81
Experimental Results
0.2
0.1
position [rad]
−0.1
Proportional Control
Fuzzy Control
−0.2
0 2 4 6 8 10 12 14 16 18 20
time [s]
10
control input [V]
−5
−10
0 2 4 6 8 10 12 14 16 18 20
time [s]
63 / 81
Membership Functions
1
0.6
0.4
0.2
0
−1 −0.9 −0.8 −0.7 −0.6 −0.5 −0.4 −0.3 −0.2 −0.1 0
Control error
0.8
membership degree
0.6
0.4
0.2
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Control error
64 / 81
Fuzzy PD Controller: Rule Table
error rate
NB ZE PB
NB NB NB ZE
error
ZE NB ZE PB
PB ZE PB PB
65 / 81
Fuzzy PD Controller – cont’d
0.5 0.5
0 0
control
control
−0.5 −0.5
−1 −1
1 1
0.5 1 0.5 1
0 0.5 0 0.5
0 0
−0.5 −0.5
−0.5 −0.5
error rate −1 −1 error rate −1 −1
error error
0.5
0
control
−0.5
−1
1
0.5 1
0 0.5
0
−0.5
−0.5
error rate −1 −1
error
66 / 81
Supervisory Fuzzy Control
Classical u y
Process
controller
67 / 81
Supervisory Fuzzy Control
external signals
Fuzzy Supervisor
Classical u y
Process
controller
67 / 81
Supervisory Control Rules: Example
68 / 81
Example: Inverted Pendulum
d
69 / 81
Cascade Control Scheme
Reference Position
controller Angle Inverted
controller pendulum
70 / 81
Experimental Results
0.5
−0.5
0 10 20 30 40 50 60
time [s]
0.2
0.1
angle [rad]
−0.1
−0.2
0 10 20 30 40 50 60
time [s]
1
control input [−]
0.5
−0.5
−1
0 10 20 30 40 50 60
time [s]
71 / 81
Experimental Results
0.5
0.1
angle [rad]
−0.1
−0.2
0 10 20 30 40 50 60
time [s]
1
control input [−]
0.5
−0.5
−1
0 10 20 30 40 50 60
time [s]
71 / 81
Takagi–Sugeno Control
Takagi–Sugeno PD controller:
R1 : If r is Low then uL = PL e + DL ė
R2 : If r is High then uH = PH e + DH ė
—L (r ) uL + —H (r ) uH
u = = ‚L (r ) uL + ‚H (r ) uH
—L (r ) + —H (r )
72 / 81
Takagi–Sugeno Control
Takagi–Sugeno PD controller:
R1 : If r is Low then uL = PL e + DL ė
R2 : If r is High then uH = PH e + DH ė
—L (r ) uL + —H (r ) uH
u = = ‚L (r ) uL + ‚H (r ) uH
—L (r ) + —H (r )
72 / 81
Takagi–Sugeno Control
Takagi–Sugeno PD controller:
R1 : If r is Low then uL = PL e + DL ė
R2 : If r is High then uH = PH e + DH ė
—L (r ) uL + —H (r ) uH
u = = ‚L (r ) uL + ‚H (r ) uH
—L (r ) + —H (r )
= P (r )e + D(r )ė;
72 / 81
Takagi–Sugeno Control
Takagi–Sugeno PD controller:
R1 : If r is Low then uL = PL e + DL ė
R2 : If r is High then uH = PH e + DH ė
—L (r ) uL + —H (r ) uH
u = = ‚L (r ) uL + ‚H (r ) uH
—L (r ) + —H (r )
72 / 81
Takagi–Sugeno Control is Gain Scheduling
fuzzy scheduling
Controller K
Inputs Outputs
Controller 2
Controller 1
73 / 81
TS Control: Input–Output Mapping
2 2
1.5 1.5
1 1
0.5 0.5
0 0
1 1
0.5 1 0.5 1
0.5 0.5
0 0
0 0
−0.5 −0.5
−0.5 −0.5
−1 −1 −1 −1
1.5
0.5
0
1
0.5 1
0.5
0
0
−0.5
−0.5
−1 −1
74 / 81
TS Control: Example
75 / 81
TS Control: Example
Nonlinear process:
76 / 81
TS Control: Example
77 / 81
Comparison of Performance
2
1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1
0 5 10 15 20 25 30
5.5
4.5
3.5
2.5
2
0 5 10 15 20 25 30
78 / 81
Typical Applications
79 / 81
Typical Applications
79 / 81
Fuzzy Control: Design Steps
80 / 81
Parameters in a Fuzzy Controller
Inference
Scaling Fuzzifier engine Defuzzifier Scaling
81 / 81