Fuzzy Logic: Fuzzy Logic Allows Reasoning With Vague Descriptions Which Can Be True To Some Degree
Fuzzy Logic: Fuzzy Logic Allows Reasoning With Vague Descriptions Which Can Be True To Some Degree
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
e.g. John has passed his driving test e.g. John is tall
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
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
Fuzzy sets are useful for dealing with vague properties (attributes) of objects
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
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
0 0 LB
8 UB
First we need a lower bound (LB) for height and an upper bound (UB)
0 0 LB
8 UB
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
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
0 0 LB
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
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
Linguistic hedges
In everyday language we use terms such as slightly or very to reduce or accentuate a property:
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:
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
this will increase the membership for a crisp value less than 1
very: power 2
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.
membership degrees rise less quickly at the lower end of the crisp scale, e.g.
De-fuzzification
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
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
Suppose a fuzzy variable called rainfall has three qualifiers: light, medium and heavy The membership functions are:
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:
Now find the centre of gravity of the shaded area on the crisp axis
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):
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
down
slope
up
up
triangle
down
up
trapezoid
down
The basic shapes consist of joined-up line segments Where these slope we can make them curved using a curvature parameter
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
crisp range (miles per hour): 0-200 qualifiers: slow, medium and fast de-fuzzifier: peak
Fuzzy rules
Example:
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 ) ).
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.
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
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
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
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
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)
Fuzzy matrices
Then the rules can be specified in a single statement called a fuzzy matrix (or a fuzzy associative memory)
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
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
ranges for crisp values meaningful qualifier names basic shape and line segment boundaries for qualifiers
cold, cool, normal, warm, hot. weak, low, ok, strong, high negative_large, negative_medium, negative_small, zero, positive_small, positive_medium, positive_large
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
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 ;
% 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