1Getting Started
Fuzzy vs.Nonfuzzy Logic
In
“The Basic Tipping Problem”on page1-12
“The Nonfuzzy Approach”on page1-12
“The Fuzzy Logic Approach”on page1-16
“Problem Solution”on page1-17
攫的读音The Basic Tipping Problem
To illustrate the value of fuzzy logic,examine both linear and fuzzy
approaches to the following problem:反邪教文章
What is the right amount to tip your waitperson?
First,work through this problem the conventional(nonfuzzy)way,writing
MATLAB commands that spell out linear and piecewi-linear relations.
Then,look at the same system using fuzzy logic.
The Basic Tipping Problem.Given a number between0and10that
reprents the quality of rvice at a restaurant(where10is excellent),what
should the tip be?
Note This problem is bad on tipping as it is typically practiced in the
United States.An average tip for a meal in the U.S.is15%,though the actual
amount may vary depending on the quality of the rvice provided.
The Nonfuzzy Approach景泰蓝工艺品
Begin with the simplest possible relationship.Suppo that the tip always
equals15%of the total bill.
tip=0.15
1-12
Fuzzy vs.Nonfuzzy Logic
This relationship does not take into account the quality of the rvice,so you
need to add a new term to the equation.Becau rvice is rated on a scale of
0to10,you might have the tip go linearly from5%if the rvice is bad to25%
if the rvice is excellent.Now the relation looks like the following plot:
tip=0.20/10*rvice+0.05
The formula does what you want it to do,and is straightforward.However,
you may want the tip to reflect the quality of the food as well.This extension
of the problem is defined as follows.
The Extended Tipping Problem.Given two ts of numbers between0and
10(where10is excellent)that respectively reprent the quality of the rvice
and the quality of the food at a restaurant,what should the tip be?
1-13
1Getting Started
See how the formula is affected now that you have added another variable.
Try the following equation:
tip=0.20/20*(rvice+food)+0.05;
In this ca,the results look satisfactory,but when you look at them cloly,
they do not em quite right.Suppo you want the rvice to be a more
important factor than the food quality.Specify that rvice accounts for80%
of the overall tipping grade and the food makes up the other20%.Try this
equation:
保险的功能
rvRatio=0.8;
tip=rvRatio*(0.20/10*rvice+0.05)+...
(1-rvRatio)*(0.20/10*food+0.05);
The respon is still somehow too uniformly linear.Suppo you want more of
a flat respon in the ,you want to give a15%tip in general,but 1-14
Fuzzy vs.Nonfuzzy Logic want to also specify a variation if the rvice is exceptionally good or bad.This factor,in turn,means that the previous linear mappings no longer apply.You
can still u the linear calculation with a piecewi linear construction.Now, return to the one-dimensional problem of just considering the rvice.You can string together a simple conditional statement using breakpoints like this.
if rvice<3,
tip=(0.10/3)*rvice+0.05;
elif rvice<7,
tip=0.15;
elif rvice<=10,
tip=(0.10/3)*(rvice-7)+0.15;
end
The plot now looks like the following figure:
If you extend this to two dimensions,where you take food into account again, something like the following output results.
rvRatio=0.8;
if rvice<3,
tip=((0.10/3)*rvice+0.05)*rvRatio+...
(1-rvRatio)*(0.20/10*food+0.05);
elif rvice<7,
1-15
自制炸薯条1Getting Started
tip=(0.15)*rvRatio+...
(1-rvRatio)*(0.20/10*food+0.05);
el,
tip=((0.10/3)*(rvice-7)+0.15)*rvRatio+...现代诗句
(1-rvRatio)*(0.20/10*food+0.05);
end
The plot looks good,but the function is surprisingly complicated.It was a
little difficult to code this correctly,and it is definitely not easy to modify this
code in the future.Moreover,it is even less apparent how the algorithm works
to someone who did not e the original design process.
The Fuzzy Logic Approach
You need to capture the esntials of this problem,leaving aside all the
factors that could be arbitrary.If you make a list of what really matters in
this problem,you might end up with the following rule descriptions.
Tipping Problem Rules—Service Factor
If rvice is poor,then tip is cheap
If rvice is good,then tip is average
If rvice is excellent,then tip is generous
1-16
Fuzzy vs.Nonfuzzy Logic The order in which the rules are prented here is arbitrary.It does not
matter which rules come first.If you want to include the food’s effect on the
tip,add the following two rules.
Tipping Problem Rules—Food Factor
If food is rancid,then tip is cheap
If food is delicious,then tip is generous
You can combine the two different lists of rules into one tight list of three梅兰芳的资料
rules like so.
Tipping Problem—Both Service and Food Factors
If rvice is poor or the food is rancid,then tip is cheap
If rvice is good,then tip is average
If rvice is excellent or food is delicious,then tip is generous
The three rules are the core of your solution.Coincidentally,you have just defined the rules for a fuzzy logic system.When you give mathematical
meaning to the linguistic variables(what is an average tip,for example?)
you have a complete fuzzy inference system.The methodology of fuzzy logic
must also consider:
•How are the rules all combined?
•How do I define mathematically what an average tip is?
The next few chapters provide detailed answers to the questions.The
details of the method don’t really change much from problem to problem—the mechanics of fuzzy logic aren’t terribly complex.What matters is that you understand that fuzzy logic is adaptable,simple,and easily applied.
Problem Solution
The following plot reprents the fuzzy logic system that solves the tipping problem.朋友聚会
1-17