Introduction
NN & FL
Artificial Intelligence
Artificial Intelligence (AI) is a branch of science that is concerned with the automation of intelligent behavior.
it is possible to build machines that can demonstrate intelligence similar to human beings.
A I can be obtained in two ways. soft computing methods (NN, FL, GA etc) Hard computing methods (conventional PID cont.
etc)
Artificial Intelligence
Hard computing methods are predominantlybased on mathematical approaches .
Soft computing techniques have drawn their inherent characteristics from biological systems
Soft computing methods are
Neural networks
Fuzzy logic
Genetic algorithms
Combination of above
Neural Networks
Neural Networks (NN) are simplified models of
the biological nervous systems
An NN can be massively parallel and therefore is
said to exhibit parallel distributed processing
NN architectures have been broadly classified as
Single layer feed forward networks.
Multi layer feed forward networks and
Fuzzy Logic
Fuzzy logic is a set of mathematical principles forknowledge representation based on themembership function
Fuzzy logic provides simple way to draw definiteconclusions from vague, ambiguous or impreciseinformation.
Fuzzy logic is similar to that of Boolean logic
Fuzzy Logic
If the Level is low then open V1
If the Level is High then Close V1
If the level is Medium then open V1 by 50%
Need of fuzzy logic controller
Rigorous mathematical model of some linear process.
in the case of complex process, which are difficult to model.
Non-Linear Systems
Comparison of conventional & fuzzy logiccontrollers:
Sets & Fuzzy Sets
Fuzzy Logic
Set (Crisp set)
Well defined collection of objects
If X is Universe of discourse
(Universal set)
A is any set from X.
x is any element in X
Set & membership function
Def: Let X be the universe of discourse and its elements be denoted as x.
In the classical set theory, crisp set A of X is defined as: Called membership function of A
where
)(xfA
1,0:)( XxfA
Axif
AxifxfA
0
,1)(
membership function (crisp set)
Crisp set of “ tall persons”
Degree of
Membership
Figure 1: A crisp way of modeling tallness
membership function (crisp set)
Figure 2: The crisp version of short
Crisp set of “ Short persons” or “ NOT tall ”
membership function (crisp set)
Different heights have same ‘tallness’
Fuzzy Set
Def: Let X be the universe of discourse and its elements be denoted as x.
In the fuzzy set theory, fuzzy set A of X is defined as: Called membership function of fuzzy set A
Where
1...0:)( toXxA
)( xA
Ainpartiallyisxifx
Ainnotisxif
Aintotallyisxif
x
A
A
,1)(0
,0
,1
)(
Fuzzy Sets & membership
The shape you see is known as the membership function
Degree of A = “Set of TALL persons”
membership
Fuzzy Sets & memberships
Shows two membership functions: ‘tall’
and ‘short’
Degree of
membership
Fuzzy Sets
Fuzzy Operations
Fuzzy Sets ( Notation)
Formal definition:
A fuzzy set A in X is expressed as a set of ordered pairs:
Universe or
universe of discourseFuzzy set
Membership
function
(MF)
}{ XxxxA A /))(,(
ExampleA = { ( x1, 0.2 ) ( x2, 0.8 ) ( x3, 0.4 ) }
Alternative Notation
A fuzzy set A can be alternatively denoted as follows:
i
iA
Xx x
xA
i
)(
i
iA
Xx
xA
)(
X is discrete
X is continuous
Note that S and integral signs stand for the union of
membership grades; “__” stands for a marker and does
not imply division.
Fuzzy Sets with Discrete Universes
Fuzzy set C = “desirable city to live in”
X = {SF, Boston, LA} (discrete and non ordered)
C = {(SF, 0.9), (Boston, 0.8), (LA, 0.6)}
Fuzzy Sets with Cont. Universes
Fuzzy set B = “temperature about 50 degrees”
X = Set of positive real numbers (continuous)
B = {(x, B(x)) / x in X}
0.5
40 50 c60
1
600
6050)5060(
)60(
5040)4050(
)40(
400
)(
xif
xifx
xifx
xif
xA
Fuzzy Sets with Cont. Universes
Fuzzy set B = “Age about 50 Years”
X = Set of positive real numbers (continuous)
B = {(x, B(x)) / x in X}
B xx
( )
1
150
10
2
Fuzzy Partition
Fuzzy partitions formed by the linguistic values “young”, “middle aged”, and “old”:
Set-Theoretic Operations
Union:
Intersection:
Complement:
BAC
BAC
A
Membership
value
Height
1.0
0.0
A
ShortB
Tall
Union (OR)
If you have x degree of faith in statement A, and y degree of faith in statement B, how much faith do you have in the statement A or B?
• Eg: How much faith in “that person is short ortall”
Union (OR)
Membership
value
Height
1.0
0.0
Short Tall
Take the max of your beliefs in each individual statement
The union of two fuzzy sets A and B is a new fuzzy set A B is defined as
))(,)((max)( xxx BABA
Intersection (AND)
If you have x degree of faith in statement A, and y degree of faith in statement B, how much faith do you have in the statement A and B?
• Eg: How much faith in “that person is short and tall”
Membership
value
Height
1.0
0.0
A
Short
B
Tall
Intersection (AND)
Membership
Height
1.0
0.0
A
Short
B
Tall The Intersection of Fuzzy Sets A and B
is a new fuzzy set
A B defined asShort and tall
))(,)((min)( xxx BABA
Complement ( NOT )
The degree to which you believe something is notin the set is 1.0 minus the degree to which you believe it is in the set
The complement of a fuzzy set A is a new fuzzy set A’
Membership
value
Units
1.0
0.0
FS
FS’
)(1)( xx AA C
0.7
0.3
X 1 X 2
Set-Theoretic Operations
Subset:
Union:
Intersection:
Complement:
))(,)((max)( xxx BABA
BA
BAC
BAC
A)(1)( xx AA C
))(,)((min)( xxx BABA
))()( xx BA
Equality of fuzzy sets:
The two fuzzy sets A and B are said to be equal (A =B)if
Example:
A = { (x1, 0.2) (x2, 0.8) }
B = { (x1, 0.6) (x2, 0.8) }
C = { (x1, 0.2) (x2, 0.8) }
A B and A = C
)()( xx BA
Product of two fuzzy sets:
The product of two fuzzy sets A and B is a new fuzzyset A B with a membership function defined as
Example:
A = { ( x1, 0.2 ) ( x2, 0.8 ) ( x3, 0.4 ) }
B = { ( x1, 0.4 ) ( x2, 0 ) ( x3, 0.1) }
A B = { ( x1, 0.08 ) ( x2, 0 ) ( x3, 0.04 ) }
)(.)()(. xxx BABA
Product of a fuzzy set with a crisp number:
Multiplying a fuzzy set A by a crisp number `a’ resultsin a new fuzzy product a. Ã with the membershipfunction
Example:
A = { ( x1, 0.2 ) ( x2, 0.8 ) ( x3, 1 ) } and
a = 0.5
Then a.A = { (x1, 0.1) (x2, 0.4)( x3, 0.5) }
)(.)(. xax AAa
Power of a fuzzy set
The’ k’ power of a fuzzy set A is a new fuzzy set whosemembership function is given by
Example:
A = { (x1, 0.4) (x2, 0.2) ( x3, 0.7) } and k = 2
Then
A2 = { (x1, 0.16) (x2, 0.04) ( x3, 0.49) }
k
A
k
A xx ])([)(
Difference:The difference of two fuzzy sets A and B is a newfuzzy set A - B is defined as
Example:
A = { ( x1, 0.2 ) ( x2, 0.5 ) ( x3, 0.6) }
B = { ( x1, 0.9 ) ( x2, 0.4 ) ( x3, 0.5) }
B’ = { ( x1, 0.1 ) ( x2, 0.6 ) ( x3, 0.5) }
A – B = { ( x1, 0.1) ( x2, 0.5) ( x3, 0.5 ) }
)( CBABA
Cardinality :
The cardinality of a set is the total membership of elements in the set
Example:
A = { ( x1,0.2 ) ( x2,0.8 ) ( x3,1) }
Card(A) = 0.2+0.8+1 = 2
Height:
The height of a fuzzy set is the highest membership value of its membership function.
Example: A = { (x1,0.2)( x2,0.8)( x3,1)}
Height(A) = 1
i
iA xACard )()(
)(max)( iA xAHeight
Support :
The support of a fuzzy set A is the set of elements whose degree of membership in A is greater than 0.
mathematically,
Example:
Support of fuzzy set A is the
open interval (10,20)
0)(/)( xXxASpt A1
0.5
10 15 20
α- Level Cut :
The α- cut of a fuzzy set A at α denoted as Aα, is the set of elements whose degree of membership in A is greater than or equal to α
mathematically,
)(/ xXxA A
10 20 30 40 50 60 70
Temperature
}60,50,40,30,20,10{2.0 A
}50,40,30,20{4.0 A
}40,30{6.0 A
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
Properties of fuzzy sets
Commutative:
Associative:
Distributive:
Identity:
ABBA ABBA
)()( CBACBA
)()( CBACBA
)()()( CABACBA
)()()( CABACBA
AA AXA A XXA
Properties of fuzzy sets
Idempotence:
Involution:
Demorgan’s Law:
AAA AAA
AA CC )(
CCC BABA )(CCC BABA )(
Problem:
Two fuzzy sets (discrete) are given as
Calculate the following fuzzy operations
1. :
2. Show that
3. Verify DeMorgan’s Laws
4. Cardinalities of , , and
5
2.0
4
3.0
3
5.0
2
1
1
0A
5
4.0
4
2.0
3
7.0
2
5.0
1
0B
CA
,
BA
,
BA, AB
CCC BABA )(
CB BA
A BAB BA
Crisp & Fuzzy Relations
Crisp/Fuzzy Relations
• A crisp relation represents the presence
or absence of association, interaction, or
interconnections between the elements of
two or more sets.
• Fuzzy relations allow various degrees or
strengths of relations between elements.
• A classical relation can be considered as
a set of pair of elements.
• A binary pair is denoted by (u, v).
Crisp or classical Relation
Notation: Crisp or classical Relation
},|),{( ByAxyxR
Definition
Let A is set defined on X and B is another set defined on Y.
Then a relation R of A and B is
“ Set of element pairs each pair consists elements from
both the sets”
Cartesian Product
Cartesian product X X Y is Set of All possible element pairs
},(|),{( YyXxyxYX
Membership function
• Membership function of a classical relation
is given by
Ryxif
Ryxif
yxR
),(0
),(1
),(
1. Crisp Relations• Example 1: Let X and Y be two sets given as follows.
Present the relation R: “x is smaller than y” in the form of a
relational matrix
X = { 1,2,3 }, Y = { 2,3,4 }, R: x<y
R = { (1,2),(1,3),(1,4),(2,3),(2,4),(3,4) }.
R =
x/y 2 3 4
1
2
3
1 1 1
0 1 1
0 0 1
Fuzzy RelationDefinition
Let assume that X and Y are sets. Fuzzy relation R of
X and Y is a fuzzy subset of X x Y represented as pair
of elements and its membership function
R x y x y x y X YR {(( , ), ( , ))|( , ) }
))(),(min(),( yxyx BAR
Membership functionIf A and B are two fuzzy sets on X and Y
Then membership function is
2. Fuzzy Relations• Example 2: Let X and Y be two sets given as follows.
Present the relation R: “x is approximately equal to y” in
the form of a relational matrix
X = { 1,2,3 }, Y = { 2,3,4 }, R:
R = { ((1,2),0.66),((1,3),0.33),((1,4),0.0),((2,2),1.0),
((2,3),0.66),((2,4), 0.33),((3,2),0.66),((3,3),1.0),((3,4),0.66) }.
R =
x/y 2 3 4
1
2
3
0.66 0.33 0
1 0.66 0.33
0.66 1 0.66
yx
2.2 Fuzzy Relations
• Example 3. Relation R is given as an association or
interconnection between (Tomato) fruit color and state.
Present R as a crisp relational matrix.
X = { green, yellow, red }, Y= { unripe, semi ripe, ripe}
R unripe semiripe ripe
green
yellow
red
1 0 0
0 1 0
0 0 1
R unripe semiripe ripe
green
yellow
red
1 0.5 0
0.3 1 0.4
0 0.2 1
2.3 Fuzzy Relations
Example:
Let A = { (x1, 0.2), (x2, 0.7), (x3, 0.4) } and
B = { (y1, 0.5), (y2, 0.6) } be two fuzzy sets
Find the fuzzy relation R resulting out of the fuzzy Cartesian product A x B
R = A x B =
)(),(min),(),( yxyxyx BABAR
4.04.0
6.05.0
2.02.0
3
2
1
x
x
x
21 yy
Operations on fuzzy Relations
1. Union
2. Intersection
3. Compliment
SR )),(),,(max(),( yxyxyxSRSR
SR
R ),(),( 1 yxyxRR
)),(),,(min(),( yxyxyxSRSR
Composition of crisp Relations
Let X,Y,Z are three sets
= ?
YXR :
ZYS :
ZXT :
SRT
}),(),,(),,(),,({ 33222111 yxyxyxyxR
}),(),,({ 2411 zyzyS }),({ 11 zxSRT
x1
x2
x3
y1
y2
Y3
y4
z1
z2
R S
X Y Z
Composition
}),({ 11 zxSRT
R y1 y2 y3 y4
x1
x2
x3
1 1 0 0
0 1 0 0
0 0 1 0
S z1 z2
y1
y2
y3
y4
1 0
0 0
0 0
0 1
}),(),,(),,(),,({ 33222111 yxyxyxyxR }),(),,({ 2411 zyzyS
R/S z1 z2
x1
x2
x3
1 0
0 0
0 0
Composition
})},(),,(min{
)},,(),,(min{
)},,(),,(min{
}),,(),,(min{{max),(
1441
1331
1221
111111
zyyx
zyyx
zyyx
zyyxzx
SR
SR
SR
SRSR
)},0,0min(),0,0min()0,1min(),1,1min({max),( 11 zxSR
},0,0,0,1{max),( 11 zxSR
Composition of Relations
Definition [Composition of Fuzzy Relations]
Let R and S are fuzzy relations, i.e.,
),/(),( ),,/(),( zyzySyxyxRZY
SYX
R
Composition of fuzzy relations,
R and S, is a fuzzy set defined by
),/(),( zxzxSRZX
SR
X Y Z
R S
SR
Composition
• Max-Min composition:
• The max-min composition of two fuzzy relations R
(defined on X and Y) and S (defined on Y and Z) is
)],(),([),( zyyxzx SRy
SR
Max-product composition:
)],().,([),( zyyxzx SRy
SR
Composition of Fuzzy Relations
• MAX-MIN composition
• MAX-PROD composition
},|)),(),,({(),( ZzXxzxzxzxSR SR
})},(),,(min{{max),( zyyxzx SRy
SR
}),().,({max),( zyyxzx SRy
SR
Composition of Fuzzy Relations
Example:
R =
S =
R S (x1, z1) = max { (min (0.5, 0.6), min (0.1, 0.5)) }
= max (0.5, 0.1) = 0.5
X = { x1, x2, x3 } Y = { y1, y2 } Z= { z1, z2, z3 }
21 yy
6.08.0
9.02.0
1.05.0
3
2
1
x
x
x
321 zzz
9.08.05.0
7.04.06.0
2
1
y
y
MAX-MIN composition
7.06.06.0
9.08.05.0
5.04.05.0
)6.0,7.0()6.0,4.0()5.0,6.0(
)9.0,2.0()8.0,2.0()5.0,2.0(
)01,5.0()1.0,4.0()1.0,5.0(
)9.0^60(),7.0^8.0()8.0^60(),4.0^8.0()5.0^60(),6.0^8.0(
)9.0^90(),7.0^2.0()8.0^90(),4.0^2.0()5.0^90(),6.0^2.0(
)9.0^10(),7.0^5.0()8.0^10(),4.0^5.0()5.0^10(),6.0^5.0(
MAX
MAX
SRT
9.08.05.0
7.04.06.0
6.08.0
9.02.0
1.05.0
oRoST
Composition of Fuzzy Relations
Example:
R =
S =
R S (x1, z1) = max { ( 0.5x 0.6), (0.1x 0.5)) }
= max (0.3, 0.01) = 0.3
X = { x1, x2, x3 } Y = { y1, y2 } Z= { z1, z2, z3 }
21 yy
6.08.0
9.02.0
1.05.0
3
2
1
x
x
x
321 zzz
9.08.05.0
7.04.06.0
2
1
y
y
MAX-PROD composition
56.048.048.0
81.072.045.0
35.02.03.0
)54.0,56.0()48.0,32.0()3.0,48.0(
)81.0,14.0()72.0,08.0()45.0,12.0(
)09.0,35.0()08.0,2.0()05.0,3.0(
)9.060(),7.08.0()8.060(),4.08.0()5.060(),6.08.0(
)9.090(),7.02.0()8.090(),4.02.0()5.090(),6.02.0(
)9.010(),7.05.0()8.010(),4.05.0()5.010(),6.05.0(
MAX
MAX
SRT
9.08.05.0
7.04.06.0
6.08.0
9.02.0
1.05.0
oRoST
Composition of Fuzzy Relations
• Example 4: R is a relation that describes an
interconnection between color x and ripeness y
of a tomato, and S represents an
interconnection between ripeness y and taste z
of a tomato.
Present relational matrices for the MAX-MIN and
MAX-PROD composition
Composition of Fuzzy RelationsThe rational matrix R (x-y connection) is given as
The rational matrix S (y-z connection) is given as
R (x,y) unripe semiripe ripe
green
yellow
red
1 0.5 0
0.3 1 0.4
0 0.2 1
S (y,z) sour sweet-sour sweet
unripe
semiripe
ripe
1 0.2 0
0.7 1 0.3
0 0.7 1
Composition of Fuzzy Relations
The MAX-MIN composition R= R 。S results in the
relational matrix
R (x,z) sour sweet-sour sweet
green
yellow
red
1 0.5 0.3
0.7 1 0.4
0.2 0.7 1
1)0,5.0,1())0,0min(),7.0,5.0min(),1,1(min( MAXMAX
4.0)4.0,3.0,0())1,4.0min(),3.0,1min(),0,3.0(min( MAXMAX
Composition of Fuzzy RelationsR (x,z) sour sweet-sour sweet
green
yellow
red
1 0.5 0.15
0.7 1 0.4
0.14 0.7 1
A linguistic interpretation in the form of rules for the
relational matrix above is as follows:
Rule1: IF the tomato is green, THEN it is sour, less likely
to be sweet-sour, and unlikely to be sweet.
Rule2: IF the tomato is yellow, THEN it is sweet-sour,
possibly sour, and unlikely to be sweet.
Rule3: IF the tomato is red, THEN it is sweet, possibly
sweet-sour, and unlikely to be sour.
Properties of Fuzzy Relations
x1
x2
x3
Y1
y2
Y3
y4
RX Y
Projection on X ( First projection ) is given by
Similarly calculate for all pairs, the X
projection is
Projection on Y ( Second projection ) is given by
Similarly calculate for all pairs, the Y projection is
Total projection is
Tolerance and Equivalence Relation
Crisp Equivalence Relation
R X x X
Relation has the following properties:
Reflexivity
Symmetry
Transitivity
Tolerance and Equivalence Relation
Reflexivity
X = { x1,x2,x3 } R X x X
(xi , xi ) R
or
µR (xi , xi ) = 1x1
x2
x3
Tolerance and Equivalence Relation
Symmetry (classical)
(xi xJ) R (xJ xi) R
or µR(xi xj) = µR(xj xi)
x1
x3
x2
Tolerance and Equivalence Relation
Transitivity: (Classical)
(xi xJ) R and (xJ xk) R (xi xk) R
or µR(xi xJ) = 1 and µR(xJ xk) = 1 µR(xi xk) = 1
x1 x2
x3
FUZZY LOGIC & FUZZY RULES
Linguistic variables
• Example:
Age = 65
Age is OLD
Temperature = { cold, cool, warm, hot }
Speed = { stop, slow, medium, fast }
Height = { short , medium , Tall }
Linguistic Value is a fuzzy set
Linguistic variable Linguistic Value
Linguistic Hedges
• Modifying the meaning of a fuzzy set using hedges such as very, more or less, slightly, etc.
• Very TALL
• Very very TALL
• More or less TALL
• etc.
tall
More or less tallVery tall
FUZZY LOGIC
What is Fuzzy Logic?• In Propositional Logic, truth values are either True or False
• Fuzzy logic is a type of Many-Valued Logic
• There are more than two truth values
• The interval [0,1] represents the possible truth values
• 0 is absolute falsity
• 1 is absolute truth
CRISP LOGIC
“Logic is a human capacity to reason” or “ Science of reasoning”
Proposition:
A statement which is either ‘True' or 'False' but not both
Example: P: Water boils at 90°C.
Q: Vapor is produced by water.
Connectives:
Disjunction ( ) OR
Conjunction () AND
Negation ( - or ~) NOT
Implication ()
Equivalence (=)
CRISP LOGIC
Let Sets A and B are defined from Universe X
P and Q are two propositions
P: truth that x Є A
Q: truth that x Є B
Disjunction ( ): P Q : x Є A or x Є B
Conjunction (): P Q : x Є A and x Є B
Implication (): P Q : x Є A or x Є B
CRISP LOGIC skip
Propositional logic connectives
Symbol Connective Usage Description
And P Q P and Q are true.
Or P Q Either P or Q is true,
¬ or ~ Not ~P or ¬ P P is not true.
implication P Q P implies Q is true.
= Equality P = Q P and Q are equal (in truth
values) is true.
Implication skip
P Q P Q
T T T
T F F
F T T
F F T
P Qq
p
qp
When in Rome, do like the Romans
Truth table
CRISP LOGIC skip
• The following table illustrates the truth table for the five connectives.
P Q P Q P Q ~ P P Q P = Q
T T T T F T T
T F F T F F F
F F F F T T T
F T F T T T F
Tautology / contradiction skip
• A formula which has all its interpretations recording true is known as a tautology and the one which records false for all its interpretations is known as contradiction.
Example:
• Obtain a truth table for the formula (P v Q) (~P). Is it a tautology?
P Q P Q ~P P Q ~P
T
F
T
F
F
T
T
F
T
T
T
F
F
T
F
T
F
T
F
T
it is not a tautology
Fuzzy logical operations
• AND, OR, NOT, etc.
• NOT A = A’ = 1 - A(x)
• A AND B = A B = min(A (x), B (x))
• A OR B = A B = max(A (x), B (x))
A not A
0.4 0.6
0.8 0.2
1-A
A B A or B
0.4 0.7 0.7
0.8 0.6 0.8
1 0.3 1
0.1 1 1
max(A,B)
A B A and B
0.4 0.7 0.4
0.8 0.6 0.6
1 0.3 0.3
0.1 1 0.1
min(A,B)
From the following
truth tables it is
seen that fuzzy
logic is a superset
of Boolean logic.
FUZZY RULES
Fuzzy Rules
• Rules often of the form:
IF x is A THEN y is B
where A and B are fuzzy sets defined on the universes of discourse X and Y respectively.
• if pressure is high then volume is small;
• if a tomato is red then a tomato is ripe.
where high, small, red and ripe are fuzzy sets.
Fuzzy Rules
• Crisp rule:
• Example:
“If Self is TALL and Enemy is SHORT, Then Attack.”
The Condition of a Rule:
“If Self is Tall and Enemy is Short”
• Fuzzy rule:
“ Self is 0.3 TALL and Enemy is 0.6 SHORT ” ,
Then 0.3 Attack
then this condition is 0.3 True.
So, should we attack?
Decision Making
• For example:
• Rule 1: If Self is TALL and Enemy is SHORT, then Attack
• Rule 2: If Self is BIG and Enemy is LEAN, then Attack.
• Rule 3: If Self’s Power is greater than 10,
and Self’s Health is greater than 5, then Attack.
Average of the 3 rules NOT TO ATTACK
0.6 0.8
0.6 0.9
0
0.6
0.6
0