Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 50

Artificial Intelligence

Lecture 9: Fuzzy Logic

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Outline
 Introduction
 What is fuzzy logic
 Linguistic term
 Membership function
 Characteristic of Fuzzy logic
 Why use Fuzzy logic
 Fuzzy logic Operations
 Fuzzy Logic Control Components
 Applications of Fuzzy Logic

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Introduction
 Egg-Boiling Fuzzy logic Robot
https://www.youtube.com/watch?v=J_Q5X0nTmrA

 Short Tutorial on Fuzzy Logic


http://cs.bilkent.edu.tr/~zeynep/files/short_fuzzy_logic_tutorial.pdf

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Motivation
 Experts rely on common sense when they solve problems.
 How can we represent expert knowledge that uses vague and
ambiguous terms in a computer?
 Fuzzy logic is not logic that is fuzzy, but logic that is used to
describe fuzziness. Fuzzy logic is the theory of fuzzy sets that
calibrate the vagueness.
 Fuzzy logic is based on the idea that all things admit of degrees, i.e.
temperature, height, speed, distance, beauty – all come on a sliding
scale.
 The motor is running really hot.
 Tom is a very tall guy.

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Boolean vs. Fuzzy Logic
 Temperature Example

Cold Hot

0 1

Cold Hot

[0 , 1]

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Logic Vs Boolean Logic
Crisp Fuzzy
Definitely
Yes
Are you under 40 Why not?
years of age? Are you young
No
………
Not that much

 Boolean logic can have only two possible values as 0/1, yes/no,
right/wrong etc.
 Fuzzy logic can be multi valued. It can have relative values like yes, no, not
so much, a little bit etc.
Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.
Fuzzy logic vs Probability theory

Imperfection

Uncertainty Vagueness

Probability
Fuzzy Logic
Theory

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Logic Vs. Probability
 Example:
 Let X be the set of all liquids (i.e., the universe of discourse) .
 Let L be a subset of X which includes all liquids suitable for
drinking.
 Suppose now that you find two bottles, A and B.
 The labels do not provide any clues about the contents.
 Bottle A label is marked as membership of L is 0.9.
 The label of bottle B is marked as probability of L is 0.9.
 Given that you have to drink from the one you choose, the
problem is of how to interpret the labels.

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Continued
 Membership of 0.9 means that the contents of A are fairly
similar to perfectly potable liquids.
 If, for example, a perfectly liquid is pure water then bottle A might
contain, say, tonic water.
 Probability of 0.9 means something completely different.
 You have a 90% chance that the contents are potable and 10%
chance that the contents will be unsavoury, some kind of acid
maybe.
 Hence, with bottle A you might drink something that is not pure
but with bottle B you might drink something deadly.
 So choose bottle A.

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Continued
 Opening both bottles you observe beer (bottle A) and hydrochloric
acid (bottle B).
 The outcome of this observation is that the membership stays the
same whereas the probability drops to zero.

 Probability measures the likelihood that a future event will


occur.

 Fuzzy logic measures the ambiguity of events that have already


occurred.

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Traditional representation of logic

Slow Fast
Speed = 0 Speed = 1

bool speed;
get the speed
if ( speed == 0) {
// speed is
slow
}
else {
// speed is
fast
Artificial Intelligence: A Modern Approach
} Peter Norvig and Stuart J.
Fuzzy Logic Representation
Slowest
[0.00 - 0.25 [

Every problem must Slow


represent in terms of fuzzy [ 0.25 – 0.50 [
sets.
Fast
[ 0.50 – 0.75 [

Fastest
[ 0.75 – 1.00 ]

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Logic Representation

Slowest Slow Fast Fastest


float speed;
get the speed
if ((speed >= 0.0)&&(speed < 0.25)) {
// speed is slowest
}
else if ((speed >= 0.25)&&(speed < 0.5))
{
// speed is slow
}
else if ((speed >= 0.5)&&(speed < 0.75))
{
// speed is fast
}
else // speed >= 0.75 && speed <= 1.0
{
// speed is fastest
}
Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.
Sets Theory
 Classical Set: An element  Fuzzy Set: An element belongs
either belongs or does not partially or gradually to the sets
belong to a sets that have been that have been defined.
defined.
X Y
XW W Z

A B

Fuzzy & gradual


Crisp
outline
outline
Classical Set: Fuzzy Set:
 W doesn’t belongs to A  W doesn’t belongs to B
 X belongs to A  Z completely belongs to B
 Y partially belongs to B
Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.
Fuzzy Logic
 Fuzzy means
 not clear, distinct or precise;
 not crisp (well defined);
 blurred (with unclear outline).
 A fuzzy set is a set with a smooth boundary.
 A fuzzy set is defined by a function that maps objects in a
domain of concern into their membership value in a set.
 Such a function is called the membership function.

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


FL Example
FRUITS VEGETABLES

X is either the fruit or not. Y is either vegetable or not


X= apple, or X=banana or Y=carrot or Y=green pepper,
X= pineapple, X=orange etc. or Y= potato, Y= broccoli etc.

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


FL Example
FRUITS VEGETABLES

X is either the fruit or not. Y is either vegetable or not


X= apple, or X=banan or Fruits or
Y=carrot or Y=capsicum,
X= pineapple, X=orange vegetables
or Y= potato, Y= broccoli
etc. ? etc.

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Set
 Let X be a non empty set
 A fuzzy set A in X is characterized by its membership function
 μA(x): X  [0,1]
 where μA(x) is the degree of membership of element x in fuzzy set
A for each x ∈ X.
 A fuzzy set has 3 principal properties:
 Range of values over which the set is mapped
 Degree of membership axis that measures a domain value's
membership in the set
 Surface of the fuzzy set - the points that connect the degree of
membership with the underlying domain
Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.
Membership function
Its membership in
Product X
the set
 Membership function can be defined
either by a formula, or by any explicit apple 1
list. banana 1
 X={apple, banana, pineapple, orange} pineapple 1
 Y={carrot, broccoli, green pepper
orange 1
, potato}
carrot 0
 ?={tomato, lemon}
green pepper 0
 If X is fruit the value is 1 and 0 if it is
vegetable. tomato 0.4

Artificial Intelligence: A Modern Approach lemon 0.6


Peter Norvig and Stuart J.
Fuzzy logic
 It has two different meanings as,
 In narrow sense: Fuzzy logic is a logical system, which is
an extension of multi-valued logic.
 In a wider sense: Fuzzy logic (FL) is almost synonymous
with the theory of fuzzy sets, a theory which relates to
classes of objects with unsharp boundaries in which
membership is a matter of degree.
 Fuzzy logic (FL) should be interpreted in its wider sense

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Logic
 Flexible machine learning technique
 Mimicking the logic of human thought
 Logic may have two values and represents only two possible
solutions
 Fuzzy logic is a multi valued logic and allows intermediate values
to be defined

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Logic
 Fuzzy logic is a branch of artificial intelligence that deals with
reasoning algorithms used to emulate human thinking and
decision making in machines.
 These algorithms are used in applications where process data
cannot be represented in binary form.
 Example:
 “The air feels cool”
 “He is young”
They are not discrete
 Fuzzy logic interprets vague statements like these so that they
make logical sense.

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Terminology

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Key Terms
 Fuzzy logic system
 Anything that uses fuzzy set theory
 Fuzzy control
 Any control system that employs fuzzy logic
 Fuzzy associative memory
 Any system that evaluates a set of fuzzy if-then rules uses
fuzzy inference. Also known as fuzzy rule base or fuzzy expert system
 Fuzzy inference control
 A system that uses fuzzy control and fuzzy inference

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Linguistic Terms
 In fuzzy logic, sets describing a fuzzy value are often called
linguistic terms.
 Set fruits or set vegetables can be also regarded as a linguistic term.
 Temperature can be like Cold, warm or hot
 The goal is to use the natural language in order to build fuzzy
expression
 product X is a fruit.
 Temperature t is cold.
 Term "very" intensifies the statement
 The membership function of set "very cold" must have a steeper
course than that one of set "cold".
Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.
Air Conditioner FL System Example (1)

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Logic System

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Air Conditioner FL System Example

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Air Conditioner FL System Example

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Air Conditioner FL System Example

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Temperature Controller (Fan) Example (2)
 The problem
 Change the speed of a heater fan, based on the room temperature and
humidity.
 A temperature control system has four settings
 Cold, Cool, Warm, and Hot
 Humidity can be defined by:
 Low, Medium, and High
 Using this we can define the fuzzy set.

 Linguistic variable is Temperature and


Humidity
 Linguistic values are (cold, cool, warm, hot),
(low medium and high)
Artificial Intelligence: A Modern Approach
 A is universe of discourse Peter Norvig and Stuart J.
Continued
 Universe of Discourse
 The Universe of Discourse is the range of all possible values
for an input to a fuzzy system.
 For example: Temperature(cold, cool, warm, hot), Humidity (low,
medium and high)

 Fuzzy Set
 A Fuzzy Set is any set that allows its members to have
different grades of membership (membership function) in the
interval [0,……,1]

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Continued…
 Support
 The support of a fuzzy set F is the crisp set (changing level) of all
points in the Universe of Discourse U such that membership
function of F does not equal zero
µF(u)>0
 Crossover point
It is an element in U where its membership
function equals 0.5.

 Centre
The centre of a fuzzy set F is the point (or
points) at which µF(u) achieves its maximum
value.A Modern Approach
Artificial Intelligence: Peter Norvig and Stuart J.
Fan Example

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Membership Function Types

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Characteristics of Fuzzy Logic
 Exact reasoning is viewed as a limiting case of approximate
reasoning
 Everything is a matter of degree
 Knowledge is interpreted as a collection of elastic or
equivalently fuzzy constraints on a collection of variables
 Inference is viewed as a process of propagating elastic
constraints
 Any logical system can be fuzzified

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Why use Fuzzy Logic?
 Conceptually easy to understand
 Flexible
 Tolerant of imprecise data
 FL can model nonlinear functions of arbitrary complexity
 FL can be built on top of the experience of experts
 FL can be blended with conventional control techniques
 FL is based on natural language

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Logic Operation

 The input to the fuzzy system is the output of the process, which is
entered into the system via input interfaces.
 Example: Temperature control application, the input data would be
entered using an analog input module
 Input is then moved through the fuzzy logic process

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Logic Control Components
 The three main actions performed by a fuzzy logic controller
are:
 Fuzzification : Membership functions used to graphically
describe a situation
 Fuzzy processing (Inference/Rules):
Application of the fuzzy logic rules
 Defuzzification: Obtaining the crisp results.

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Logic Control Components

 Fuzzification
 The fuzzy controller receives the input data, it translates it into a
fuzzy form.
 Fuzzy processing (fuzzy controller)
 The controller then performs fuzzy processing, which involves the
evaluation of the input information according to IF…THEN rules
created by the user during the fuzzy control system’s programming
and design stages.
 Defuzzification
 Once the fuzzy controller finishes the rule-processing stage and
arrives at an outcome conclusion, it begins the defuzzification process
Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.
Fuzzy logic process (Input)

 The processor would analyze a database to obtain an


output.

 Fuzzy processing involves the execution of IF...THEN


rules, which are based on the input conditions.

 An input’s grade specifies how well it fits into a particular


graphic set (e.g., too little, normal, too much).
Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.
Fuzzy logic process (Output)
 The output of a fuzzy controller is also defined by grades, with
the grade determining the appropriate output value for the
control element.

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Sample Fuzzy Rules
 IF temperature IS very cold THEN stop fan

 IF temperature IS cold THEN turn down fan

 IF temperature IS normal THEN maintain fan

 IF temperature IS hot THEN speed up fan

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Propositions
A fuzzy proposition is a statement that drives a fuzzy
truth value.
 Fuzzy Connectives: Fuzzy connectives are used to join
simple fuzzy propositions to make compound
propositions.
 Examples of fuzzy connectives are:
 Negation (not)
 Disjunction (and)
 Conjunction (or)
 Implication ()

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Simple Fuzzy Operators

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Fuzzy Rules
 The power and flexibility of simple If-Then-Else logic rules is
enhanced by adding linguistic parameter.

 Fuzzy rules are expressed in the form:


 IF linguistic_variable IS fuzzy_set_value THEN action

 Examples:
 IF temperature IS very cold THEN stop air conditioner
 IF temperature IS normal THEN adjust air conditioner
 IF temperature IS hot THEN start air conditioner

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


Application
 Photocopiers  Speech recognition
 Still and Video Cameras  Decision making
 Television  Image analysis
 Microwave Ovens  Scheduling
 Refrigerators
 Toasters
 Vacuum Cleaners
 Washing Machines
 Air Conditioners/Dryers/Heaters

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


.

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


References
 Short Tutorial
http://cs.bilkent.edu.tr/~zeynep/files/short_fuzzy_logic_tutorial.pdf
 Pdf Book
http://sc.uaemex.mx/xose/html/clases/logica/articles/libro_fuzzy_logic.p
df
 PowerPoint Slides
http://teaching.csse.uwa.edu.au/units/CITS7212/Lectures/Students/Fuzzy
.pdf
 Tutorial point
https://www.tutorialspoint.com/artificial_intelligence/artificial_intelligen
ce_fuzzy_logic_systems.htm

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.


End

Artificial Intelligence: A Modern Approach Peter Norvig and Stuart J.

You might also like