Fuzzy Control and Neural Networks: Dr. Nam H. Nguyen Department of Automatic Control School of Electrical Engineering
Fuzzy Control and Neural Networks: Dr. Nam H. Nguyen Department of Automatic Control School of Electrical Engineering
https://sites.google.com/view/n2c
• I. Fuzzy logic
• II. Fuzzy controller
• III. Neural networks and applications
• 1.1.1 History
• 1.1.2 Set and membership function
• 1.1.3 Operations
• 1.1.4 Fuzzy set
• Empty set: Φ
A set has no element.
Example 1.4: A set of real roots of the equation 𝑥 2 + 1 = 0
• Subset: 𝐴 ⊂ 𝐵 ⟺ ∀𝑥, 𝑥 ∈ 𝐴 ⟹ 𝑥 ∈ 𝐵
- If A is not included in B, then we represent as 𝐴 ⊄ 𝐵
- 𝐴 = 𝐵 ⟺ 𝐴 ⊂ 𝐵 𝑎𝑛𝑑 𝐵 ⊂ 𝐴 (equal sets)
Example 1.5: The set of integers is a subset of the real number
set
• Properties:
✓ A ⊂ A for every A.
✓ If A ⊂ B and B ⊂ C then A ⊂ C
✓ Φ ⊂ A for every A.
• Membership function: Figure 1.1 Subset property
1, 𝑖𝑓 𝑥 ∈ 𝐴
𝜇𝐴 𝑥 = ቊ
0, 𝑖𝑓 𝑥 ∉ 𝐴
Example 1.6: A set of cool temperatures
𝐴 = 𝑥|20 𝑜𝐶 ≤ 𝑥 ≤ 25 𝑜𝐶
1, 𝑛ế𝑢 𝑥 ∈ 𝐴
𝜇𝐴 𝑥 = ቊ
0, 𝑛ế𝑢 𝑥 ∉ 𝐴 Figure 1.2 Membership function for
the set A
9/15/2020 2:52 PM Dr. Nam H. Nguyen 10
1.1.3 Operation of crisp sets
• A) Intersection: 𝐴 ∩ 𝐵 = 𝑥|𝑥 ∈ 𝐴 𝑎𝑛𝑑 𝑥 ∈ 𝐵
𝜇𝐴∩𝐵 𝑥 = 𝜇𝐴 𝑥 . 𝜇𝐵 𝑥 or
= min(𝜇𝐴 𝑥 , 𝜇𝐵 (𝑥))
Example 1.7: Given 𝐴 = 𝑥|1 < 𝑥 < 3 and B = 𝑥|2 < 𝑥 < 4
𝐴 ∩ 𝐵 = 𝑥|2 < 𝑥 < 3
• B) Union
𝐴 ∪ 𝐵 = 𝑥|𝑥 ∈ 𝐴 𝑂𝑅 𝑥 ∈ 𝐵
𝜇𝐴∪𝐵 𝑥 = 𝜇𝐴 𝑥 + 𝜇𝐵 𝑥 − 𝜇𝐴 𝑥 . 𝜇𝐵 𝑥 or
= max(𝜇𝐴 𝑥 , 𝜇𝐵 (𝑥))
Example 1.8: 𝜇𝐴∪𝐵 𝑥 = 𝑥|1 < 𝑥 < 4
0, 𝑖𝑓 𝑥 ≤ 𝑎
𝑥−𝑎
, 𝑖𝑓 𝑎 ≤ 𝑥 < 𝑏
𝜇𝐹 𝑥 = 𝑏𝑐 −
−𝑥
𝑎
, 𝑖𝑓 𝑏 ≤ 𝑥 < 𝑐
𝑐−𝑏
0, 𝑖𝑓 𝑐 ≤ 𝑥
0, 𝑖𝑓 𝑥 ≤ 𝑎
𝑥−𝑎
, 𝑖𝑓 𝑎 ≤ 𝑥 < 𝑏
𝑏−𝑎
𝜇𝐹 𝑥 = 1, 𝑖𝑓 𝑏 ≤ 𝑥 ≤ 𝑐
𝑑−𝑥
, 𝑖𝑓 𝑐 ≤ 𝑥 < 𝑑
𝑑−𝑐
0, 𝑖𝑓 𝑑 ≤ 𝑥
• 𝜇𝐹 𝑥 = 𝑡𝑟𝑎𝑝𝑚𝑓(𝑥, [𝑎; 𝑏; 𝑐; 𝑑])
• Gauss2mf
1 𝑥−𝑐1 2
− ,𝑖𝑓 𝑥≤𝑐1
𝑒 2 𝜎
𝜇1 𝑥 = ቐ 1
1, 𝑖𝑓 𝑥 > 𝑐1
1 𝑥−𝑐2 2
− ,𝑖𝑓 𝑥≥𝑐2
𝑒 2 𝜎2
𝜇2 𝑥 = ቐ
1, 𝑖𝑓 𝑥 < 𝑐2
𝜇𝐹 𝑥 = 𝜇1 𝑥 *𝜇2 𝑥
• Complement
μ𝐴𝑐 x = 1 − μA x (Zadeh)
𝑣 1/𝑣
μ𝐴𝑐 x = 1 − μA x (Yager)
• Example 1.11:
1
𝜇𝐴 𝑥 =
1 + 𝑥2
= Gbellmf (1, 1, 0)
𝑥2
𝜇𝐴𝑐 𝑥 =
1 + 𝑥2
• Union
μA⋃B x = max μA x , μB x for every x, Zadeh
μA⋃B x = μA x + μB x − μA x . μB x
• Intersection
μA∩B x = min μA x , μB x , ∀x ∈ U, Zadeh
μA∩B x = μA x . μB x , ∀x ∈ U
Example 1.13:
• Example 1.14:
• y: error
• T(y): very big, big, small, very small, very very small
• U: 0; 10
• Gr: very
• Ru: associate with each value of linguistic variable a fuzzy set
μ𝑣𝑒𝑟𝑦 𝑏𝑖𝑔 𝑥 = 𝑡𝑟𝑖𝑚𝑓 𝑥, 7,5 10 12
μ𝑏𝑖𝑔 𝑥 = 𝑡𝑟𝑖𝑚𝑓 𝑥, 5 7,5 10
μ𝑠𝑚𝑎𝑙𝑙 𝑥 = 𝑡𝑟𝑖𝑚𝑓 𝑥, 2,5 5 7,5
μ𝑣𝑒𝑟𝑦 𝑠𝑚𝑎𝑙𝑙 𝑥 = 𝑡𝑟𝑖𝑚𝑓 𝑥, 0 2,5 5
μ𝑣𝑒𝑟𝑦 𝑣𝑒𝑟𝑦 𝑠𝑚𝑎𝑙𝑙 𝑥 = 𝑡𝑟𝑖𝑚𝑓 𝑥, −2 0 2,5
9/15/2020 2:52 PM Dr. Nam H. Nguyen 31
1.3 If-then rules
• If-then rule
R: If 𝜒 is A Then 𝛾 is B
• The if-then rule is called the fuzzy implication or fuzzy
conditional statement.
• χ is A: called the antecedent or premise
• γ is B: called the consequence or conclusion
• The if-then rule can be abbreviated as
𝑅: 𝐴 ⟶ 𝐵
𝑓 μ𝐴 𝑥 , μ𝐵 𝑦 = min( μ𝐴 𝑥 , μ𝐵 𝑦 𝑀𝑎𝑚𝑑𝑎𝑛𝑖
𝑓 μ𝐴 𝑥 , μ𝐵 𝑦 = μ𝐴 𝑥 . μ𝐵 𝑦 Larsen - PROD
• R: If 𝜒 is A Then 𝛾 is B
• A•⊂ X, B ⊂ Y, x ∈ 𝑋 and y ∈ 𝑌
• When the input A’ is given to the inference system, the output
B’ is obtained through the inference operation denoted by the
composition operator “o”.
B’ = A’ o R
• This inference procedure is called as the “compositional rule
of inference”
• B’ = A’ o ⋃𝑛𝑖=1 𝑅𝑖 = ⋃𝑛𝑖=1 A’ o 𝑅𝑖
• μ𝑅 𝑥, 𝑦 = ⋃𝑛𝑖=1 μ𝑅𝑖 𝑥, 𝑦
• Example 1.15:
• μ𝐴1 𝑥 = 𝑡𝑟𝑖𝑚𝑓(𝑥, [1 2 3]),
• μ𝐴2 𝑥 = 𝑡𝑟𝑖𝑚𝑓(𝑥, [2 3 4]),
• μ𝐵1 𝑦 = 𝑡𝑟𝑖𝑚𝑓(𝑦, [1 3 5]),
• μ𝐵2 𝑦 = 𝑡𝑟𝑖𝑚𝑓(𝑦, [3 5 7]),
• Rule base:
𝑅1 : If 𝜒 is 𝐴1 Then 𝛾 is 𝐵1 OR
𝑅2 : IF 𝜒 is 𝐴2 Then 𝛾 is 𝐵2
• Determine μ𝑅 𝑥0 , 𝑦 using the composition operation MAX –
MIN, given 𝑥0 = 2.75.
0 0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 1 2 3 4 5 6 7 8
1 1
A1 Mu1
Do thoa man B1
0.5 0.5
0 0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 1 2 3 4 5 6 7 8
1 1
A2 Mu2
Do thoa man B2
0.5 0.5
0 0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 1 2 3 4 5 6 7 8
1
MuR
0.5
0
0 1 2 3 4 5 6 7 8
1 1
A1 B1
A2 B2
0.5 0.5
0 0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 1 2 3 4 5 6 7 8
1 1
A1 Mu1
Do thoa man B1
0.5 0.5
0 0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 1 2 3 4 5 6 7 8
1 1
A2 Mu2
Do thoa man B2
0.5 0.5
0 0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 1 2 3 4 5 6 7 8
1
MuR
0.5
0
0 1 2 3 4 5 6 7 8
• Conclusion:
✓ The matching degree (MISO) is
𝛼𝑖 = 𝑀𝐼𝑁(𝛼𝑖,1 , 𝛼𝑖,2 ,…𝛼𝑖,𝑗 , …)
𝛼𝑖,𝑗 = μ𝐴𝑖,𝑗 (𝑥𝑗 )
μ𝑅 𝒙, 𝑦 = ራ μ𝑅𝑖 𝑦
𝑖=1
𝒙 = x1 x2 … x𝑚
9/15/2020 3:07 PM Dr. Nam H. Nguyen 46
1.3 Compositional Rule of Inference
0 0 0
0 1 2 3 4 5 -5 -4 -3 -2 -1 0 0 1 2 3 4 5 6 7 8
1 1 1
A12 A22 Mu1
0.8 alpha21 0.8 alpha22 0.8
B2
0.6 0.6 0.6
0 0 0
0 1 2 3 4 5 -5 -4 -3 -2 -1 0 0 1 2 3 4 5 6 7 8
1
MuR
0.8
0.6
0.4
0.2
0
0 1 2 3 4 5 6 7 8
• Centroid
Let S = 𝑦 ∈ 𝑌|μ𝑅 𝑦 > 0
′ 𝑦 𝑆μ𝑅 𝑦 𝑑𝑦
𝑦 =
𝑆μ𝑅 𝑦 𝑑𝑦
• BISECTOR
y’ satisfies the condition
𝑦′ 𝑏
න μ𝑅 𝑦 𝑑𝑦 = න μ𝑅 𝑦 𝑑𝑦
𝑎 𝑦′
a = min(𝑆) và b = m𝑎𝑥(𝑆)
0 0 0
0 1 2 3 4 5 -5 -4 -3 -2 -1 0 0 1 2 3 4 5 6 7 8
1 1 1
A12 A22 Mu1
0.8 alpha21 0.8 alpha22 0.8
B2
0.6 0.6 0.6
0 0 0
0 1 2 3 4 5 -5 -4 -3 -2 -1 0 0 1 2 3 4 5 6 7 8
1
MuR
0.8
0.6
0.4
0.2
0
0 1 2 3 4 5 6 7 8
Maximum:
H = max(μR 𝐱 𝟎 , y )=0.5
G = y ⊂ Y|(μR y = H = y ⊂ Y 4 ≤ y ≤ 6
y1 = min G = 4
y2 = max G = 6
Thus, y’ can be:
y’ = 4, or
y’ = 6, or
Y’ = 5
Centroid:
• Example
μ𝐴1,1 𝑥1 = 𝑡𝑟𝑖𝑚𝑓(𝑥1 , [1,2,3]),
μ𝐴1,2 𝑥1 = 𝑡𝑟𝑖𝑚𝑓(𝑥1 , [2,3,4]),
μ𝐴2,1 𝑥2 = 𝑡𝑟𝑖𝑚𝑓(𝑥2 , [−3, −2, −1]),
μ𝐴2,2 𝑥2 = 𝑡𝑟𝑖𝑚𝑓(𝑥2 , [−4, −3, −2]),
𝑅1 : IF 𝜒1 is 𝐴1,1 AND 𝜒2 is 𝐴2,1 THEN 𝑦 = 𝑔1 𝑥1 , 𝑥2 OR
𝑅2 : IF 𝜒1 is 𝐴1,2 AND 𝜒2 is 𝐴2,2 THEN 𝑦 = 𝑔2 𝑥1 , 𝑥2
Find y’, given 𝒙𝟎 = 2.75, −2.5 , 𝑔1 𝑥1 , 𝑥2 = 3 and
𝑔2 𝑥1 , 𝑥2 = 5
• 𝛼1 = 0.25
• 𝛼2 = 0.5
𝛼1 𝑦1 +𝛼2 𝑦2 0.25∗3 + 0.5∗5 3.25
• 𝑦′ = 𝛼1 +𝛼2
= 0.25+0.5
= 0.75 = 4.33 – wtaver
• 𝑦 ′ = 𝛼1 𝑦1 + 𝛼2 𝑦2 = 3.25 - wtsum
• Find y’ when 𝑔1 𝑥1 , 𝑥2 = 𝑥1 + 𝑥2 − 1 and 𝑔2 𝑥1 , 𝑥2 = 𝑥1 −
𝑥2 + 1