Вы находитесь на странице: 1из 42

Fuzzy Logic

Experts System
 ESs are computer programs that emulate the reasoning
process of a human expert or perform in an expert manner
in a domain for which no human expert exists.
 Computer Application that performs a task that would
otherwise be performed by a human expert. For example,
there are expert systems that can diagnose human illnesses,
make financial forecasts, and schedule routes for delivery
vehicles. Some expert systems are designed to take the
place of human experts, while others are designed to aid
them.
Experts System
 Expert systems are part of a general category of computer
applications known as artificial intelligence .
 To design an expert system, one needs a knowledge
engineer, an individual who studies how human experts
make decisions and translates the rules into terms that
a computer can understand.
What is Fuzzy Logic?

 Definition of fuzzy
 Fuzzy – “not clear, distinct, or precise; blurred”

 Definition of fuzzy logic


 A form of knowledge representation suitable for notions that cannot
be defined precisely, but which depend upon their contexts.

 Fuzzy logic is an approach to computing based on “degree of truth”


rather than the usual true or false logic on which modern system is
based
Traditional Representation of Logic

bool speed;
get the speed
if ( speed == 0) {
// speed is slow
}
else {
// speed is fast
Slow Fast }
Speed = 0 Speed = 1
Fuzzy Logic Representation
Slowest
 For every problem
[ 0.0 – 0.25 ]
must represent in terms
of fuzzy sets.
Slow
[ 0.25 – 0.50 ]

Fast
[ 0.50 – 0.75 ]

Fastest
[ 0.75 – 1.00 ]
Crisp (Traditional) Variables
 Crisp variables represent precise quantities:
 x = 3.1415296
 A {0,1}
 A proposition is either True or False
 ABC
 King(Richard)  Greedy(Richard) 
Evil(Richard)
 Richard is either greedy or he isn't:
 Greedy(Richard) {0,1}
Fuzzy Sets
 What if Richard is only somewhat greedy?
 Fuzzy Sets can represent the degree to which a quality is
possessed.
 Fuzzy Sets (Simple Fuzzy Variables) have values in the
range of [0,1]
 Greedy(Richard) = 0.7
Fuzzy Linguistic Variables
 Fuzzy Linguistic Variables are used to represent qualities
spanning a particular spectrum
 Temp: {Freezing, Cool, Warm, Hot}
 Membership Function
 Question: What is the temperature?
 Answer: It is warm.
 Question: How warm is it?
Fuzzy Logic
Fuzzification
 Fuzzifier converts a crisp input into a vector of fuzzy
membership values.
 The membership functions
 reflects the designer's knowledge
 provides smooth transition between fuzzy sets
 are simple to calculate
 Typical shapes of the membership function are Gaussian,
trapezoidal and triangular.
Membership Functions
 Membership functions are used to convert the crisp value
into fuzzy value.
 A membership function curve defines that how each point
in the input space is converted into membership value.
 There are different types of membership function
including triangular, trapezoidal, generalized bell shaped,
Gaussian curve, polynomial curve, and sigmoid function.
Example: Triangular Membership Functions
 a, b and c represent the x coordinates of the three vertices of
µA(x) in a fuzzy set A (a: lower boundary and c: upper
boundary where membership degree is zero, b: the centre
where membership degree is 1)

0 if x  a 
x a 
 if a  x  b 
 
 A ( x)   b  a 
c  x if b  x  c 
c  b 
0 if x  c 
 
Membership Functions
 Temp: {Freezing, Cool, Warm, Hot}
 Degree of Truth or "Membership"

Freezing Cool Warm Hot


1

0
10 30 50 70 90 110
Temp. (F°)
Membership Functions
 How cool is 36 F° ?

Freezing Cool Warm Hot


1

0
10 30 50 70 90 110
Temp. (F°)
Membership Functions

 How cool is 36 F° ?
 It is 30% Cool and 70% Freezing

Freezing Cool Warm Hot


1
0.7

0.3

0
10 30 50 70 90 110
Temp. (F°)
Fuzzy Rules
 Fuzzy rules has the form
If x is A then y is B
 A & B are fuzzy sets
 Antecedent is ‘x is A’
 Consequent is ‘y is B’
 Examples of everyday rules are:
 If it is dark, then drive slowly
 If the tomato is red, then it is ripe
 If the washing machine is half full, then wash shorter time
Rule Evaluation
 To evaluate the disjunction of the rule antecedents, we use
the OR fuzzy operation. Typically, fuzzy expert systems
make use of the classical fuzzy operation union:
 Similarly, in order to evaluate the conjunction of the rule
antecedents, we apply the AND fuzzy operation
intersection
Classic/Crisp/Boolean Logic
 Logical AND (∩) • Logical OR (U)
Truth Table
Truth Table
A B A∩B A B AUB
0 0 0 0 0 0
0 1 0 0 1 1
1 0 0 1 0 1
1 1 1 1 1 1
A
B A
B

Crisp Intersection Crisp Union


Fuzzy Union
 The most commonly used method for fuzzy union is to
take the maximum. That is, given two fuzzy sets A and B
with membership functions µA(x) and µB(x)
 AUB ( x)  max(  A ( x),  B ( x))
Fuzzy Intersection
 The most commonly used method is the minimum. That
is, given two fuzzy sets A and B with membership
functions µA(x) and µB(x)

 AB ( x)  min(  A ( x),  B ( x))


Fuzzy Complement
 To be able to develop fuzzy systems we also have to deal
with NOT or complement.
 This is the same in fuzzy logic as for Boolean logic
 For a fuzzy set A, A denotes the fuzzy complement of A
 Membership function for fuzzy complement is

 ( x )  1   A ( x)
A
Example 1:
Suppose we have the following (discrete) fuzzy sets:
A = 0.4/1+0.6/2+0.7/3+0.8/4
B = 0.3/1+0.65/2+0.4/3+0.1/4
The union of the fuzzy sets A and B
= 0.4/1+0.65/2+0.7/3+0.8/4
The intersection of the fuzzy sets A and B
= 0.3/1+0.6/2+0.4/3+0.1/4
The complement of the fuzzy set A
= 0.6/1+0.4/2+0.3/3+0.2/4
Example 2
Given two fuzzy sets A and B

a. Calculate the of union of the set A and set B


b. Calculate the intersection of the set A and set B
c. Calculate the complement of the union of A and B

A  0.0 /  2  0.3 / 1  0.6 / 0 1.0 / 1  0.6 / 2  0.3 / 3  0.0 / 4

B  0.1/  2  0.4 / 1 0.7 / 0 1.0 / 1 0.5 / 2  0.2 / 3  0.0 / 4


Example 2 (cont)

a
Union  max (A, B)  0.1 /  2  0.4 /  1  0.7 / 0  1.0 / 1  0.6 / 2  0.3 / 3  0.0 / 4

b
Intersecti on  min (A, B)  0.0 /  2  0.3 /  1  0.6 / 0  1.0 / 1  0.5 / 2  0.2 / 3  0.0 / 4

c
Complement of (b)  1 - max(A, B)  0.9 /  2  0.6 /  1  0.3 / 0  0.0 / 1  0.4 / 2  0.7 / 3  1.0 / 4
Defuzzification
 After the inference step, the overall result is a fuzzy value
 This value should be defuzzified to obtain a final crisp
output
 It is an interface with the crisp model of the world
 Defuzzification is performed according to the membership
function of the output variable
 Some of the techniques of the defuzzification include:
centroid defuzzification technique, weighted average
defuzzification technique etc.
Drawbacks to Fuzzy logic
 Requires tuning of membership functions
 Fuzzy Logic control may not scale well to large or
complex problems
 Deals with imprecision, and vagueness, but not
uncertainty
Fuzzy Logic Example
 The problem is to estimate the level of risk involved in a
software engineering project. For the sake of simplicity
conclusion based on two inputs: project funding and
project staffing.

“This example is taken from the second edition of the "Artificial Intelligence: A
Guide to Intelligent Systems" book by Michael Negnevistky.”
http://petro.tanrei.ca/fuzzylogic/fuzzy_negnevistky.html
Fuzzy Logic Example : Step 1
 The first step to convert the crisp input into a fuzzy one.
Since we have two inputs we will have 2 crisp values to
convert. The first value the level of project staffing. The
second value is the level of project funding.
 Suppose our inputs are project_funding=
35% and project_staffing = 60%. Next step is to get the
fuzzy values for these crisp values by using the
membership functions of the appropriate sets. The sets
defined.
 Sets defined for project_funding are inadequate, marginal
and adequate.
 Sets defined for project_staffing are small and large.

Fuzzy Logic Example : Step 1
 Following fuzzy values for the project_funding are:
Fuzzy Logic Example : Step 1
 Visual representation of this procedure
Fuzzy Logic Example : Step 1
 Following fuzzy values for the project_staffing are:
Fuzzy Logic Example : Step 1
 Visual representation of this procedure
Fuzzy Logic Example : Step 2
 The next step is to know what fuzzy rules are available to
arrive at the final fuzzy value. The rules which we have
are:
 If project_funding is adequate or project_staffing is small then
risk is low.
 If project_funding is marginal and project_staffing is large
then risk is normal.
 If project_funding is inadequate then risk is high.
Rule 1 - If project_funding is adequate or
project_staffing is small then risk is low
 Rules containing disjunctions, OR, are evaluated using
the UNION operator.
Rule 2 - If project_funding is marginal and
project_staffing is large then risk is normal
 Conjunctions in fuzzy rules are evaluated using
the INTERSECTION operator.
Rule 3 - If project_funding is inadequate then risk is
high
 fuzzy rules are evaluated using.
Fuzzy Logic Example : Step 3
 The next step is to evaluate the rules:
 The result of evaluating the rules is shown below:
Fuzzy Logic Example : Step 4
 The defuzzification can be performed in several different
ways. The most popular method is the centroid method.
 Centroid Method: Calculates the center of gravity for the
area under the curve.
Fuzzy Logic Example : Step 4
 We chose the centroid method to find the final non-fuzzy
risk value associated with our project. This is shown
below.

 The result is that this project has 67.4% risk associated


with it.
Slides taken from different websites

Вам также может понравиться