CS235 Artificial Intelligence 10
CS235 Artificial Intelligence 10
CS
Kaustuv Nag
/
Fuzzy Logic in Artificial Intelligence
/
Use of Fuzzy Logic
/
Fuzzy Logic Systems Architecture
Rules
Crisp Crisp
Fuzzifier Defuzzifier
Input Output
Intelligence
Fuzzy Input Set Fuzzy Output Set
/
Classical Set (Crisp Set)
▶ A classical set is a collection of distinct objects. For example, a set of students, a set
of even numbers etc.
▶ Each individual entity in a set is called a member or an element of the set.
▶ The classical set is defined such that the universe of discourse is split into two
groups: members and non-members. Hence, no partial membership exists.
▶ For example:
▶ A = {a1 , a2 , a3 , a4 }
▶ A = {2, 4, 6, 8}
Expressing the second example using a formula:
A = {x | x is an even natural number}
▶ Using a membership function µA (x), the membership value of an element x in a
crisp set A is: (
1 if x ∈ A
µA (x) =
0 if x ∈
/A
/
Fuzzy Sets
▶ Fuzzy set theory introduces vagueness (ambiguity) using the concept of a
membership function.
▶ Membership value µÃ (y) permits any value between [0, 1].
▶ Formal representation of a fuzzy set Ã:
à = {(y, µÃ (y)) | y ∈ U }.
0 y /
Example for Fuzzy Set
/
An Example for Fuzzy Set: Age
Young Middle-Aged Old
Membership, µ
.
“Age”
▶ Human age groups illustrated as fuzzy sets (“Young,” “Middle-Aged,” “Old”) with
corresponding membership functions (µ).
▶ Example: The set “Young” might include ages 0 to 37. Membership µ could be 1 up
to age 23, then decrease linearly to 0 by age 37. An age of 30 might have µ = 0.5 in
“Young”.
▶ Solid lines: Fuzzy membership functions. Dashed lines: Example of a crisp
(non-fuzzy) definition for “Young” (e.g., ages 0 to 30).
▶ Any specific age may belong to multiple sets (e.g., “Young” and “Middle-Aged”) but
with different membership values.
/
Operations on Fuzzy Sets
▶ Let A and B be fuzzy sets in universe U (A, B ⊆ U ), and u ∈ U .
▶ Standard complement (¬A or Ā):
▶ Example: Let A = {(x1 , 0.5), (x2 , 0.7)} and B = {(x1 , 0.8), (x2 , 0.2)}.
▶ Complement (¬A): ¬A = {(x1 , 1 − 0.5), (x2 , 1 − 0.7)} = {(x1 , 0.5), (x2 , 0.3)}.
▶ Intersection:
A ∩ B = {(x1 , min{0.5, 0.8}), (x2 , min{0.7, 0.2})} = {(x1 , 0.5), (x2 , 0.2)}.
▶ Union: A ∪ B = {(x1 , max{0.5, 0.8}), (x2 , max{0.7, 0.2})} = {(x1 , 0.8), (x2 , 0.7)}.
/
Triangular Fuzzy Membership Function
▶ Defined by three parameters: a, b, c.
0 if x ≤ a
x−a
b−a if a < x ≤ b
µtri (x; a, b, c) =
c−x
if b < x < c
c−b
0 if x ≥ c
1.0
µA (x)
a b c
/
Gaussian Fuzzy Membership Function
▶ Defined by center c, width s, and sometimes fuzzification factor m.
▶ A common form (with m = 2 implicitly):
2 !
1 x−c
µgauss (x; c, s) = exp −
2 s
▶ Generalized form from slide (with factor m):
m
1 x−c
µ(x; c, s, m) = exp −
2 s
1
0.8
0.6
0.4
0.2
0
0 1 2 3 4 5 6 7 8 9 10 /
Introducing Linguistic Variables
▶ We often want to use natural language terms like ‘young’, ‘not young’, ‘middle age’,
‘possibly yes’, ‘possibly no’ etc. in our knowledge-base or rule-base.
▶ Linguistic variables allow us to represent and use these terms, incorporating
vagueness/ambiguity into rules.
/
Linguistic Variable: Definition and Examples
/
Fuzzy Rules
/
Examples: Fuzzy Rules
/
Fuzzy Inference System (FIS)
▶ Fuzzy Inference Systems (FIS) take inputs, process them using fuzzy reasoning based
on fuzzy rules, and produce outputs.
▶ Inputs and outputs are typically crisp (real-valued) numbers, while the internal
processing uses fuzzy sets, fuzzy logic, and fuzzy rules.
▶ Basic structure includes three main components:
. Rule Base: Contains the collection of fuzzy IF-THEN rules.
. Database (Dictionary): Defines the membership functions (MFs) for the fuzzy sets used
in the rules.
. Reasoning Mechanism (Inference Engine): Performs the inference procedure based on
the rules and input facts to derive a conclusion or output.
Input Output
Fuzzy Reasoning
/
Structure of Fuzzy Inference Systems (FISs)
Provided by Experts
or Extracted from
Numerical Data
Crisp Crisp
Fuzzification Defuzzification
Input Output
Inference
Fuzzy Set of Input Variables Fuzzy Output Set
/
Popular Models of Fuzzy Inference Systems (FISs)
/
Mamdani Inference System
▶ The Mamdani model is the most commonly used fuzzy inference technique.
▶ It typically performs inference in four main steps:
. Fuzzification of input variables.
. Rule evaluation (applying fuzzy operators for antecedents and implication).
. Aggregation of rule outputs (combining results from all relevant rules).
. Defuzzification (converting the aggregated fuzzy output to a crisp number).
Example Application
Design a Mamdani FIS to predict risk in a project funding system.
▶ Inputs: Project Funding (pf ), Project Staffing (ps ) (crisp values).
▶ Output: Risk Prediction (e.g., linguistic values like low/normal/high, or a crisp value
after defuzzification).
/
Knowledge Base for the FIS: Example
▶ Crisp Inputs: x (for pf ), y (for ps ). Crisp Output: z (for risk).
▶ Linguistic Variable: Project Funding (pf )
▶ Terms/Fuzzy Sets: Inadequate (A1 ), Marginal (A2 ), Adequate (A3 ).
▶ Linguistic Variable: Project Staffing (ps )
▶ Terms/Fuzzy Sets: Small (B1 ), Large (B2 ).
▶ Linguistic Variable: Risk (z)
▶ Terms/Fuzzy Sets: Low (C1 ), Normal (C2 ), High (C3 ).
▶ Pre-specified membership functions exist for each fuzzy set
(A1 , A2 , A3 , B1 , B2 , C1 , C2 , C3 ).
Rule Base Example
. IF pf is Adequate (A3 ) OR ps is Small (B1 ) THEN Risk is Low (C1 ).
(IF x is A3 OR y is B1 THEN Z is C1 )
. IF pf is Marginal (A2 ) AND ps is Large (B2 ) THEN Risk is Normal (C2 ).
(IF x is A2 AND y is B2 THEN Z is C2 )
. IF pf is Inadequate (A1 ) THEN Risk is High (C3 ).
(IF x is A1 THEN Z is C3 )
/
Fuzzy Sets Defined Over Input/Output Variables
µA1 (x) µA2 (x) µA3 (x) µB1 (y) µB2 (y) µC1 (z) µC2 (z) µC3 (z)
x y z
Figure: Membership functions for Input x (Funding: A1 , A2 , A3 ), Input y (Staffing: B1 , B2 ), and
Output z (Risk: C1 , C2 , C3 ).
/
Designing FIS - Step : Fuzzification
▶ Convert crisp input values into degrees of membership in the relevant fuzzy sets.
▶ Example: Take crisp inputs for Project Funding (x1 ) and Project Staff (y1 ).
▶ Use the defined membership functions to find the membership values.
Example results from the graph:
▶ For input x1 : µA1 (x1 ) = 0.5, µA2 (x1 ) = 0.2, µA3 (x1 ) = 0.0.
▶ For input y1 : µB1 (y1 ) = 0.1, µB2 (y1 ) = 0.7.
µA1 (x) µA2 (x) µA3 (x) µB1 (y) µB2 (y)
.
.
.
.
x1 x y1 y
Figure: Example Fuzzification Step: Finding membership values for crisp inputs x1 and y1 . /
Step : Rule evaluation - Antecedent
▶ Determine the degree to which the antecedent (IF part) of each rule is satisfied by
the current inputs.
▶ If a rule’s antecedent has multiple parts connected by fuzzy operators (AND, OR):
▶ Apply the corresponding fuzzy operation to the membership values obtained during
fuzzification.
▶ The result is a single number representing the rule’s antecedent truth value (firing
strength).
▶ Evaluating operators (using standard fuzzy logic):
▶ OR (Disjunction): Typically uses the maximum operator. For antecedent “X is A OR Y
is B”:
Truth Value = max[µA (X), µB (Y )]
▶ AND (Conjunction): Typically uses the minimum operator. For antecedent “X is A AND
Y is B”:
Truth Value = min[µA (X), µB (Y )]
/
Mamdani Style of Rule Evaluation for Project System I
Figure: Calculating the firing strength for each rule using the fuzzified inputs and fuzzy operators
(min for AND, max for OR).
/
Mamdani Style of Rule Evaluation for Project System II
Rule Firing Strengths: µA1 = 0.5, µA2 = 0.2, µA3 = 0.0, µB1 = 0.1, µB2 = 0.7
▶ Rule (A OR B ): max(0.0, 0.1) = 0.1.
▶ Rule (A AND B ): min(0.2, 0.7) = 0.2.
▶ Rule (A ): 0.5 (single antecedent)
/
Step : Rule evaluation - Fuzzy Implication
▶ Apply the calculated firing strength of each rule to its consequent (THEN part). This
reshapes the consequent’s fuzzy set.
▶ The result of this step is one output fuzzy set for each rule, shaped by its firing
strength.
▶ Mamdani Implication Methods:
Clipping (min): The consequent Scaling (prod): The consequent
membership function is truncated (cut off) membership function is scaled (multiplied)
at the level of the firing strength. (Most by the firing strength.
common). 1
1 µC2 (z)
µC2 (z)
▶ Unify the output fuzzy sets from all contributing µR1 (z)
individual rule output sets at that point z. µC1 (z) µC2 (z) µC2 (z)
1
µAGG (z)
µAGG (z) = max[µR1 (z), µR2 (z), µR3 (z), ...]
0 z
/
Step : Defuzzification
▶ Convert the final aggregate fuzzy set (which represents the fuzzy conclusion) into a
single crisp output number.
▶ Input: The aggregate output fuzzy set. Output: A single crisp value.
▶ Methods: Many exist (Mean of Maximum, Bisector, etc.).
▶ Centroid (Center of Gravity - COG): Most popular method. Finds the point on the
x-axis (z) that represents the “center of mass” or “balance point” of the aggregate
fuzzy set.
R
▶ For a continuous set, COG = Rz·µAGG (z)dz .
µAGG (z)dz
▶ For discrete points or sampled representation:
P
zi · µAGG (zi )
COG = P
µAGG (zi )