Sie sind auf Seite 1von 40

Fuzzy Logic

Muhammad Ridwan Andi Purnomo


Department of Industrial Engineering
Universitas Islam Indonesia
2015

Introduction (What is fuzzy thinking?)


Experts usually rely on common sense when they
solve problems.
They also use vague and ambiguous terms. Ex:
Though the power transformer is slightly
overloaded, I can keep this load for a while.
Other experts have no difficulties with
understanding and interpreting that statement
they have the background to hearing problems
described like that.

Introduction (What is fuzzy thinking?)


A technique to describe the vague and ambiguous
terms is required Fuzzy logic can be used for that
(Proposed by Lotfi Zadeh in 1965).
Fuzzy logic is not logic that is fuzzy, but logic that is
used to describe fuzziness.
Fuzzy logic is based on the idea that all things admit
of degrees.
The motor is running really hot how many degree
is the hot?
Tom is a very tall guy how many degree is the
tall?

Why Fuzzy?
Not all of natural phenomenon can be described using
Crisp. Ex:

If height is 180 then the status is tall (degree of


membership = 1), but if height is 179,99 then the
status will be not tall/short (degree of membership =
0). Is it fair?

Crisp VS Fuzzy
Crisp (yes/no) (a) VS Fuzzy (multi-value) (b)

Crisp VS Fuzzy

Crisp VS Fuzzy
Height 184, in Crisp
it is Tall
Height 184, in Fuzzy
it is Average with
correctness 0.1 and
it is Tall with
correctness 0.4.

Linguistic variables and Hedges


A linguistic variable is a fuzzy variable, ex:
IF wind is strong
THEN sailing is good
IF project_duration is long
THEN completion_risk is high
IF speed is slow
THEN stopping_distance is short

Linguistic variables and Hedges


Hedges are terms that modify the shape of fuzzy
sets. They include adverbs such as very,
somewhat, quite, more or less and slightly.

Representation of Hedges in Fuzzy Logic

How to represent logics in Fuzzy Logic?


Fuzzy rule (IF-THEN rule) is used to represent
logic.
Rule: 1
IF speed is fast (antecedent)
THEN stopping_distance is long (consequent)
Rule: 2
IF speed is slow (antecedent)
THEN stopping_distance is short (consequent)

Multi antecedent and multi consequent rule


Rule 1:
IF project_duration is long
AND project_staffing is large
AND project_funding is inadequate
THEN risk is high
Rule 2:
IF temperature is hot
THEN hot_water is reduced;
cold_water is increased

Fuzzy Inference
Fuzzy inference can be defined as a process of
mapping from a given input to an output.
There are 2 types of inference system, Mamdanistyle and Sugeno-style

Mamdani-style Inference

Introduction of Mamdani-style inference


The most commonly used fuzzy inference
technique is the so-called Mamdani method.
In 1975, Professor Ebrahim Mamdani of London
University built one of the first fuzzy systems to
control a steam engine and boiler combination.
Mamdani-style uses linguistic variable both in
antecedent and consequent part of a fuzzy rule. Ex:
IF project_funding is adequate
OR project_staffing is small
THEN risk is low

Mamdani-style inference
Performed in four steps: fuzzification of the input
variables, rule evaluation, aggregation of the rule
outputs, and finally defuzzification.
Example: A project management case will be
analysed using Mamdani-style inference.
Input: Project funding (PF), project staffing (PS)
Output: Project risk (PR)
PF
PS

Fuzzy (Mamdani-style)

PR

Mamdani-style inference
The fuzzy rules:
Rule: 1
Rule: 1
IF x is A3
IF project_funding is adequate
OR y is B1
OR project_staffing is small
THEN z is C1
THEN risk is low
Rule: 2
Rule: 2
IF x is A2
IF project_funding is marginal
AND y is B2 AND project_staffing is large
THEN z is C2
THEN risk is normal
Rule: 3
Rule: 3
IF x is A1
IF project_funding is inadequate
THEN z is C3THEN risk is high

What is the risk if project_funding = 35% and


project_staffing = 60% ?

Mamdani-style inference
Step 1: Fuzzification conducted by providing
fuzzy set for every input and output variables.

Fuzzy set for


project risk

Mamdani-style inference
Step 2: Rule evaluation Map the input to every rule and
find the membership value.
IF project_funding is adequate (pf = 35% adequate,
u = 0)
OR project_staffing is small (ps = 60% small, u =
0.1)
THEN risk is low (MAX(0; 0.1) = 0.1) MAX is used
because conjunction of the antecedent is OR.
IF project_funding is marginal (pf = 35% marginal, u
= 0.2)
AND project_staffing is large (ps = 60% large , u =
0.7)
THEN risk is normal (MIN(0.2; 0.7) = 0.2) MIN is used
because conjunction of the antecedent is AND.

Mamdani-style inference
Step 3: Aggregation of the rule output.

Mamdani-style inference
Step 4: Defuzzification Centre of Gravity is the
commonly used method for defuzzification.
Bellow is the function of COG for continuous and
discrete system.

Mamdani-style inference using MATLAB


Step 1: In MATLAB command window, type: fuzzy (enter)

Step 2: in the displayed dialog, click the Input square,


change the name to be Project_Funding (enter).

Mamdani-style inference using MATLAB


Step 3: From menu Edit, choose add variable input, and
do the same with Step 2. Name the second input with
Project_Staffing.
Step 4: Change the outputs name to be Project_Risk. Now
the interface will be like following figure.

Mamdani-style inference using MATLAB


Step 5: Double click input Project_Funding. In the displayed
dialog, click mf1 curve. Change the Name to be
inadequate. Change the Type to be trapmf, change the
Range to be [0 100] and edit the Params to be [0 0 20
40]. For mf2, the Name is Marginal, the Type is trimf
with Params value [20 50 80]. For mf3, the name is
Adequate, the Type is trapmf with Params value [60 80
100 100].
Step 6: Do the same for another input (Project_Staffing). But
for Project_Staffing, there are only 2 membership functions.
Both are trapmf in a range of [0 100]. Change the name
of mf1 to be Small with Params is [0 0 20 60]. Change
the name of mf2 to be Large with Params is [40 80 100
100].

Mamdani-style inference using MATLAB


Step 7: Modify fuzzy set for the output (Project_Risk). The
range is [0 100]. Name mf1 with Low with Type is
trapmf and Params is [0 0 20 60]. Name mf2 with
Normal and Type is trimf with Params is [20 50 80].
Name mf3 with High and Type is trapmf and Params
is [40 80 100 100]. Your interface will be like following
figure.

Mamdani-style inference using MATLAB


Step 8: Go to menu Edit Rules, to edit the
fuzzy rules.
Rule 1: Select Adequate for Project_Funding,
Small for Project_Staffing and Low for Project
Risk. The connection is OR. Click button add
rule.
Rule 2: Select Marginal for Project_Funding,
Large for Project_Staffing and Normal for
Project Risk. The connection is AND. Click
button add rule.
Rule 3: Select Inadequate for Project_Funding,
None for Project_Staffing and High for Project
Risk. The connection is OR.

Mamdani-style inference using MATLAB


Step 9: Go to menu View Rule. From displayed dialog, change
the input (by sliding the line in the fuzzy set or manually typing in
the bottom text field) to be 35, 60. Then you can see the
Project_Risk value, which is 50. It is different from the manual
calculation in the previous slide because of different parameters
value in the fuzzy set.

Sugeno-style Inference

Introduction
Mamdani-style inference requires us to find the
centroid of a two-dimensional shape by
integrating across a continuously varying function
not computationally efficient.
Sugeno-style fuzzy inference is very similar to the
Mamdani method.
Sugeno changed only a rule consequent. Instead
of a fuzzy set, Sugeno used a mathematical
function of the input variable.

Format of Sugeno-style
IF x is A
AND y is B
THEN z is f (x, y) the consequent part is
mathematical function of input variables (x and y).
Example:
IF project_funding is High
AND project_staffing is Large
THEN project_risk = 0.7x + 0.85y. (x = crisp input of
project_funding, y = crisp input of project_staffing)

note: project_risk can be a constant, ex: project_risk =


0.85 zero order Sugeno style.

Sugeno-style flow

Sugeno-style defuzzification

Sugeno-style computation by hand


The fuzzy rules:

Rule: 1
Rule: 1
IF x is A3
IF project_funding is adequate
OR y is B1
OR project_staffing is small
THEN z is C1
THEN risk is 20 (%)
Rule: 2
Rule: 2
IF x is A2
IF project_funding is marginal
AND y is B2 AND project_staffing is large
THEN z is C2
THEN risk is 50 (%)
Rule: 3
Rule: 3
IF x is A1
IF project_funding is inadequate
THEN z is C3THEN risk is 80 (%)
What is the risk if project_funding = 35% and project_staffing = 60% ?

Sugeno-style computation by hand


Rule evaluation:
IF project_funding is adequate (pf = 35% adequate, u = 0)
OR project_staffing is small (ps = 60% small, u = 0.1)
THEN risk is 20 (MAX(0; 0.1) = 0.1) MAX is used because
conjunction of the antecedent is OR.
IF project_funding is marginal (pf = 35% marginal, u = 0.2)
AND project_staffing is large (ps = 60% large , u = 0.7)
THEN risk is 50 (MIN(0.2; 0.7) = 0.2) MIN is used because
conjunction of the antecedent is AND.
IF project_funding is inadequate (pf = 35% inadequate, u = 0.5)
THEN risk is 80 (0.5)
Output: project_risk = ((0.1 x 20) + (0.2 x 50) + (0.5 x 80)) / (0.1 +
0.2 + 0.5) = 65.

Sugeno-style using MATLAB


Type fuzzy (without quote) in Matlab editor to open Fuzzy
toolbox.
By default, the inference engine is Mamdani. Dont forget to
open Sugeno style from menu File New FIS Sugeno.
Do the same with the previous case to create fuzzy sets for
input variables. For output variables, by default, Matlab
provides 3 mf. Because we have only 3 rules (refer to the
previous case), then:
Click mf1 then change the name to 20 and Params value
= 20.
Click mf2 then change the name to 50 and Params value
= 50.
Click mf3 then change the name to 80 and Params value
= 80.

Sugeno-style using MATLAB

Sugeno-style using MATLAB


Open rules editor from menu Edit Rules.
Define the fuzzy rules so that like following figure:

Sugeno-style using MATLAB


Evaluate the output from menu View Rules. Set the input to
[35; 60] (enter) and we got 52.2 as the project risk. The result is
different from the by-hand calculation because of different fuzzy
set parameters value.

THANK YOU !

Das könnte Ihnen auch gefallen