fuzzy logic and fuzzy control - nju.edu.cn
TRANSCRIPT
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Fuzzy Logic and Fuzzy Control
n Fuzzy Logic �• Zadeh defines fuzzy logic (FL) �• two important concepts "�
n Fuzzy Rules�• fuzzy rules�• Example of Fuzzification �• Defuzzification�
n Fuzzy Controllers�l Why fuzzy control? �l Example of fuzzy controller
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Fuzzy Logic
• Zadeh defines fuzzy logic (FL) as a logical system, which is an extension of multivalued logic �
• FL is not based on a closed world model (we don’t assume� everything is known) �• FL (& crisp logic) state objective descriptions/measures�• FL does not require statistical independence of variables�• In FL, the absence of a fact doesn’t imply anything �• A FL membership value persists after observation �
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
Fuzzy Logic
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Fuzzy Logic
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
The more complex a system is, the more it involves intelligent behavior, the more likely it is that fuzzy logic will provide a good approach.
Fuzzy Logic
two important concepts within FL : �
• linguistic variable �
• fuzzy if-then rule
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
linguistic variable �
Fuzzy Logic
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
• Concentration hedges (e.g. very) �
• Dilation hedges
Fuzzy Logic
hedges
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Fuzzy Rules �• Have antecedent part and consequent part�
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Fuzzy Rules
�• Mamdani-type fuzzy rule: �If X1 is A1 and ... and Xn is An then Y is Bj ��• TSK-type fuzzy rule: �If X1 is A1 and ... and Xn is An then Y = p0 + p1X1 + ... + pnXn��The default type of rule we use is the Mamdani type. �
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Mamdani-type fuzzy rule
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
TSK FUZZY RULE
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Fuzzifica)on
Fuzzification is the combining of the antecedent sets (the if- side of the rule) ��We use a gas flow regulator for a furnace as an example. �• Input parameters: indoor temp., outdoor temp., 5-min. delta temp.�• Output parameter: change in gas flow �
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Fuzzy Set Defini)on Now we must define the fuzzy sets over each parameter. We decide to use triangular membership func)ons. First decide how many sets per parameter, then decide range for each: • For the InTemp parameter, we define three fuzzy sets: cool, comfortable, and
too_warm. • For OutTemp, we have five fuzzy sets defined: very_cold, chilly, warm,
very_warm, and hot. • For DeltaInTemp, we define five fuzzy sets: large_negaAve, small_negaAve,
near_zero, small_posiAve, and large_posAve. • For our output parameter FlowChange, we define five fuzzy sets:
decrease_greatly, decrease_small, no_change, increase_small, and increase_greatly.
Number of membership func)ons for a parameter depends on the situa)on.
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Define the Rule Set Possible rules: ��Rule 1: If InTemp is comfortable and DeltaInTemp is near_zero, then FlowChange is no_change. ��Rule 2: If OutTemp is chilly and DeltaInTemp is small_negative, then FlowChange is increase_small. ��Rule 3: If InTemp is too_warm and DeltaInTemp is large_positive, then FlowChange is decrease_greatly. ��Rule 4: If InTemp is cool and DeltaInTemp is near_zero, then FlowChange is increase_small. �… �
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Define the Membership Func)ons
(We define only those we need for our example rules.) For inside temperature (intemp):
⎭⎬⎫
⎩⎨⎧ ++=
700
601
501cool
⎭⎬⎫
⎩⎨⎧ ++=
800
701
600ecomfortabl
⎭⎬⎫
⎩⎨⎧ ++=
901
801
700_ warmtoo
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Define the Membership Func)ons, Cont’d. For DeltaInTemp:
⎭⎬⎫
⎩⎨⎧ ++=
⎭⎬⎫
⎩⎨⎧
+++
−=
⎭⎬⎫
⎩⎨⎧ +
−+
−=
61
41
20_arg
20
01
20_
00
21
40_
positiveel
zeronear
negativesmall
For OutTemp:
⎭⎬⎫
⎩⎨⎧ ++=
700
501
300chilly
(These are all we need for our rules.)
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Example of Fuzzification
Assume inside temperature is 67.5 F, change in temperature last five minutes is -1.6 F, and outdoor temperature is 52 F.
Now find fuzzy values needed for our four example rules:
For InTemp,
0.0)5.67( and ,75.0)5.67(,25.0)5.67( _ === warmtooecomfortablcool µµµ. For DeltaInTemp,
0.0)6.1( and ,2.0)6.1( ,8.0)6.1( _arg__ =−=−=− positiveelzeronearnegativesmall µµµ
For OutTemp,
9.0)52( =chillyµ.
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Fire the Fuzzy Rules Using Zadeh’s AND process:
Rule 1: changeno _20.020.075.0 µ==∩
Rule 2: smallincrease _8.08.09.0 µ==∩
Rule 3: greatlydecrease _0.00.00.0 µ==∩
so Rule 3 doesn’t produce any output. Rule 3 is said to have fired but not to have been activated. Rule 4: smallincrease _2.02.025.0 µ==∩
Note that two rules result in the activation of increase_small.
for FlowChange.
for FlowChange.
for FlowChange.
for FlowChange.
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Determine Output Fuzzy Set Ac)va)ons
In our example, rules 1, 2, and 4 are activated. ��Two output fuzzy sets are activated: �no_change (by rule 1) �increase_small (by rules 2 and 4) ��Note that a fuzzy set can be activated by several rules
(often at different levels) �We can use various ways to obtain the output when
multiple rules fire; Zadeh’s OR is one common way. This results in an output level of 0.8 for increase_small�
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Defuzzifica)on
• Combines set of if-then rules into a specific value of a control�(output) variable�• Defuzzification is the process of getting a scalar out of the fuzzy
system. ��
Note: These rules are for changes in flow. �
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Defuzzifica)on, Con)nued
Chop off consequent linguistic variable membership functions at values obtained Note that membership functions must have been established with scalar values assigned to consequent variable scale A common way to defuzzify is with the centroid (clipped center of gravity) method.
∑
∑=
ii
iii
x
xxOutput
)(
)(
µ
µ
Must specify how to deal with areas of overlap: count them once or twice.
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
Defuzzifica)on of Furnace Gas Flow
DG, increase greatly; DS, decrease slightly; NC, no change;
IS, increase slightly; IG, increase greatly
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
Other Defuzzifica)on Methods (Each represents outputs as arrows pushing down on x-‐axis.) Max-‐membership: Take centroid of membership func)on with highest value (Output = 1.0 in example) Mean-‐max-‐membership: Average value on the domain axis (Output = 0.5 in example) Center-‐of-‐maximum: Each membership value represented by one arrow. (Like forces pushing on a lever.) (Output = 0.8 in example)
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Measures of Fuzziness
• Fuzziness measures for discrete fuzzy sets exist
• Fuzziness measures are metrics of fuzzy uncertainty
• These measures es)mate average ambiguity in fuzzy sets
• Goal: to describe the rela)onship of elements to sets and sets to one another
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Fuzzy Control
• Largest applica)on of fuzzy logic
• First implemented by Mamdani in laboratory in 1975
• Thousands of commercial and industrial applica)ons today
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Why Fuzzy Control?
* Efficiently incorporates human expert informa)on * Does not require a mathema)cal model of system * Produces nonlinear controllers * Easy and inexpensive to design * Easy to understand
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
The Fuzzy Controller
System being controlled
Fuzzify Defuzzify
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
The Fuzzy Controller
* Provides set of inputs to produce desirable outputs * Controller’s ac)ons defined by rule base * To build rule base:
1. Iden)fy and name input variables and define ranges 2. Iden)fy and name output variables and define ranges 3. Define fuzzy membership func)on for each input variable 4. Build rule base to govern controller 5. Define how control ac)ons will be combined to provide plant inputs
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Example Fuzzy Controller
• Build system to control speed of train
• Specifically, design system to smoothly slow and stop train from any speed and distance from sta)on
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Iden)fy and name input variables and define ranges
SPEED Linguistic Range
Low High
Fast 26.5 70 Medium Fast 6.5 46.5 Slow 2.5 10.5 Very Slow 1 4 Stopped 0 2
DISTANCE Linguistic Range
Low High
Far 1,500 ∞ Medium Far 100 3,000 Near 3 200 Very Near 1 5 At 0 2
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Iden)fy and name output variables and define ranges
THROTTLE Linguistic Range
Low High
Full 60% 100% Medium 20% 80% Slight 3% 30% Very Slight 1% 5% No 0 2%
BRAKE Linguistic Range
Low High
Full 98% 100% Medium 95% 99% Slight 70% 97% Very Slight 20% 80% No 0 40%
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
Fuzzy Membership Func)ons for Speed
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
Fuzzy Membership Func)ons for Brake
%
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Build Rule Base Matrix
• Build matrix of input variable combina)ons • Each matrix posi)on may have values for output variables • If one output variable is specified, all must be • Shaded area on next figure corresponds to rules:
As speed is ‘stopped’ and as distance is ‘at’ then do ‘full brake’ As speed is ‘stopped’ and as distance is ‘at’ then do ‘no throdle’
• “AND” together the inputs to produce each output
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
Fuzzy Rule Base Matrix
Shaded entry: IF (speed) IS (stopped) AND IF (distance) IS (at)
THEN (full brake) AND (no throdle)
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Determine How Control Will Occur Usually use centroid defuzzification Example: speed = 3 km/hr; distance = 1.8 m Determine which membership functions are activated and
to what values:
speed: µVY-SLOW(3)=0.667
µSLOW(3)=0.125
µAT(1.8)=0.1
µVY-NEAR(1.8)=0.4
distance:
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
3 km/hr Ac)vates Very Slow and Slow
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
1.8 Meters Ac)vates at and very near
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
Rules Ac)vated with speed = 3 and distance = 1.8
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015 INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2014
Use Centroid Defuzzifica)on to Obtain Output
INTRODUCTION TO COMPUTATIONAL INTELLIGENCE, Nanjing University Spring 2015
Summary of Controller Opera)on
• Sample inputs
• Determine membership values ac)vated by inputs
• Determine which rules fire
• Combine relevant membership values using AND operator
• Trace ac)va)on membership values back through output func)ons
• Use centroid method to defuzzify output to a scalar