Lab 1 C.I Report PDF
Lab 1 C.I Report PDF
The theory of Fuzzy logic is based on the notion of relative graded membership, as inspired
by the processes of human perception and cognition. Lotfi A. Zadeh published his first
famous research paper on fuzzy sets in 1965. Fuzzy logic can deal with information arising
from computational perception and cognition, that is, uncertain, imprecise, vague, partially
true, or without sharp boundaries. Fuzzy logic allows for the inclusion of vague human
assessments in computing problems. Also, it provides an effective means for conflict
resolution of multiple criteria and better assessment of options. New computing methods
based on fuzzy logic can be used in the development of intelligent systems for decision
making, identification, pattern recognition, optimization, and control.
Fuzzy logic is extremely useful for many people involved in research and development
including engineers (electrical, mechanical, civil, chemical, aerospace, agricultural,
biomedical, computer, environmental, geological, industrial, and mechatronics),
mathematicians, computer software developers and researchers, natural scientists (biology,
chemistry, earth science, and physics), medical researchers, social scientists (economics,
management, political science, and psychology), public policy analysts, business analysts,
and jurists.
OBJECTIVES
Afterward concluding this unit, students should be talented to :
1 To define fuzzy variables, form the rule base and use fuzzy reasoning to check the
operability of the rule base.
2 To build fuzzy logic system by using Mat labs fuzzy logic toolbox.
Fuzzy logic studies reasoning systems in which the notions of truth and falsehood are
considered in a graded fashion, in contrast with classical mathematics where only absolutely
true statements are considered. From the Stanford Encyclopedia of Philosophy: The study of
fuzzy logic can be considered in two different points of view: in a narrow and in a broad.
In the year 1987, the first subway system was built which worked with a fuzzy logic-based
automatic train operation control system in Japan. It was a big success and resulted in a fuzzy
boom. Universities as well as industries got interested in developing the new ideas. First, this
was mainly the case in Japan. Since the relegions in Japan acceped that things can contain
parts of their opposites, it wasn't such a frightening idea as in most other parts of the world.
And fuzzy logic promised lots of money to the industries, which was of course welcome too.
INPUT / OUTPUT
Input status words be:
Too slow
Just right
Too fast
output action words be:
Less voltage (Slow down)
No change
More voltage (Speed up) 14 FIS Editor: Ad
The quality of service in restaurant is evaluated according to scale 1-10, where 10 means
excellent and 0 is poor service. The question is, how much tip we should give, that the
relation between tip and service is correct. Create FIS with GUI following rules below;
There are three main rules:
i.
ii.
iii.
According to US practice, the cheap tip is 5%, average 15% and generous 25% of the total
bill. Formulate fuzzy deduction system tip. Use Matlab Fuzzy Logic Toolbox.
There are several steps that must follow in order to do this experiment
Step 1: open Matlabs command window and type fuzzy
The FIS editor will show the fuzzy system. In this experiment, it consists of single
input and single output. The transfer function or the method will be use is
MAMDANI.
HERE you can name the FIS by click on FILE the EXPORT to workspace Or file the
name for example task_1
By editing the name of service membership MF1, MF2 and MF3 to the quality of the service
which are POOR, GOOD and EXCELLENT respectively
Discussion
we have to change the display range value from [0 1] to [0 10], Based on the labsheet was
stated that the service is evaluated according to scale 0-10, where 10 means excellent and 0 is
poor service. There are 3 inputs for service which is poor, good and excellent. The name of
each input is change from mf1 to POOR, mf2 to GOOD and mf3 to EXCELLENT. We
choose Trimf as type of function which is the triangular membership function and has a
triangular shape of graph. Parameters mean the coordinate of each point of triangular. Table
below shows the detail for each service input.
MEMBERSHIP
FUNCTION 1
MEMBERSHIP
FUNCTION 2
MEMBERSHIP
FUNCTION 3
Name:
POOR
GOOD
EXCELLENT
Type:
Trimf
Trimf
Trimf
[1 5 9]
[6 10 14]
Parameters: [-4 0 4]
10
By editing the name of Tip membership MF1, MF2 and MF3 to the quality of the Tip which
are CHEAP, AVERAGE and GENEROUS respectively
The parameter of POOR membership function is [-12 0 12]
11
12
Discussion:
we have to change the display range value from [0 1] to [0 30]. In the labsheet was stated that
the tips for cheap is 5%, average 15% and generous is 25%. There are 3 MEMBERSHIP
FUNCTION for tips which are cheap, average and generous. The name of each input is
change from mf1 to CHEAP, mf2 to AVERAGE and mf3 to GENEROUS. We choose Trimf
type which is the triangular membership function of graph. The Trimf is chosen because of
the peak point that we want and it easier to read the graph. Parameter means the coordinate of
each point of triangular graph. Table below shows the detail for each tips input.
Tip
MEMBERSHIP
MEMBERSHIP
FUNCTION 1
FUNCTION 2
CHEAP
AVERAGE
Name:
trimf
trimf
Type:
[3 15 27]
Parameters: [-12 0 12]
MEMBERSHIP
FUNCTION 3
GENEROUS
trimf
[18 30 42]
To open the rule window and change it base on the membership function number and the
operation either maximum (OR) or minimum (AND).
13
14
For the Rule Viewer, it will display the relations of service and tips. As we know, the
quality of service in restaurant is evaluated according scale 1-10 which 0
is poor and 10 is excellent. From the Rule Viewer, we can see that if the
service is at 1.55 (poor), the tips get is 5(cheap). When the service is 4.5
(good), the tips get is 15 (average) and when the service is 7.41
(excellent), the tips given are 25 (generous).
15
low
medium
high
low
medium
high
cool
low
medium
high
moderate
low
low
low
warm
low
low
low
hot
low
low
low
16
SOLUTIONS:
Step 1: Open new m-file then Write and Run the coding at command window
%Task_2
a=newfis('furnace');
a=addvar(a,'input','TEMPERATURE',[32 112]);
a=addmf(a,'input',1,'cold','trimf',[32 32 52]);
a=addmf(a,'input',1,'cool','trimf',[32 52 72]);
a=addmf(a,'input',1,'moderate','trimf',[62 72 82]);
a=addmf(a,'input',1,'warm','trimf',[72 92 112]);
a=addmf(a,'input',1,'hot','trimf',[92 112 112]);
a=addvar(a,'input','SETTING',[1 10]);
a=addmf(a,'input',2,'low','trimf',[0 0 5]);
a=addmf(a,'input',2,'medium','trimf',[3 5 7]);
a=addmf(a,'input',2,'high','trimf',[5 10 10]);
a=addvar(a,'output','POWER',[0 20]);
a=addmf(a,'output',1,'low','trimf',[0 0 10]);
a=addmf(a,'output',1,'medium','trimf',[5 10 15]);
a=addmf(a,'output',1,'high','trimf',[10 20 20]);
ruleList=[ ...
11111
21111
31111
41111
51111
12211
22211
32111
42111
52111
13311
23311
33111
43111
5 3 1 1 1];
a=addrule(a,ruleList);
fuzzy(a) %displays the FIS Editor.
mfedit(a) %displays the Membership Function Editor.
ruleedit(a) %displays the Rule Editor.
ruleview(a) %displays the Rule Viewer.
surfview(a) %displays the Surface Viewer.
17
18
19
20
21
The rule viewer will display all the 15 fuzzy rules for furnace control (task 2).
Rule 1
temperature cold
(32C)
setting
low
power
Low
(3.39)
22
Rule 2
Rule 3
temperature moderate
(72.3C)
setting
low
power
low(3.39)
23
Rule 4
Rule 5
temperature
setting
power
24
hot (112C)
low
low(3.39)
Rule 6
temperature
setting
power
cold (32C)
medium
Medium(10)
Rule 7
temperature
setting
power
25
cool (51.7C)
medium
medium(10)
Rule 8
temperature
setting
power
moderate (71.7C)
medium
low(3.45)
temperature
setting
power
warm (92.3C)
medium
low(3.27)
Rule 9
26
Rule 10
temperature
setting
power
hot (112C)
medium
low(3.27)
temperature
setting
power
cold (32C)
medium
high(16.7)
Rule 11
27
Rule 12
temperature
setting
power
cool (51.7C)
medium
high(16.7)
Rule 13
temperature
setting
power
28
moderate (72.3C)
medium
low(3.27)
Rule 14
temperature
setting
power
warm (92.3C)
medium
low(3.27)
Rule 15
temperature
setting
power
29
hot (112C)
medium
low(3.27)
Discussion:
This graph shows the relationship between the input which are Temperature and setting and
the correspond output which is power. When the temperature is so low in other word
Cold(40) AND Setting is Low(2) so the power will be Low(5).
What is applied in Role (1), it will be the same procedure till Role 16
This graph shows clearly how the output Power changing based on any changing occur on the
input Temperature and Setting.
30
Discussion:
in this task, we used AND =1
However OR= 2
OUTPUT
INPUT
temperature
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
setting
1
1
1
1
1
2
2
2
2
2
3
3
3
3
3
power
1
1
1
1
1
2
2
1
1
1
3
3
1
1
1
weight
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
31
AND
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
CONCLUSION
The lab deals with fuzzy logic fundamentals. Introduced the term fuzzy logic and described
the mathematics of fuzzy set theory. Fuzzy set allows partial memberships. Fuzzy sets
represent linguistic labels or term sets such as If the service is poor, the tip is cheap
If the service is good, the tip is average , If the service is excellent, the tip is generous
. Fuzzy membership functions represent term sets.
The membership function is a graphical representation of the magnitude of participation of
each input. It associates a weighting with each of the inputs that are processed, define
functional overlap between inputs, and ultimately determines an output response. The rules
use the input membership values as weighting factors to determine their influence on the
fuzzy output sets of the final output conclusion. Once the functions are inferred, scaled, and
combined, they are defuzzified into a crisp output which drives the system. There are
different memberships functions associated with each input and output response. Some
features to note are:
Fuzzy Logic provides a completely different, unorthodox way to approach a control problem.
This method focuses on what the system should do rather than trying to understand how it
works. One can concentrate on solving the problem rather than trying to model the system
mathematically, if that is even possible. This almost invariably leads to quicker, cheaper
solutions. Once understood, this technology is not difficult to apply and the results are usually
quite surprising and pleasing.
32