0% found this document useful (0 votes)
60 views45 pages

Fuzzy Logic: Fuzzy Logic Allows Reasoning With Vague Descriptions Which Can Be True To Some Degree

Fuzzy logic allows reasoning with vague or uncertain statements by assigning them degrees of membership in fuzzy sets rather than binary true/false values. It represents vagueness using membership functions that assign a value between 0 and 1 to indicate the degree to which an element belongs to a fuzzy set. Fuzzy rules then allow reasoning from these vague conditions to determine membership values for conclusions. Key concepts include fuzzy variables with linguistic qualifiers, fuzzification of crisp inputs, hedges to modify membership functions, and defuzzification to obtain a crisp output value from fuzzy memberships.

Uploaded by

familyuma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views45 pages

Fuzzy Logic: Fuzzy Logic Allows Reasoning With Vague Descriptions Which Can Be True To Some Degree

Fuzzy logic allows reasoning with vague or uncertain statements by assigning them degrees of membership in fuzzy sets rather than binary true/false values. It represents vagueness using membership functions that assign a value between 0 and 1 to indicate the degree to which an element belongs to a fuzzy set. Fuzzy rules then allow reasoning from these vague conditions to determine membership values for conclusions. Key concepts include fuzzy variables with linguistic qualifiers, fuzzification of crisp inputs, hedges to modify membership functions, and defuzzification to obtain a crisp output value from fuzzy memberships.

Uploaded by

familyuma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 45

Fuzzy Logic

Fuzzy logic allows reasoning with vague descriptions which can be true to some degree

Representing vagueness

Ordinary logic (propositional and first order) deals with statements which are either true or false

called Boolean truth values

This works provided statements can be determined precisely to be true or false

e.g. John has passed his driving test e.g. John is tall

But often knowledge is expressed in vague statements

It can be difficult to assign true or false to such a statement

the truth value seems to be somewhere in between

Fuzzy sets - how true is true?


Sets and logic are closely related Let D be the set of people who have passed their driving test John has passed his driving test is true means: John D An element is either in a set or it is not

belongs to the set = true not belongs to the set = false


If you know John you may feel this is fairly true If Peter is taller, then it is more true of Peter

What about John is tall?


Fuzzy sets

A fuzzy set allows elements to belong to it to a particular extent This is called the degree of membership. It varies between 0 and 1

0 corresponds to does not belong at all (false) 1 corresponds to belongs completely (true) Values between 0 and 1 indicate partial belonging

the larger the value, the greater is the degree of membership

Fuzzy sets are useful for dealing with vague properties (attributes) of objects

like tall or middle-aged or slow

Fuzzy versus crisp

An ordinary set is said to be crisp

and its elements are also crisp

Usually with vague properties there is an underlying concrete or crisp or precise measurement scale

tall is a description of height: crisp scale metres middle-aged is a description of age: crisp scale years slow is a description of speed: crisp scale miles per hour

To reason with vague properties, we have to relate them to their underlying crisp scale

Defining the membership function


What is a sensible definition of tall? It depends on the context

6 feet is tall for a person but not for a tree!

The membership function for tall is a graph of degree of membership of the fuzzy set tall against the crisp scale Lets deal with people. Suppose:

Below 5 feet is definitely not tall Above 6 feet is definitely tall In between 5 and 6 feet is tall to some degree

We are clear about the graph beneath 5 feet and above 6 feet

In between is harder to specify

Graphing membership functions


1 membership

0 0 LB

5 Height crisp value (feet)

8 UB

First we need a lower bound (LB) for height and an upper bound (UB)

All heights must be between these two values Set LB = 0; UB = 8

Graphing membership functions ctd


1 membership

0 0 LB

5 Height Crisp value (feet)

8 UB

Between 5 and 6 feet the graph is linear

51/2 feet has membership of 0.5 of the fuzzy set tall degree of membership will then rise more quickly or more slowly with changes in crisp value

We could make it curved

Fuzzy variable

Notice that our membership function for tall describes one part of the height measurement scale There are other fuzzy height properties e.g. small, mediumsized Each of these can be regarded as values of a fuzzy variable for height

i.e. the fuzzy height variable has values small, medium-sized and large

These values are called the linguistic qualifiers of height Each qualifier has its own membership function

Fuzzy variable ctd


small 1 membership medium-sized tall

0 0 LB

4 Height crisp value (feet)

8 UB

We can plot all three membership functions on the same graph Any crisp height (e.g. 51/2 feet) has a membership degree for each qualifier

these are usually different

Fuzzification

The process of converting a crisp input value to membership values for each qualifier is called fuzzification In the height example, suppose we input 5 feet 6 inches. We require the degree of membership of qualifiers small, medium-sized and tall Reading from the membership functions we get:
small: 0 medium-sized: 0.55 tall: 0.8

Thus the fuzzy variable has three different degrees of membership

Linguistic hedges

In everyday language we use terms such as slightly or very to reduce or accentuate a property:

it is very hot; I am slightly sad

In fuzzy logic these terms are called linguistic hedges Suppose we have a fuzzy variable mood with qualifiers sad and happy We will define two hedges:

slightly and very


slightly sad, sad, very sad, slightly happy, happy, very happy

These may be used with either qualifier, so we can say:

Hedges - an example

Hedges are often implemented by applying a power function to the basic membership graph
This will bend the membership graph for degrees <1 A degree of 1 will not change To accentuate use a power > 1

this will decrease the membership for a crisp value less than 1

e.g 0.52 0.25

To de-accentuate use a power between 0 and 1

this will increase the membership for a crisp value less than 1

e.g 0.50.2 0.87

For our hedges use


slightly: power 0.2

very: power 2

Hedges - an example ctd

Here is the basic membership function for happy:

Apply power 0.2 for slightly happy:

Apply power 2 for very happy:

Hedges - an example ctd

The dotted line shows the original membership function for happy To get 0.5 for happy, a person must score 40 The effect of the slightly hedge is

membership degrees rise more quickly at the lower end of the crisp scale as compared to the basic happy function, e.g.

for slightly happy a score of 10 has membership of 0.5

The effect of the very hedge is

membership degrees rise less quickly at the lower end of the crisp scale, e.g.

for very happy a score of 70 is needed for membership of 0.5

De-fuzzification

It is straightforward to convert a crisp value (fuzzify):

read off the various qualifier memberships

But suppose we have qualifier memberships how do we convert back to a single crisp value The qualifiers might conflict, e.g. for the height variable suppose:

small has degree 0.8 medium-sized has degree 0.5 tall has degree 1

These degrees conflict

There is no single crisp value that has all these memberships

De-fuzzification ctd

It is one of the strengths of fuzzy logic that it can handle this situation and produce a compromise crisp value Producing a single crisp value from a collection of membership degree is called de-fuzzification There are various methods Two of the most popular are:

centroid

finds an average or centre of gravity of the various degrees. uses only the qualifier with the highest degree and produces a crisp value from it

peak

The centroid method

Suppose a fuzzy variable called rainfall has three qualifiers: light, medium and heavy The membership functions are:

Assume the qualifiers have values:


light 0.75, medium 0.25 and heavy 0

The centroid method ctd

The centroid method takes the membership function for each qualifier and cuts off any portion of the function which contains values above the current value for the qualifier So the light qualifier would have a cut-off point at 0.75:

The centroid method ctd

The medium qualifier would be cut off at 0.25:

The heavy qualifier would be cut off at 0

So there would be no shaded area beneath the cut-off

The centroid method ctd

Combining the cut-offs produces:

The heavy shaded is counted twice

it belongs to both light and medium qualifiers

Now find the centre of gravity of the shaded area on the crisp axis

with the dark area rated twice as heavy

The peak method


The qualifier with the highest membership is light Crop its membership function at the given value, 0.75 Take the mid-point crisp value directly underneath the cropped peak (the plateau):

The FLINT toolkit

The FLINT toolkit in Win-Prolog supports


design and implementation of fuzzy variables (and hedges) reasoning with fuzzy variables using fuzzy rules (considered later)

Either Prolog syntax is used A graphic design tool (the fuzzy editor) is available on the Run menu

Can be used to

define qualifiers draw membership functions specify de-fuzzification method

Membership function shapes

There are six basic linear shapes:

down

slope

up

up

triangle

down

up

trapezoid

down

Adding curvature to the basic shapes


The basic shapes consist of joined-up line segments Where these slope we can make them curved using a curvature parameter

values lie between 0.1 and 9

Defining fuzzy variables in FLINT

A fuzzy variable is defined as a rule for the built-in predicate fuzzy_variable/1 The basic shapes are defined using symbols:

For a line segment, use keyword linear For a curved segment use curved(P) where P is a value between 0.1 and 9.9

Example

Define a fuzzy variable speed:


crisp range (miles per hour): 0-200 qualifiers: slow, medium and fast de-fuzzifier: peak

Fuzzy rules

A fuzzy rule consists of:

conditions involving fuzzy variables

joined using and, or or not

a conclusion involving a single fuzzy variable (with an optional else statement)

Example:

Fuzzy rules ctd

Keywords such as: if, and, then, else are not normally available in Prolog These must be defined as operators and compiled before the fuzzy rule syntax is valid The required definitions are:
:op( op( op( op( op( op( op( 1200, xfy, ( if ) ), 1200, xfy, ( then ) ), 1200, xfx, ( else ) ), 1100, xfy, ( or ) ), 1000, xfy, ( and ) ), 700, xfx, ( is ) ), 600, fy, ( not ) ).

The fuzzy reasoning process

A fuzzy rule uses the existing membership values of its conditions to determine a membership value for the qualifier in its conclusion This is called propagation of membership values.

Each condition will be true to a particular degree, e.g.

the qualifier long of the fuzzy variable duration might have membership value 0.25

To obtain the overall truth value of the whole condition we combine the degrees of membership of each qualifier mentioned This combined value is then the membership value for the conclusion qualifier

Combining membership values


Qualifiers in the condition can be joined by and, or or not There are several methods of dealing with each of these Suppose X P is the degree of membership for P. The common
methods are shown below:
Expression
P and Q

Method
minimum product

Description
min(X P , X q ) XP * Xq max(X P , X q ) 1- X P

P or Q not P

maximum complement

Example

Consider fuzzy rule:


fuzzy_rule( a4 ) :if voltage is low and (current is low or current is medium) then delta_current is high else delta_current is low.

The condition fuzzy variables are:

voltage, current
voltage: low 0.3 current: low 0.7, medium 0.5 Truth value of condition is: min(0.3, max(0.7, 0.5)) = 0.3

Suppose the membership values are:


Use the minimum method for and, maximum method for or

Thus membership value for qualifier high of delta_current variable in conclusion is set to 0.3 Membership value for qualifier in else statement is 1 - value in then part: 1 - 0.3 = 0.7 for delta_current low

Activating fuzzy reasoning

Fuzzy rules are run using the predicate


fuzzy_propagate( Conjunction, Disjunction, Negation, Agenda )

Arguments 1 to 3 state the methods of combination to be applied (see above) Agenda is a list of names of the fuzzy rules to be used in the reasoning

The Agenda argument may also be the name of a fuzzy rule matrix (see below)

Each rule in the agenda is applied once Example:


?- fuzzy_propagate( minimum, maximum, complement, [t1, t2, t3] ).

Fuzzy matrices

Often a set of fuzzy rules involves

the same condition variables in every rule

only the qualifiers change

conditions are joined by and

Then the rules can be specified in a single statement called a fuzzy matrix (or a fuzzy associative memory)

The structure of a fuzzy logic program

A fuzzy logic program has three stages:

Stage 1 Fuzzification

The crisp input values are assigned to the appropriate input fuzzy variables The crisp input value is converted into a degree of membership for each of the qualifiers for the fuzzy variable it is assigned to Fuzzy rules are applied to the fuzzy variables and their qualifiers The degrees of membership for the qualifiers in the conditions of the rule are propagated to the qualifiers in the conclusions of the rule The resultant degrees of membership for the qualifiers of the output fuzzy variables are converted back into crisp values

Stage 2 Propagation

Stage 3 De-fuzzification

A complete fuzzy program: the steam turbine

Fuzzy logic is often used to create a controller for a device

A fuzzy turbine controller

The controller we will implement will use a fuzzy set of rules to adjust the throttle of a steam turbine according to its current temperature and pressure to keep it running smoothly

Program design

The program uses input values of temperature and pressure to set the level of the throttle Require:

Definitions of fuzzy variables for temperature, pressure and throttle Fuzzy rules linking temperature and pressure to throttle

rules should cover all cases of temperature and pressure receive the crisp input of temperature and pressure and fuzzify these propagate to throttle using the rules de-fuzzify to get a crisp throttle setting

A master program to

Fuzzy variable definitions

Talk to the turbine experts to find


ranges for crisp values meaningful qualifier names basic shape and line segment boundaries for qualifiers

This is a knowledge acquisition exercise Decide on:

Temperature: range 0 to 500 Celsius

cold, cool, normal, warm, hot. weak, low, ok, strong, high negative_large, negative_medium, negative_small, zero, positive_small, positive_medium, positive_large

Pressure: range 0 to 300 Kpa

Throttle: -60 to +60 (-ve move back, +ve move forward)

Fuzzy variable definitions: temperature


fuzzy_variable( temperature ) :[0 , 500 ] ; cold, \ , linear, [ 110 , 165 ] ; cool, /\, linear, [ 110 , 165 , 220 ] ; normal, /\, linear, [ 165 , 220 , 275 ] ; warm, /\, linear, [ 220 , 275 , 330 ] ; hot, /, linear, [ 275 , 330 ] .

Fuzzy variable definitions: pressure


fuzzy_variable( pressure ) :[0 , 300 ] ; weak, \ , linear, [ 10 , 70 ] ; low, /\, linear, [ 10 , 70 , 130 ] ; ok, /\, linear, [ 70 , 130 , 190 ] ; strong, /\, linear, [ 130 , 190 , 250 ] ; high, /, linear, [ 190 , 250 ] .

Fuzzy variable definitions: throttle


fuzzy_variable( throttle ) :[-60 , 60 ] ; negative_large, \ , linear, [ -45 , -30 ] ; negative_medium, /\, linear, [ -45 , -30 , -15 ] ; negative_small, /\, linear, [ -30 , -15 , 0 ] ; zero, /\, linear, [ -15 , 0 , 15 ] ; positive_small, /\, linear, [ 0 , 15 , 30 ] ; positive_medium, /\, linear, [ 15 , 30 , 45 ] ; positive_large, /, linear, [ 30 , 45 ] ; centroid . % need defuzzifier for crisp output

Fuzzy rules

Again, consult experts to obtain rules expressed in fuzzy qualifiers linking temperature and pressure inputs to throttle output Three examples of rules provided are:
fuzzy_rule(throttle1) if temperature is cold and pressure is weak then throttle is positive_large. fuzzy_rule(throttle2) if temperature is hot and pressure is high then throttle is negative_large. fuzzy_rule(throttle3) if temperature is normal and pressure is ok then throttle is zero.

Fuzzy matrix

Temperature and pressure each have five qualifiers.

Therefore need 25 rules to deal with every temperature and pressure combination all have temperature and pressure conditions which are anded
fuzzy_matrix( t ) :temperature* pressure -> throttle ; cold * weak -> positive_large ; cold * low -> positive_medium ; cold * ok -> positive_small ; cold * strong -> negative_small ; cold * high -> negative_medium ;

Simpler to express using fuzzy matrix

Part of fuzzy matrix:

% etc

Master program

Define a Prolog rule to link all parts of the fuzzy controller together:
find_throttle( Temperature, Pressure, Throttle ) :% throttle membership initialised: fuzzy_reset_membership( throttle ), % fuzzify temperature and pressure inputs: fuzzy_variable_value( temperature, Temperature ), fuzzy_variable_value( pressure, Pressure ), % apply fuzzy matrix to get throttle memberships: fuzzy_propagate( minimum, maximum, complement, [t] ), % de-fuzzify throttle to get crisp output: fuzzy_variable_value( throttle, Throttle ).

Sample query:
?- find_throttle( 300, 150, Throttle ) . Throttle = -26.040413058933

You might also like