You are on page 1of 33

Introduction to Fuzzy Logic

Created by Eli Hait to help people in understanding Fuzzy Logic principle, methodology and possible applications

Contact: 052 5!0"#$#

INTRODUCTION

Eastern Culture VS Western


Buddha, who lived in India about 500 BC founded a religion called Buddhism. His philosophy was based on the thought that the world is filled with contradictions, that almost everything contains some of its opposite, or in other words, that things can be A and not A at the same time. Here we can see a clear connection between Buddha!s philosophy and modern fu""y logic. About #00 years later, the $ree% scholar Aristotle developed binary logic. In contrary to Buddha, Aristotle thought that the world was made up of opposites, for e&ample male versus female, hot versus cold, dry versus wet, active versus passive. 'verything has to be A or not A, it can!t be both.

Eastern Culture VS Western


(ver the centuries, these two philosophies developed and spread independently. Buddhism e&panded as the religion of India and surrounding states. Aristotle!s logic, however, was accepted by the $ree% scholars and later got spread all over 'urope. Aristotle!s binary logic became the base of science) if something got proven with logic, it was and still is accepted as scientifically correct.

Brief history of FL The Beginning


*he concept of +u""y ,ogic -+,. was first conceived by ,otfi /adeh, a professor at the 0niversity of California at Ber%ley, and presented not as a control methodology, but as a way of processing data by allowing partial set membership rather than crisp set membership or non membership. 5rofessor /adeh reasoned that people do not re3uire precise, numerical information input, and yet they are capable of highly adaptive control. If feedbac% controllers could be programmed to accept noisy, imprecise input, they would be much more effective and perhaps easier to implement. *his approach to set theory was not applied to control systems until the 10!s due to insufficient small computer capability prior to that time. 0nfortunately, 0.2. manufacturers have not been so 3uic% to embrace this technology while the 'uropeans and 4apanese have been aggressively building real products around it.

Brief history of FL The Outbrea


+or a long time, a lot of 9estern scientists have been reluctant to use fu""y logic because they felt that it threatened the integrity of scientific thought. *he term :fu""y; also didn;t helped to spread the new approach. In the year 6781, the first subway system was built which wor%ed with a fu""y logic based automatic train operation control system in 4apan. It was a big success and resulted in a fu""y boom. *oday, +u""y ,ogic concept used widely in many implementations li%e automobile engine < automatic gear control systems, air conditioners, automatic focus control, video enhancement in *= sets, washing machines, behaviour based mobile robots, sorting and handling data, Information 2ystems ->B?2, Info. @etrieval., 5attern @ecognition -Image 5rocessing, ?achine =ision., motion control systems, decision support -Adaptive H?I, 2ensor +usion., traffic control systems and many, many others.

So! "hat is all about#


+u""y logic ma%es use of human common sense. It lets novices build control systems that wor% in places where even the best mathematicians and engineers, using conventional approaches to control, cannot define and solve the problem. *he initial motivation for that was create a methodology to deal with issues which can;t be answered Aust by *@0' or +A,2' li%e BHow many grains of sand ma%e up a pileCB +u""y ,ogic approach is mostly useful in solving cases where no deterministic algorithm available or it is simply too difficult to define or to implement, while some intuitive %nowledge about the behaviour is present.

So! "hat is all about#


FL incorporates a simple, rule-based IF X AND Y THEN Z approach to a sol in! control problem rather than attemptin! to model a s"stem mathematicall"# The FL model is empiricall"-based, rel"in! on an operator$s e%perience rather than their technical understandin! o& the s"stem# For e%ample, rather than dealin! 'ith temperature control in terms such as( )*+ ,-..F), )T /0...F), or )10.2 /TE3+ /11.2), The terms used are li4e( )IF 5process is too cool6 AND 5process is !ettin! colder6 THEN 5add heat to the process6) or( )IF 5process is too hot6 AND 5process is heatin! rapidl"6 THEN 5cool the process 7uic4l"6)# These terms are imprecise and "et er" descripti e o& 'hat must actuall" happen#

So! "hat is all about#


+, re3uires some numerical parameters in order to operate such as what is considered significant error and significant rate of change of error, but e&act values of these numbers are usually not critical unless very responsive performance is re3uired in which case empirical tuning would determine them. $enerally, +, is so forgiving that the system will probably wor% the first time without any twea%ing.

FL is a better alternati$e to linear %ontrol


?ost real life physical systems are actually non linear systems. Conventional design approaches use different appro&imation methods to handle non linearity. 2ome typical choices are, linear, piecewise linear, and loo%up table appro&imations to trade off factors of comple&ity, cost, and system performance A linear appro&imation techni3ue is relatively simple, however it tends to limit control performance and may be costly to implement. 5iecewise linear techni3ue wor%s better, although it is tedious to implement because it often re3uires the design of several linear controllers. A loo%up table techni3ue may help improve control performance, but it is difficult to debug and tune. +urthermore in comple& systems where multiple inputs e&ist, a loo%up table becomes impractical due to its large memory re3uirements +u""y logic provides an alternative solution to non linear control because it is closer to the real world. Don linearity is handled by rules, membership functions, and the inference process which results in improved performance, simpler implementation, and reduced design costs.

&BOUT FU''( LO)IC

Cris* Set $s Fu++y Set


Crisp logic needs hard decisions. ,i%e in this chart. In this e&ample, anyone lower than 615 cm considered as short, and behind 615 considered as high. 2omeone whose height is 680 is part of *A,, group, e&actly li%e someone whose height is 670

+u""y ,ogic deals with Emembership in groupF functions. In this e&ample, someone whose height is 680, is a member in both groups. 2ince his membership in group of *A,, is 0.5 while in group of 2H(@* only 0.6, it may be seen that he is much more *A,, than 2H(@*.

Cris* Set $s Fu++y Set

Another way to loo% at the fu""y Emembership in groupFG each circle represents a group. As closer to center to particular circle -group., the membership in that group is EstrongerF. In this e&ample, a valid value may be member of $roup 6, $roup #, both or neither.

Fu++y O*erations
Crisp logic is a subset of +u""y ,ogic

FU''( LO)IC CONTROL S(STE, DESI)N

Starting the *ro%ess*he first step in implementing +, is to decide e&actly what is to be controlled and how. +or e&ample, suppose we want to design a simple proportional temperature controller with an electric heating element and a variable speed cooling fan. A positive signal output calls for 0 600 percent heat while a negative signal output calls for 0 600 percent cooling. Control is achieved through proper balance and control of these two active devicesG

Starting the *ro%ess ./0


It is necessary to establish a meaningful system for representing the linguistic variables in the matri&. +or this e&ample, the following will be usedG BDB H BnegativeB error or error dot input level B/B H B"eroB error or error dot input level B5B H BpositiveB error or error dot input level BHB H BHeatB output response EDB H BDo ChangeB to current output BCE H BCoolB output response >efine the minimum number of possible input product combinations and corresponding output response conclusions using these terms. +or a three by three matri& with heating and cooling output responses, all nine rules will need to be defined. *he conclusions to the rules with the linguistic variables associated with the output response for each rule are transferred to the matri&.

Ty*i%al %ontrol syste1 res*onse


*he figure shows what command and error loo% li%e in a typical control system relative to the command setpoint as the system hunts for stability. *he I steps are mandatory for each control functionG 6. #. Current 2tatus Ac3uirement Current 2tatus vs 2etpoint -@e3uired 2tatus. 5rocessing @evealing the Control @esponse -Corrective Action..

I.

FL Control Syste1 in 2 ste*s*ypical +u""y ,ogic control implementation involving I stepsG

+u""ificationG converting the crisp inputs to membership functions which comply to intuitive perception of system status. @ules 5rocessingG calculating the response from system status inputs according to the pre defined rules matri& -control algorythm implementation.. >e +u""ificationG converting the @ules 5rocessing results to crisp outputJs to feed into the control devices.

Fu++yfi%ation- ,e1bershi* Fun%tions


*he membership function is a graphical representation of the magnitude of participation of each input. It associates a weighting with each of the inputs that are processed, define functional overlap between inputs, and ultimately determines an output response. Bell, trape"oidal, haversine and, e&ponential shapes may be used but the triangular shape is common, good enough in most of cases and e&tremely simple and cheap to implement by H9 or 29.

,e1bershi* Fun%tions .e3a1*le 4esign0


*he degree of membership ->(?. is determined by plugging the selected input parameter -error or error dot. into the hori"ontal a&is and proAecting vertically to the upper boundary of the membership function-s..

'&ampleG consider an BerrorB of 6.0 and an Berror dotB of K#.5. *he degree of membership would beG L 'rror H 6.5 L 'rr dot H K# . HM DegativeH0.1 /eroH0.#5 5ositiveH0 HM DegativeH0 /eroH0.N 5ositiveH0.I

Rules E$aluation
*he @ule ?atri& summari"e the %nowledge about how the control output should behave in response to relevant inputs. It is a matri& presentation of e&pected behavior of control -algorithm implementation.. *he minimum si"e for practical @? is I&I -7 rules., but so small matrics can represent only very simple system behavior. 0sually, the @?;s are much more complicated. 9hen more than one control outputs needed or the number of inputs to each table, it may be splitted into few different tables. *he 3uality of the whole control function depends on precision and coverage of the rule matri&.

The Rule ,atri3 .e3a1*le 4esign0


*he following table describes the basic behavior of temperature control system. >ecide appropriate output response conclusions, and load these into the rule matri&. *he same 7 rules represented in linguistic termsG Dote that the AD> function is Efu""y AD>F, i.e. the result is ?ID function between the inputs.
6. #. I. O. 5. N. 1. 8. 7.

*he rules use the input membership values as weighting factors to determine their influence on the fu""y output sets of the final output conclusion.

I+ 'rrorHD and 'rror dotHD then (utputHH I+ 'rrorH/ and 'rror dotHD then (utputHH I+ 'rrorH5 and 'rror dotHD then (utputHC I+ 'rrorHD and 'rror dotH/ then (utputHH I+ 'rrorH/ and 'rror dotH/ then (utputHD I+ 'rrorH5 and 'rror dotH/ then (utputHC I+ 'rrorHD and 'rror dotH5 then (utputHC I+ 'rrorH/ and 'rror dotH5 then (utputHC I+ 'rrorH5 and 'rror dotH5 then (utputHC

Rule strength e$aluation


In our e&ample, when the fu""y inputs are 'rrH 6.5 and 'rr dotHK#, the membership function -fu""ification. result isG
'rror H 6.5 HM DH0.1 /H0.#5 5H 0 'rr dot H K# HM DH 0 /H0.N 5H0.I

Dow we calculate the strength for each rule by selecting the ?ID value of each of the variables contained in its AD> functionG
N. 1. 8. 7. 60. 66. 6#. 6I. 6O. I+ 'rrorHD and 'rror dotHD then (utputHH I+ 'rrorH/ and 'rror dotHD then (utputHH I+ 'rrorH5 and 'rror dotHD then (utputHC I+ 'rrorHD and 'rror dotH/ then (utputHH I+ 'rrorH/ and 'rror dotH/ then (utputHD I+ 'rrorH5 and 'rror dotH/ then (utputHC I+ 'rrorHD and 'rror dotH5 then (utputHC I+ 'rrorH/ and 'rror dotH5 then (utputHC I+ 'rrorH5 and 'rror dotH5 then (utputHC HM 2trength H minP0.1, 0Q H 0 HM 2trength H minP0.#5, 0Q H 0 HM 2trength H minP0, 0Q H 0 HM 2trength H minP0.1, 0.NQ H 0.N Heat HM 2trength H minP0.#5, 0.NQ H 0.#5 Dothing HM 2trength H minP0, 0.NQ H 0 HM 2trength H minP0.1, 0.IQ H 0.I Cool HM 2trength H minP0.#5, 0.IQ H 0.#5 Cool HM 2trength H minP0, 0.IQ H 0

Dote that only rules O,5,1 and 8 get strength higher than 0, only these rules would EfireF the output.

,erging the rules strengths


As could be seen in the e&ample, different fu""y rules might have different conclusions. *o consider all rules the (utput ?embership +unction should be involved, and somehow the composite conclusion should be evaluated from this membership function according to Econclusion driving rules strengthsF But there might also be few rules producing different strength values for the same conclusion -li%e rules R1 and R8 in the e&ample., so a single cumulative strength value should be evaluated before de fu""ification -composition.. In some cases, the +u""y (@ function may be used -select the ma&imum strength output for each conclusion., but the most common and precise method used called @22 S @oot 2um 23uare.

,erging the rules strengths .RSS 1etho40


*he @22 ?ethod defined asG TTTTTTTTTTTTTTTTTTTTTTT U -@6# K @## K @I# K V K @n# . 9here @6, @#, @IV. @n are strength values of different rules which share the same conclusion. In our e&ample, the cumulative strengths calculated as followsG 2H'A* H U 0.N# H 0.N 2D(*HID$ H U 0.#5# H 0.#5 2C((, H U -0.I# K 0.#5#. H U -0.07 K 0.0N#5. H 0.I7 *hese values would be applied to the output membership function for composition.

Defu++ifi%ation 1etho4s5
Combines all fu""y conclusions obtained by inference into a single conclusion. 2ince different fu""y rules might have different conclusions, consider all rules. (nce the functions are inferred, scaled, and combined, they should be defu""ified into a crisp output which drives the system. *here are few methods of >efu""ication, but all of them apply the E@ules Cumulative 2trengthF values on the E(utput ?embership +unctionF. +or e&ample, output membership function for the e&ample may be something li%e this *he cumulative strengths calculated in the e&ample areG 2H'A*H0.N 2D(*HID$H0.#5 2C((,H0.I7

Defu++ifi%ation Fu++y Centroi4 &lgorith1


'ach response membership graph is clipped to calculated strength value, then fu""y (@ applied and finally the ECenter (f $ravityF point is calculated for the cumulative polygon. *he W a&is value of the C($ point is the crisp control output to drive the system, +or our e&ample, the crisp output calculation as followsG
CcoolX2cool K CnoopX2noop K CheatX2heat 2cool K 2noop K 2heat

H (utput

9here C is for EcentroidF, i.e. ma&imum value.


- 600X0.I7 K 0X0.#5 K 600X0.N. J -0.I7K0.#5K0.N. H K#8.##N

Defu++ifi%ation s%aling instea4 of %li**ing


2caling the output membership graph instead of clipping is little bit more precise because when clipping the membership function some information is lost. However, the scaling method involves much more and comple& arithmetic calculations while the precision benefits are negligible. In most implementations the clipping method is preferred for practical use.

Design Tools for Fl i1*le1entation


>ifferent %ind of tools for implementation, simulation and visuali"ation of +u""y ,ogic designs been created. *he most common to this moment areG ?ath9or%s +u""y ,ogic *oolbo& for ?A*,AB fu""y*'CH %ernels for embedded microcontrollers, >25;s < 5C. 2peciali"ed +, design environment tools integrated into uC and e&pert design tools. Analog fu""y >esign tools and tool%its

TUNNING THE FL CONTROL SYSTEM

Tuning the FL %ontrol fun%tion


*he simple graphical and intuitive representation of membership functions allows simple and intuitive tuning of +, control function while it wor%s. *he rules usually represent the hard system response while the membership functions affect on when and how strong the reaction would be. *he tuning and adaptation of +, control function usually performed by changing the shape parameters of membership curves and the overlap between them. *he tuning functionality may be made in the development stage or to be inherently assimilated in the design to perform automotive adaptation during operation.

Tuning the FL %ontrol fun%tion


*he Control behavior 5erformance 'valuation module may be a Deural Detwor% function or a human operator. *his functionality may be temporary -only while the system is in tuning or ElearningF phase. or permanent -in adaptive control systems..

You might also like