Professional Documents
Culture Documents
CHAPTER
2'2
. . ;
, .. r,.
FUZZY LOGIC SYSTEMS, . J f r ; ~tl, F • ,,. ;
1, I
Cl]1f1t upon ang efmg tfi.scoveries.tfirou,gli tlie process efrational tliin,{i1!!J..,. , .u,, ·: J rJ,,. d
/,ad ·~ - \'
.
(1879-1955), GermarJ:..born'
. - · Amert
theoretical
. Einstein
\ . ·~
phy~icist
. .. ., ).: l ••;. ; '- J
Z2.1 IN TRODUCTION I
Alarge amount of data can constitute a proportionately -large amount of information. But thi~ comes with a
bel ofuncertainty. As we come to know more, we also know how much we do not know and our awareness
oftbeconcept of complexity seems to increase. We tend to forego some precise data and, f11lo~ uncertainty to
creep into our perception. This is when we start describing things in a slightly vague and fuzzy manner. For
~ ce after seeing a long list of names, you tell your friend that his name was cited .somev,,here near the
nnddle of the list. The word near seems to be comprehended effortlessly by the ·human brain but what of
computing systems? What does near mean in this context? Two names below the middle or five above or... ?
hlhere a way we can make these number crunching systems understand this concept?
~~sider the case of the statement - "Drive slowly". Does it mean you should drive at 10, 20 or, 20.5 km/
1
~ ~e answer could be any value or a very different one depending on the context. If it is ascertained in
it e that any speed less than or equal to 20 km/hour means slow speed and anything above is fast, then
'Orld.:ean tbat.20.1 km/hour (or 20.01 km/hour for that matter) is fast~ This is an exaggeration in the real
1rfili~.~yst~Ql
foUnderof~ r:
~al!ow~f~~gic deals with h?~ we can capture ~is essence of c_omprehension_and embed it
gradual trans1t1on from slow to high speeds. This comprehension, as per r.!otfi Z,adeti, the '
e zzy·logic concept, confers a higher machine intelligence quotient to computer systems. r:
22 2
, CRJsp SETS
llic. convenuonaI
· m . , . , '·• ' ' , - ·
C!isp :VaJues thereb achin: uses crisp sets to take care of concepts like fast and slow speeds. It relates speed to
Yfomung members that either belong to a ·group or d6 not belong· to it. For example
Slow = {0,5,10,15,20,25,30,35,40}
Artificial Jntelllgence
446
th value of speed is equal to either of those ·rn .
We could mean acrisp set that says that wh~n e be odified to a dosed interval [O 40 cnuonCd ·
set then the speed is categorized as stow. nus mar cros':es over to 40.1 it will be categoriz ] to inc1u: the
118
complete range of values. However, when ~e spec
22.3 ·FuttvsETS
Fuzzy sets introduce a certain amount of vagueness to reduce complexity of comprehension. This
- · h" f a t M b hi set con·
of-elements •hat 'sigm·fy the degree or o-mde of members •P to a uzzy spec . em ers p values sists
' . ' u.r ' . ' e,- b Of . f
closed intervals and denote the sense of belonging of a mem er a cnsp set to a uzzy set. To tnak
usuauy
USC
clear consider a crisp set A comprising of elements that signify the ages of a set of people ,in years~ the llOint
A = {2,4,10,15,21 ,30,35,40,45,60,70}
We could classify age in •t erms of-what are known af fuzzy linguistic variables - infant, child, adole
adult, young and oui. A person whose age is 15 is no doubt young but how would you categorize SCtnt.
who is ~0. 1.f ~e la~er i~ to be ,considered young what about the person who is 40? Is he old? Ho:
for
'::1
translate all these into numbers
are . ?
efficiently making the computer understand what our feelings abo e
m•
Inspect the Table 22.1 giving ages and their membership to a particular set.
I { otscourse (U):
, 1 gii~rsefio ed as the range of all possible values that comprise the input to the fuzzy system.
· de n
t l)iS I' ,
I I ..tfJ set . members to have diftierent grades of membership (based on a membership
. function)
.
. tY' (hat ernPowers its
I 1
1 •Ulyse• tefV al (0 ' t J is a fuzzy set.
. afl I0
. hiP function
1
ienir,ers1,ership function µA which fonns the basis of a fuzzy set is given by
-~
jbe rr,etll µA: U [0,1]
the closed interval is one that holds real numbers.
rt of a fuZZJ set (S1) .
SIIPP°rt sofa fuzzy se~f, in a u~iversal ~risp set U is that ·set which contains all elem~nts of the set U that
SIPP°
1be .zero membership value m'f For mstartce, the support of the fuzzy Set adult 1s
111,oe a 000
Sadult = {21,30,35,40,45,60,70}
Motor Pump
Fuzzy Controller
For simplicity we assume that to maintain the temperature of the room, only the rate of flow of water~
to be con!TOlled ba_se<;l on the speed of the fan and the temperature. With this infrastructure we move to_deSI~
the fuzzy en~e to control ~s system.
Fuzzy regions
.
Two parameters (viz. temperature and pressure) decide the water flow rate. We define f~zzy \n.1per
t•b
temperature a~Cold, Cool, Moderate, Warm and Hot while those for fan speed (measured m rotall
minute) as-Slack, Low , Medium, Brisk, Fast. · . . furt/
Thus temperature in the room could be defined as Cold or Cool or by: any of the corresf<>ndi]lg
linguistic variables. Likewise, the fan speed too could be defined by any of the latter variables. ()lllda!SO
The output of the system, which is the flow-rate of the water controlled by the motorized pumP, ~Ne'sor'
be defined-accordingly by yet another set of fuzzy terms-Strong-Negative (SN), Negative (N), /.JJW
(IN) , Medium (M), Low-Positive (LP) , Positive (P) and High-Positive (HP).
• I
Fuzzy Logic Systems 449
rofiles
f'J,IY p data availa~le ~e ~ow define_ profiles ~or each ~f these parameters (viz. temperature, fan moto~ s~d
by assigning memberships to their respective values. The graphs shown 1in Fig. 22.2 depict this
1~tlt real rate)
_,J ~o~p for the inp~~ temperature ,and fan speed while Figi 22.3 reveals this for the output flow rate.
0
~1aUo that the regions for each of the sets for both the input parlin'leters, temperature and fan motor
O as a)so the outP-.ut hav~ a common 1.~tersect1on
bserve . ,
area. For example, we ,may say that when the temperat~re
~ • grees its membership to the fuzzy set moderate is I (100%). But as we drift away to 30 degrees, its
is 25 de h"P ;0 this set decreases while the same to the set warm starts to increase. Thus when the temperature
inelllt,e~s it is neither f~ ly moder~ttJ_ nor_warm. These erofiles have to be carefully designed after studying
and desired_behaviour of the system. _, r , , ,
1
!be .' 1.2 ~ - ~ - - - - - - - - - - ,
1.2 COid Cool Moderate Warm Hot 'l ' Medium ' Brisk Fast
i
1.
i
Z 1 '" I!!
0.8 0.8,
Q.6 ;:E 0.6
i
c
0
04 'j , 3l ,0.4
tu -~• OQ
0 I _ _,.j........."TTT"l.,.,...,rl-n-n"l"T,..,+,-r'rrn"l"T"TTT1',-h-,rrn-.....l "i 9 0 ..).......,.J..,.....,..,...l,~.+r-r..+nTTT1,,-rr,+,..,n'n-rrrrrh+r-n-rrrT1
O1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 1 4 7 10 13 16 19 22 25 28 31 34,37 40 43 46 49
Temperature ' I Motor,Speep RPM
(a) Temperature , •'f ,. (bJ Fr,m Moton Speed
1
Fig.:22.2, , I,/
1.2 ~ - - - - - - - - - - - - ~
a. SN N LN M LP P HP
1
1lE 0.8
Q)
::E 0.6
0
a> 0.4
!!!
g> 0.2
a
0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
Flow Rate (ml/sec)
Fig. 22.3 Wat;er Flow Rate
FIIZzyRu/~
The fuzzy rules fonn th~ triggers of the fuzzy en9ine. After a study of Jbe system we could write linguistic
rules (so akin to natural language) such as - ,,,
RI : lftemperaturejs HOT and fan motor speed is SLACK then flow-rate is HIGH-POSmVE.
R2: If temperature is HOT and fan motor speed is LOW then flow-rate is .HIGH-POSITIVE
R3: If temperature is HOT and fan motor speed is MEDIUM then the flow-rate .is POSmVE.
R4: If temperature is HOT and fan motor speed is BRISK then the flow-rate is'.HIGH-POSITIVE.
!
R5: lftempera!J.lre is WARM and fan motor speed is MEDIUM then the-flow-rate is LOW-POSITIVE,
6
: If temperature is WARM and fan motor speed is BRISK then the flow-rate is POSITIVE.
/ If temperature is COOL and fan motor speed is LOW then flow-rate is NEGATIVE.' .,
S: If temperature is MODERATE and fan motor speed is LOW then flow-rate is MEDIUM.
lbe reac1e 18.
r urged to write the remaining set of rules based on the requirement of the system.
450 Artificial lntelli9ence
Fuzziflcation
The fuzzifier forms the heart of the fuzzy engine. Whenever the sensors report the values of tempe
fan speed, they are mapped based on their memberships to the respective fuzzy regions they be! rature ilnd
instance if at some instance of time t the temperature is 42 degrees and fan speed is 31 rpm, the coing to. For
membership values and the associated fuzzy regions are mentioned below esponding
F11zzy Regions Memberships
Parameter
warm, hot 0.1 42, 0.2
Temperature ·. 0.25,0.286
Fan speed medium, brisk
From the table, since both temperature and fan speed belo_ng to two regions, it is clear that the rules R3 4
R5 and R6 are applicable. The rules indicate a conflict. While two of them state that the flow-rate shouit ,
POSmVE, the other two state that it should be LOW-POSmVE and HI?H-POSITI_VE respectively. Thou be
we have resolved the issue of what could be the flow rates, the actual cnsp value still eludes us. gh
Defuzzifler
This is where we have to demystify these fuzzy terms for the flow rate controller system. In other words the
fuzzy outputs LOW-POSITIVE, POSITIVE and HIGH-POSmvE are to be converted to a single crisp
which can then be delivered to the final actuator of the pump. This process is called defuzzification. Se
methods_ are~ to achieve defuzzification, the most common ones being the Centre o~ Gravity method an~ the
e:
;al
Composite Maxuna method. In both these methods we need to compute the composite region formed by th
portions A, B, C and D (_See Fig. 22.4) on the output profile. F~g~ 22.4 sho~s how this i~ calculated. In case 0;
parameters whose prenuses are connected by an AND, the nurumum of therr memberships is first found. This
)
_e. 1.2 ~ - - - - - - - - - -- -~
j 1
r-o.8
0.6
I !
l
0.4
0.2
0 + -r-r.---r-r-~.,.......---.-,--,-~-1-h~--i
1 4 7 10131619222528313437 40 434648
Temperature 42°c
0.2
.e-
j 1.2
j 1
0.8
Rule R3
0
min (0.2, 0.25)
0.6
Eo.4
0.2
0
1.6
0 0.2 0.4 0.6 0.8
Flow Rate (ml/sec)
0.25
1 4 7 10 13 16 19 22 25 28 31343740 43 46 49
Motor Speed (RPM) 31 rpm
Ij:::1:
0.1
0
14 7
1013181922252831343740434849
Temperature
•
42 C
HP
0.4
0.2 0.2
p
i 0.6
0 --1--~----.----r--,--,--.....,.-+--t-----t
0 0.2 0.4
Flow Rate (ml/sec)
0.6 0.6
I o4
l Ol..1--.-r-r-r-,-T""""T--r--r"""'llr"""T--r.-'r-r--i
0
0.286
,,
14710131619222528 1343740434649
Motor Speed (RPM) 31 rpm
0 1 1 ~ - - - - - - -- - - - - - - ,
i
E 0.8
1
• 06
0
1°·· 0.142
g01
Q.
:i; Rule R5
1 4 7 10 1316 19 22 25 26 31 34 37 40 43 46 49
j 1.2 . - - - - - - - - - - - - - - - ~
Temperature 42•c
:i 1
0.8
0
[ 0.6
J,
0,4
0.142 0.2
1.~
0 ;--,--,---,---+-+--r1--,--~-----i
•
1
iO.S
0.8
,, !I
0
I
0.2 0.4
Flow Rate (ml/sec)
0.6 0.8
J' I
1.2
A
1.4 1.6
0.142
0.286
1 4 7 10131619222528 1343740434649
Motor Speed (RPM) 31 rpm
1.2
a. LP P
:i:
· e?
Q)
.c 0.8
E
Q)
::E 0.6
0
0.4
eCl
G>
Q)
_. c 0.2 --t---- Centroid
0
0 0.2 0.4 0.6
Flow Rate ml/sec
A
Bi~ within c 'a's 1
P1s
a subset of the region C
value is used to cut ~ough the profile of the output fuzzy set (d~ne by drawing a horizontal line). This resul~
.. ' "''
a region (area) on the output surface. For cases where an OR relates the premises the maximum mern_
t,ersbip!S
taken to work out the output surface. All output surfaces are found to obtain the composite output region. )
Depending on the application, either the Centre of Grayi~y or the Composite Maxima of this region (are~
is fou_nd and tr~ated as th~ crisp outJ?ut. The f~rmer method works best for control applications such as~:~
descnbed herem. The cnsp output 1s the desired flow rate (X-coordinate of the Centroid) and the mot
pump is adjusted accordingly based on this value.
Fuzzy Lo9ic Systems 453
thus seen that the steps involved in realizing a fuzzy logic based system include -
'ehave .
\\ lating Fuzzy regions,
fortllU '
(i) Rules and
6i) fu~dding a Defuzzlfication procedure. ·
6ii) f,fll!ogic has als~ ~n wide!y applied to non-control applications as well. Take the case of decid!n~
fuaY t,ook on Artificial Intelligence belongs to the domain of Computer Science, Psychology or CIVIi
~·tiether g In such situations a crisp numerical output o'btained by this defuzzification process used earlier
~ioeennn~ meaning. The composite maxima is generally used for such problems and the truth d7pends on
111<1Y carrY not the composite maxima has crossed a predetermined thr~shold. The defuzzification process
L,w;
i=l
whereNis the number of rules triggered and the weight w; = min(µ};j = 1 to M the number of sensor inputs.
The computation of a Sugano based is depicted in Fig. 22.5.
~-----------+-l f= (aT + bS + c)
Membership
Membership f---~---,J
I
Fig. 22.S Sugano fezzy injerence processi,ng model
454 Artificial lntel/i9ence
2 .2 3 -3 4 4 5 5 6 0
Height in Metres '
Definitely, Intensifies Fuzzy Heights ''
positively, .the contrast .---Tall
surely, very of the region
Somewhat, Dilutes the -VeryTall ,
a bit, rather, region
quite • • ·• Somewhat
Tall -
2 2.5 3 3.5 4 4 .5 -Extremely
Heigh_t in Metres
Tall
./ . q
22.8 a CUT"THRESHOLD li't
The minimum truth membership level for a fuzzy set forms the a cut threshold
for that fuzzy set. Membership values below this threshold are treated as
Hot
equivalent to zero. Naturally this threshold affects the suppo~t'~f the fuzzy set.
Thus as this threshold value increases, the support of the fµzzy, &et decreases.
Figure 22.6 shows one such a cut (µHot = 0.27) for the fuzzy set Hot. a cuts, ·
implemented either as strictly "less than," a certain membership value or relaxed 0.27 ---------
as "less than or equal to" mode, aid in filtering out 'noise by prescribing a 140
minimum truth level requirement. Such cuts have to be implemented with care Temperature
and should not be ·raised beyond the overlapping areas of the fuzzy sets lest Fig. 22,6 aCut/or theFUzzY
some points in the universe of discourse (U) become excluded from all the . Set Hot
fuzzy sets. ·
Fuzzy Logic Systems 455
e
Tempe Output
Fan mot
speed
Brisk µ
'G v
Fig. 22.7 Neuro Fuzzy Room Cooler
As can be seen from the figure the arcs connecting the neurons pertaining to the rule's left hand side, to
those of its right hand side (neurons of the penultimate layer) are weighted. These weights may be initialized
just as in neural networks, to values between [O, 1]. These weights are the ones that change during the training
phase of the neural network. Training is conducted by presenting both the input and the desired target output.
The system's output is computed and the error between this and the desired output is propagated backwards
(using the back propagation algorithm). This modifies the activation functions of the neurons. Over several
epochs, the weights are altered to reveal the best values. In the process it may also happen that a particular arc
may have a weight equal to Owhich essentially means the rule (neuron) from which it emanated need not be
pan of the fuzzy system. The learning mechanism thus aids in filtering unnecessary or redundant rules that
may have been included by the expert unknowingly.
22 ·10 POIN TS TO N OTE
~se of fuzzy logic may seem a bit unconventional. Especially since everything seems in place (a priori)
thus; sys~m seems to be doing something computationally to achieve the desired effect. Such systems are
realize~: suited for areas where a mathematical model is not available or the problem is difficult to model or
urthennore these systems have to be tuned and re-tuned by changing the input and output profiles,
456 Artificial Intelligence
rules and the de~zzification procedures. This may require sev~ral iter~ti~ns; at times in:olving the develo .
of the real workmg prototype in the loop. Also note that while the mput control variables are cont· Plllent
. . tnuou .
nature, the system can take into account high ambient noise. lmagme a case when the temperature O . 8 1n
frequ~tly between two values belonging to two adjacent fuzzy re~ions. Si~ce the ce~troid would sh~~tes
rnargmally, the change in the flow rate would remain smooth unhke that m conventional discrete s nly
wherem · osci·11 atmns
· could lead to instability. YSlems ·
EXERCISES
1. No_w that a fuzzy cooler is in place, design a simple_fuzzy washing machine that can decide the SJ>eecl
of _its motor based on the dirt level, type and the weight of the cloth.
2. Visit the library of your institution, this time,.for a different purpose. Inspec~ what of books are
placed in each rack. Write a fuzzy logic program that can suggest the rack mto which a new arrival
(pook) can go. .
3. Based on the fuzzy cooler, model ·the exposure time of a typical camera. Assume the camera has
sensors to detect ambient light, controls for flash and picture type (landscape, close, etc.) settings. Also
assume that exposure times are based on values reported by these sensors.
4. Check the fuzzy model for parking a truck described in the site:
http://www.iit.nrc.ca/IR_public/fuzzy/FuzzyTruck.html
Observe thatthe rules have been portrayed as a matrix commonly referred to as a Fuzzy Associative
Memory (FAM). Try placing the truck at different orientations at the comers and trace its path. In ~ase it
is unsuccessful try changing the rules within this m~trix and inspect the ways in which the truck paiks,