# Project Risk Fuzzy Logic by qnm10071

VIEWS: 37 PAGES: 9

• pg 1
```									                    Fuzzy Logic                                                                           Outline                                                     Mamdani fuzzy inference
Part 2                                                                                                                            The Mamdani fuzzy inference involves four steps:
Andrew Kusiak                               Mamdani fuzzy inference
Intelligent Systems Laboratory                      Sugeno fuzzy inference                                                                     Fuzzification of the input variables
2139 Seamans Center
The University of Iowa                          Case study                                                                                 Rule evaluation
Iowa City, Iowa 52242 - 1527
Summary                                                                                    Aggregation of the rule outputs
andrew-kusiak@uiowa.edu                                                                                                                      Defuzzification
http://www.icaen.uiowa.edu/~ankusiak
Tel: 319 - 335 5934    Fax: 319 - 335 5669

Based on material provided by Professor Michael Negnevitsky

Consider a simple two-input one-output application that
two-     one-                                 Step 1: Fuzzification                                                                       Step 2: Rule Evaluation
includes three rules:                                            The first step is to take the crisp inputs, x1 and y1                                       The second step is to take the fuzzified inputs,
Rule: 1                  Rule: 1                                                                 staffing),
(project funding and project staffing), and determine                                       μ(x=A1) = 0.5, μ(x=A2) = 0.2, μ(y=B1) = 0.1 and μ(y=B2) =
IF      x is A3          IF      project_funding is adequate     the degree to which these inputs belong to each of the
OR      y is B1          OR      project_staffing is small                                                                                                   0.7, and apply them to the antecedents of the fuzzy
appropriate fuzzy sets.                                                                     rules. If a given fuzzy rule has multiple antecedents,
THEN z is C1             THEN risk is low
Rule: 2                  Rule: 2
the fuzzy operator (AND or OR) is used to obtain a
IF      x is A2          IF      project_funding is marginal      Project        Crisp Input                     Project             Crisp Input             single number that represents the result of the
funding            x1                          staffing                y1
AND y is B2              AND project_staffing is large                      Inadequate    Marginal   Adequate            Small                  Large
antecedent evaluation. This number (the truth value)
THEN z is C2             THEN risk is normal                                1
A1            A2        A3
1    B1                        B2       is then applied to the consequent membership
0.7
Rule: 3                  Rule: 3
0.5
0.2                                         0.1
function.
0                                           0
IF      x is A1          IF      project_funding is inadequate                           x1                  X                             y1            Y
μ (x = A1) = 0.5                            μ (y = B1) = 0.1
THEN z is C3             THEN risk is high                                           μ (x = A2) = 0.2                            μ (y = B2) = 0.7
R1: IF project_funding is adequate

To evaluate the disjunction of the rule antecedents,
OR project_staffing is small
THEN risk is low
Mamdani’
Mamdani’s rule evaluation                                               Now the result of the antecedent evaluation can be
we use the OR fuzzy operation. Typically, fuzzy
operation.                              1                                    1                                         1
applied to the membership function of the
expert systems make use of the classical fuzzy                                     A3                 B1
0.1                0.1
C1      C2       C3                consequent.
0.0                                    OR

operation union:
union:                                             0        x1                X         0             y1           Y
(max)
0                          Z           The most common method of correlating the rule
Rule 1: IF x is A3 (0.0)       OR       y is B1 (0.1)             THEN           z is C1 (0.1)                      consequent with the truth value of the rule
μA∪B(x) = max [μA(x), μB(x)]                        1                                    1
0.7
1
antecedent is to cut the consequent membership
C1      C2       C3
A2               0.2                      B2                   0.2
AND                                              function at the level of the antecedent truth. This
Similarly, in order to evaluate the conjunction of the       0                                    0
(min)
0
x1                X                       y1           Y                                         Z
clipping.
method is called clipping. Since the top of the
rule antecedents, we apply the AND fuzzy operation             Rule 2: IF x is A2 (0.2) AND y is B2 (0.7)                        THEN           z is C2 (0.2)
membership function is sliced, the clipped fuzzy set
intersection:
intersection:                                                1                                                                              1
A1                         0.5                                           0.5 C1        C2        C3               loses some information. However, clipping is still
μA∩B(x) = min [μA(x), μB(x)]                                                                                                                                              often preferred because it involves less complex and
0        x1                X                                                   0                          Z
Rule 3: IF x is A1 (0.5)                         THEN                            z is C3 (0.5)                      faster mathematics, and generates an aggregated
R2: IF project_funding is marginal                                                R3: IF project_funding is inadequate                                     defuzzify.
output surface that is easier to defuzzify.
AND project_staffing is large                                                     THEN risk is high
THEN risk is normal

While clipping is a frequently used method, scaling        Clipped and scaled membership functions                                                                               Step 3: Aggregation of the rule outputs
offers a better approach for preserving the original                                                                                                                             Aggregation is the process of unification of the
shape of the fuzzy set. The original membership                           Clipped                                                        Scaled
outputs of all rules. We take the membership
function of the rule consequent is adjusted by          Degree of                                                   Degree of                                                    functions of all rule consequents previously clipped or
multiplying all its membership degrees by the truth     Membership                                                  Membership
scaled and combine them into a single fuzzy set.
1.0                                                         1.0
antecedent.
value of the rule antecedent. This method, which
The input of the aggregation process is the list of
generally loses less information, can be useful in                               C2                                                            C2
functions,
clipped or scaled consequent membership functions,
fuzzy expert systems.
0.2                                                         0.2
and the output is one fuzzy set for each output
variable.
0.0                                                         0.0
Z                                                          Z
There are several defuzzification methods, but
Aggregation of the rule outputs                                                            Step 4: Defuzzification                                                                                 probably the most popular one is the centroid
The last step in the fuzzy inference process is                                                         technique.
technique. It finds the point where a vertical line
Clipped membership functions
defuzzification.
defuzzification. Fuzziness helps us to evaluate the                                                     would slice the aggregate set into two equal masses.
rules, but the final output of a fuzzy system has to be                                                 Mathematically this center of gravity (COG) can be
1                          1                          1
a crisp number. The input for the defuzzification                                                       expressed as:
C1                               C2                              C3
0.5                        0.5
0.2
process is the aggregate output fuzzy set and the
0.1                        0.2                                                                                                                                                                                                         b
0.1
output is a single number.
∫ μ A ( x ) x dx
0                     Z    0                     Z    0                     Z         0             Z
z is C 1 (0.1)             z is C 2 (0.2)             z is C 3 (0.5)                       ∑
COG =   a
b
∫ μ A ( x ) dx
a

Centroid defuzzification method finds a point                                                                                Center of gravity (COG):                                                                   Sugeno fuzzy inference
representing the centre of gravity of the fuzzy set, A,                                                      (0 + 10 + 20 ) × 0.1 + (30 + 40 + 50 + 60 ) × 0.2 + (70 + 80 + 90 + 100 ) × 0.5
COG =                                                                                          = 67 .4
on the interval, ab.
ab.                                                                                                0 . 1 + 0 . 1 + 0 . 1 + 0 .2 + 0 . 2 + 0 . 2 + 0 .2 + 0 . 5 + 0 . 5 + 0 .5 + 0 .5           Mamdani-
Mamdani-style inference, requires finding the
A reasonable estimate can be obtained by calculating                                                                                                                                                                          two-
centroid of a two-dimensional shape by integrating
it over a sample of points.
Degree of
Membership
across a continuously varying function. In general,
this process is not computationally efficient.
μ( x )                                                                                           1.0
1.0                                                                                                0.8
0.8                                                                                                0.6                                                                                             Michio Sugeno suggested to use a single spike, a
0.6                                     A                                                          0.4                                                                                             singleton,
singleton, as the membership function of the rule
0.4                                                                                                0.2                                                                                                              singleton,
consequent. A singleton, or more precisely a fuzzy
0.0                                                                                             singleton,
singleton, is a fuzzy set with a membership function
0.2                                                                                                      0     10     20      30      40     50      60      70     80      90     100
a                                                     b
that is unity at a single particular point on the
67.4                      Z
0.0                                                                               X                                                                                                                universe of discourse and zero everywhere else.
150            160     170          180       190      200               210
Sugeno-
Sugeno-style fuzzy inference is similar to the                                    The most commonly used zero-order Sugeno fuzzy
Sugeno-
Sugeno-style rule evaluation
zero-
Mamdani method. Sugeno has modified a rule                                        model applies fuzzy rules in the following form:                                      1                                 1                                  1
A3                 B1
consequent. Instead of a fuzzy set, he used a                                                                                                                                                                            0.1                0.1
IF   x is A                                                                                                0.0                              OR
(max)
mathematical function of the input variable. The                                                                                                                        0        x1             X         0        y1          Y              0     k1                 Z
AND y is B
Sugeno-
format of the Sugeno-style fuzzy rule is                                                                                                                                Rule 1: IF x is A3 (0.0)      OR y is B1 (0.1)             THEN           z is k1 (0.1)
THEN z is k                                                                    1                                 1                                  1
0.7
IF         x is A
where k is a constant.                                                                              A2            0.2                 B2          AND     0.2
AND        y is B                                                                                                                                                 0        x1             X         0        y1          Y
(min)
0           k2           Z
THEN                  y)
z is f (x, y)                                                                                                                                          Rule 2: IF x is A2 (0.2) AND y is B2 (0.7)                 THEN           z is k2 (0.2)
In this case, the output of each fuzzy rule is constant.
where x, y and z are linguistic variables; A and B are                            All consequent membership functions are represented
1
A1                      0.5
1
0.5

fuzzy sets on universe of discourses X and Y,                                     by singleton spikes.                                                                  0        x1             X                                             0                   k3   Z
y)
respectively; and f (x, y) is a mathematical function.                                                                                                                  Rule 3: IF x is A1 (0.5)                    THEN                          z is k3 (0.5)

Weighted average (WA):                                              How to make a decision on which method
Sugeno-
Sugeno-style aggregation of the rule outputs
to apply − Mamdani or Sugeno?
Sugeno?
μ(k1) × k1 + μ(k 2) × k 2 + μ(k 3) × k 3 0.1× 20 + 0.2 × 50 + 0.5 × 80
WA =                                           =                              = 65    Mamdani method is widely accepted for capturing
μ(k1) + μ(k 2) + μ(k 3)                 0.1 + 0.2 + 0.5
expert knowledge. It allows us to describe the
1                  1                 1                 1
Sugeno-
Sugeno-style defuzzification                                                                            human-
expertise in more intuitive, more human-like
0.5               0.5
0.1                0.2                                 0.1
0.2                                                                                                                             Mamdani-
manner. However, Mamdani-type fuzzy inference
0    k1    Z      0     k2    Z     0     k3    Z      0     k1   k2   k3   Z                                                                                         entails a substantial computational effort.
z is k1 (0.1)      z is k2 (0.2)     z is k3 (0.5)                ∑                                                                                                   Sugeno method is computationally effective and
0                 z1   Z                                   works well with optimization and adaptive
Crisp Output                                      techniques, which makes it very attractive in control
z1                                          problems, particularly for dynamic nonlinear
systems.
Building a fuzzy expert system: A case study                                          Process of developing a fuzzy expert system               Step 1: Specify the problem and define
1. Specify the problem and define linguistic variables.           linguistic variables
A service center keeps spare parts and repairs failed
ones.                                                                              2. Determine fuzzy sets.                                  There are four main linguistic variables: average
A customer brings a failed item and receives a spare                                                                                         waiting time (mean delay) m, repair utilisation
of the same type.                                                                  3. Elicit and construct fuzzy rules.                      factor of the service centre ρ, number of servers s,
Failed parts are repaired, placed on the shelf, and                                4. Encode the fuzzy sets, fuzzy rules and procedures      and initial number of spare parts n.
thus become spares.                                                                   to perform fuzzy inference into the expert system.
The objective here is to advise a manager of the
5. Evaluate and tune the system.
service center on certain decision policies to keep
the customers satisfied.

Linguistic variables and their ranges
Linguistic Value
Linguistic Variable: Mean Delay, m
Notation          Numerical Range (normalised)    Step 2: Determine fuzzy sets                                             Fuzzy sets of Mean Delay m
Very Short                     VS                          [0, 0.3]
Short                           S                        [0.1, 0.5]
Degree of
Medium                          M                        [0.4, 0.7]
Linguistic Variable: Number of Servers, s
Fuzzy sets can have a variety of shapes. However,        Membership
Linguistic Value
Small
Notation
S
Numerical Range (normalised)
[0, 0.35]
a triangle or a trapezoid can often provide an            1.0

Medium
Large
M
L
[0.30, 0.70]
[0.60, 1]
adequate representation of the expert knowledge,          0.8       VS            S                   M
Linguistic Variable: Repair Utilisation Factor, ρ
Utilisation Factor,                  and at the same time, significantly simplifies the        0.6
Linguistic Value           Notation                Numerical Range
Low                             L                          [0, 0.6]            process of computation.                                   0.4
Medium                          M                        [0.4, 0.8]
High                            H                          [0.6, 1]                                                                      0.2
Linguistic Variable: Number of Spares, n
Linguistic Value           Notation          Numerical Range (normalised)                                                              0.0
Very Small                     VS                         [0, 0.30]                                                                            0     0.1   0.2   0.3   0.4   0.5   0.6   0.7   0.8    0.9     1
Small                           S                         [0, 0.40]                                                                                                                      Mean Delay (normalized)
Rather Small                   RS                       [0.25, 0.45]
Medium                          M                       [0.30, 0.70]
Rather Large                   RL                       [0.55, 0.75]
Large                           L                         [0.60, 1]
Very Large                     VL                         [0.70, 1]
Fuzzy sets of Number of Servers s                                 Fuzzy sets of Repair Utilisation Factor ρ                                                                Fuzzy sets of Number of Spares n
Degree of                                                                   Degree of                                                                                     Degree of
Membership                                                                  Membership                                                                                    Membership
1.0                                                                         1.0                                                                                           1.0
0.8         S                       M                         L             0.8                  L                                  M                     H                0.8       VS       S           RS         M        RL         L        VL
0.6                                                                         0.6                                                                                            0.6

0.4                                                                         0.4                                                                                            0.4

0.2                                                                         0.2                                                                                            0.2

0.0                                                                         0.0                                                                                            0.0
0     0.1   0.2   0.3   0.4   0.5   0.6   0.7     0.8    0.9     1          0    0.1      0.2       0.3   0.4       0.5       0.6    0.7    0.8      0.9    1              0     0.1   0.2    0.3        0.4   0.5   0.6   0.7    0.8     0.9    1
Number of Servers (normalized)                                                                  Repair Utilization Factor                                                         Number of Spares (normalized)

The Fuzzy Associative Memory                                                                                       Rule Base 1
Step 3: Elicit and construct fuzzy rules                                                  (FAM) square
1. If (utilization_factor is L) then (number_of_spares is S)
2. If (utilization_factor is M) then (number_of_spares is M)
To accomplish this task, we might ask the expert to                                    No of                                                      No of                3. If (utilization_factor is H) then (number_of_spares is L)
s                                              spares
describe how the problem can be solved using the                                       servers                                                                         4. If (mean_delay is VS) and (number_of_servers is S) then (number_of_spares is VL)
5. If (mean_delay is S) and (number_of_servers is S) then (number_of_spares is L)
fuzzy linguistic variables defined previously.                                                                                                                         6. If (mean_delay is M) and (number_of_servers is S) then (number_of_spares is M)
7. If (mean_delay is VS) and (number_of_servers is M) then (number_of_spares is RL)
L    M          S     VS                                        8. If (mean_delay is S) and (number_of_servers is M) then (number_of_spares is RS)
9. If (mean_delay is M) and (number_of_servers is M) then (number_of_spares is S)
Required knowledge also can be collected from                                                                                                                          10. If (mean_delay is VS) and (number_of_servers is L) then (number_of_spares is M)
M        RL     RS            S                                     11. If (mean_delay is S) and (number_of_servers is L) then (number_of_spares is S)
other sources such as books, computer databases,                                                                                                                       12. If (mean_delay is M) and (number_of_servers is L) then (number_of_spares is VS)
flow diagrams and observed human behaviour.                                                        S        VL         L         M

VS         S         M         m Delay
3 + 3x3 rules

k dimensional cube for k variables
Cube FAM of Rule Base 2
s
Rule table 2                                                        Step 4: Encode the fuzzy sets, fuzzy rules
s

L
VS VS VS
S
VS VS VS
S  VS
L   RL   M   RS
Rule                      m         s     ρ   n      Rule       m    s   ρ         n     Rule    m    s     ρ       n
and procedures to perform fuzzy
VS VS VS                                       M       M    M   S
M
VS VS VS
VS VS VS
ρ                                  VL   L   M        ρ
1                   VS              S     L   VS     10         VS   S   M         S     19      VS   S     H       VL           inference into the expert system
VS VS VS                                           S
VS VS VS                                                                       2                         S         S     L   VS     11         S    S   M         VS    20       S   S     H       L
S   VS VS VS       H                                                        H
M                                            VS   S   M
L                   s                                                3                         M         S     L   VS     12         M    S   M         VS    21      M    S     H       M
VS   S  M                                                      m
m                           L   M    RS   S
4                   VS              M     L   VS     13         VS   M   M         RS    22      VS   M     H       M
One may choose one of two options:
M       RS   S    VS
5                         S         M     L   VS     14         S    M   M         S     23       S   M     H       M    • Build the system using a programming language
S   S    VS   VS                                 6                         M         M     L   VS     15         M    M   M         VS    24      M    M     H       S      such as C/C++ or Pascal, or
M
VS   S    M
s
m
7                   VS              L     L   S      16         VS   L   M         M     25      VS   L     H       RL   • Apply a fuzzy logic development tool such as
L   S    S    VS                                                            8                         S         L     L   S      17         S    L   M         RS    26       S   L     H       M      MATLAB Fuzzy Logic Toolbox or Fuzzy
9                         M         L     L   VS     18         M    L   M         S     27      M    L     H       RS
M    VS   VS   VS
Knowledge Builder.
S   VS   VS   VS
VS   S    M
L
3x3 = 27 rules                                        The rules constructed from a 3-dimensional cube
m                                                                                                  (3x3x3 = 27 rules)

Three-
Three-dimensional plot of Rule Base 1                                                                                  Three-
Three-dimensional plot of Rule Base 1
Step 5: Evaluate and tune the system

0.6
The last, and the most laborious, task is to evaluate                                                                                                                                                                               0.6

and tune the system. We want to see whether the
number_of_spares

0.5

number_of_spares
0.5
fuzzy system meets the requirements.                                                                                0.4

0.4

Several test situations depend on the mean delay,                                                                   0.3

0.3
number of servers and repair utilisation factor.                                                                    0.2

0.2
0
The Fuzzy Logic Toolbox can generate surfaces                                                                                                                                                         1
0
0.2                                                                                                         0.2                                                 1
system’
useful in analysis of the system’s performance.                                                                                      0.4                                              0.6
0.8
0.4                           0.6
0.8

0.4                                                                                      0.4
0.6                0.2                                                                                 0.6       0.2
mean_delay                   0                  number_of_servers                                           mean_delay         0          utilization_factor
Three-
Three-dimensional plot of Rule Base 2                                                                        Three-
Three-dimensional plot of Rule Base 2

0.35                                                                                                        0.5                                                                                                            However, even now, the expert might not be
satisfied with the system performance.
number_of_spares

0.3
0.4

number_of_spares
0.25
0.3
To improve the system performance, we may use
0.2                                                                                                                                                                                                                       additional sets − Rather Small and Rather Large −
0.2
Servers,
on the universe of discourse Number of Servers,
0.15
and then extend the rule base.
0                                                                                                        0

0.2                                                                     1                                 0.2                                                                                              1
0.8                                                                                                                                0.8
0.4                                           0.6                                                            0.4                                                              0.6
0.4                                                                                                                          0.4
0.6                 0.2                                                                                     0.6                          0.2
mean_delay                        0              number_of_servers                                      mean_delay                                0                           utilization_factor

Cube FAM of Rule Base 3                                                                             Three-
Three-dimensional plots for Rule Base 3
Modified fuzzy sets of Number of Servers                                                                                              s
s

VS VS VS                                                           L   L     M     RS
VS VS VS
SL   S VS
VS VS VS                                                       RL RL         M     RS
Degree of                                                                                                                              VS VS VS
RL S    S VS                                                                                                                     0.35
VS VS VS                                                           M   M     M      S
Membership                                                                                                                             VS VS VS
1.0                                                                                                                                M VS VS VS
VS VS VS                          s                            RS VL         RL    RS
VS VS VS                                                                                                                      0.3
RS VS VS VS

number_of_spares
0.8                                                                                                                                     VS VS VS     ρ                     L   M        RS   S             S VL      L      M         ρ
S                     RS                    M         RL             L                                    VS VS VS
S VS VS VS      H                                                                            H
M                                                             VS    S     M                                       0.25
RL   M        RS   S
0.6                                                                                                                                  VS   S M
L                                                                     m
m                             M RS          S    VS
0.4                                                                                                                                                                                                                                                                 0.2
s                         RS   S        VS   VS
0.2                                                                                                                                             L   S      S   VS         S    S        VS   VS                                                                    0.15
M
0.0                                                                                                                                                                            VS       S    M
RL       S      S   VS
m                                                                             0
0       0.1       0.2         0.3         0.4   0.5     0.6   0.7     0.8    0.9     1
M VS          VS   VS
Number of Servers (normalized)                                                                                                                                                                0.2                                                1
RS VS          VS   VS                                                                                                                                                      0.8
0.4                          0.6
S VS      VS   VS                                                                                                                                       0.4
0.6       0.2
L
VS     S   M                                                                                                                              0
mean_delay                     number_of_servers
m
Three-
Three-dimensional plots for Rule Base 3
Tuning fuzzy systems                         4. Review the existing rules, and if required add new
1. Review model input and output variables, and if          rules to the rule base.
0.5
required redefine their ranges.                       5. Examine the rule base for opportunities to write
0.4                                                               2. Review the fuzzy sets, and if required define            hedge rules to capture the pathological behaviour
number_of_spares

additional sets on the universe of discourse.            of the system.
0.3
The use of wide fuzzy sets may cause the fuzzy        6. Adjust the rule execution weights. Most fuzzy
0.2                                                                  system to perform roughly.                               logic tools allow control of the importance of rules
3. Provide sufficient overlap between neighbouring          by changing a weight multiplier.
0

0.2                                                     1
triangle- to-
sets. It is suggested that triangle-to-triangle and   7. Revise shapes of the fuzzy sets. In most cases,
0.8
0.4                            0.6                      trapezoid- to-
trapezoid-to-triangle fuzzy sets should overlap          fuzzy systems are highly tolerant of a shape
0.4
0.6
0
0.2                                     between 25% to 50% of their bases.                       approximation.
mean_delay                   utilization_factor

```
To top