fuzzy logic

38
FUZZY LOGIC Ranga Rodrigo March 30, 2014 Most of the sides are from the Matlab tutorial. 1

Upload: sal

Post on 23-Feb-2016

49 views

Category:

Documents


0 download

DESCRIPTION

Fuzzy Logic. Ranga Rodrigo March 30 , 2014 Most of the sides are from the Matlab tutorial. Introduction. Fuzzy logi c is due to the 1965 paper by Prof. Lofti A. Zadeh . Fuzzy logic is a form of many-valued logic; it deals with reasoning that is approximate rather than fixed and exact. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Fuzzy Logic

1

FUZZY LOGIC

Ranga RodrigoMarch 30, 2014

Most of the sides are from the Matlab tutorial.

Page 2: Fuzzy Logic

2

INTRODUCTION• Fuzzy logic is due to the 1965

paper by Prof. Lofti A. Zadeh.• Fuzzy logic is a form of many-

valued logic; it deals with reasoning that is approximate rather than fixed and exact.

• Compared to traditional binary sets (true or false values) fuzzy logic variables may have a truth value that ranges in degree between 0 and 1 (no and yes).

http://www.ieeeghn.org/wiki/index.php/Lotfi_A._Zadeh

Page 3: Fuzzy Logic

3

HUMAN REASONING• Fuzzy systems attempts to mimic human reasoning.• It can capture the degree of belongingness. E.g.,– Is a student short, or tall?– In classical logic: h > 6 feet is tall and h 6 is short.– How about 5 feet 11 inches? Some may call this tall, and

some may call it short. – This information is captured as a matter of degree

• This “degree” is called a truth value.

Page 4: Fuzzy Logic

4

OVERVIEW OF A FUZZY INFERENCE SYSTEM

• The point of fuzzy logic is to map an input space to an output space.

• The input space consists of a vector of truth values.• The primary mechanism for doing this is a list of if-

then statements called rules.

Page 5: Fuzzy Logic

5

PROCESS

Crisp input Fuzzy input

Fuzzification

Fuzzy set

Apply Fuzzy Operators and Implication

Crisp output

Defuzzyfication

Page 6: Fuzzy Logic

6

A FUZZY INFERENCE SYSTEM (FIS)

Input Output

Rules

Input terms (interpret)

Output terms (assign)

A General Case

Service Tip

If service is good then tip is cheapIf service is good then tip is averageIf service is excellent then tip is generous

Service is interpreted as {poor, good,

excellent}

Tip is assigned to be {cheap, average,

generous}

A Specific Example

A FIS interprets the values in the input vector and, based on some set of rules, assigns values to the output vector.

Page 7: Fuzzy Logic

7

FUZZY SETS• Fuzzy logic starts with the concept of a fuzzy set. • A fuzzy set is a set without a crisp, clearly defined

boundary.• It can contain elements with only a partial degree of

membership.

Page 8: Fuzzy Logic

8

FUZZY SETS EXAMPLE

A classical set: The set of days of the week unquestionably includes Monday, Thursday, and Saturday. It just as unquestionably excludes butter, liberty, and dorsal fins, and so on.

A fuzzy set: Most would agree that Saturday and Sunday belong, but what about Friday? It feels like a part of the weekend, but somehow it seems like it should be technically excluded.

Of any subject, one thing must be either asserted or denied

In fuzzy logic, the truth of any statement becomes a matter of degree.

Page 9: Fuzzy Logic

9

FUZZY SETS EXAMPLE CONTD.• Reasoning in fuzzy logic is a matter of generalizing the

familiar yes-no (Boolean) logic.• If true = 1 and false = 0, fuzzy logic also permits in-

between values like 0.2 and 0.7453.• Q: Is Saturday a weekend day? – A: 1 (yes, or true)

• Q: Is Tuesday a weekend day? – A: 0 (no, or false)

• Q: Is Friday a weekend day? – A: 0.8 (for the most part yes, but not completely)

• Q: Is Sunday a weekend day? – A: 0.95 (yes, but not quite as much as Saturday).

Page 10: Fuzzy Logic

10

Truth values for weekend-ness if forced to respond with an

absolute yes or no response

Truth value for weekend-ness if allowed to respond with fuzzy in-

between values

Continuous-scale Time Plot of Weekend-ness for Two-valued And Multi-Valued Membership

Page 11: Fuzzy Logic

11

EXAMPLE OF APPLYING TRUTH VALUES• A temperature measurement for anti-lock brakes• Each function maps the same temperature value to

a truth value in the 0 to 1 range. • These truth values can then be used to determine

how the brakes should be controlled.

http://en.wikipedia.org/wiki/Fuzzy_logic

Truth values of each of the three functions at a particular temperature

Page 12: Fuzzy Logic

12

MEMBERSHIP FUNCTIONS• A membership function (MF) is a curve that defines

how each point in the input space is mapped to a membership value (or degree of membership) between 0 and 1.

• The input space is sometimes referred to as the universe of discourse.

Page 13: Fuzzy Logic

13

MEMBERSHIP FUNCTIONS CONTD.• A smoothly varying curve that passes from not-tall

to tall is the right way to represent.• The output-axis is a number known as the

membership value between 0 and 1.• The curve is known as a membership function and is

often given the designation of µ.

Page 14: Fuzzy Logic

14

Page 15: Fuzzy Logic

15

MEMBERSHIP FUNC. IN FUZZY LOGIC TOOLBOX

Triangular Membership Function

Trapezoidal Membership Function

Gaussian Membership Function

Sigmoid Membership Function

Page 16: Fuzzy Logic

16

LOGICAL OPERATIONS• Fuzzy logical reasoning is the fact that it is a

superset of standard Boolean logic.Standard Truth Table

Fuzzy Truth Table

AND: min(A,B)OR: max(A,B)NOT: 1-A

Page 17: Fuzzy Logic

17

APPLICATION OF LOGICAL OPERATORS

Page 18: Fuzzy Logic

18

IF-THEN RULES• Fuzzy sets and fuzzy operators are the subjects and

verbs of fuzzy logic. These if-then rule statements are used to formulate the conditional statements that comprise fuzzy logic.

• A single fuzzy if-then rule assumes the form

• An example of such a rule might beif x is A then y is B

If service is good then tip is average

The if-part of the rule "x is A" is called the antecedent or premise.

While the then-part of the rule "y is B" is called the consequent or conclusion.

Page 19: Fuzzy Logic

19

IF-THE RULES CONTD.• In general, the input to an if-then rule is the current

value for the input variable (in this case, service) • The output is an entire fuzzy set (in this case,

average). • This set will later be defuzzified, assigning one value

to the output.

Page 20: Fuzzy Logic

20

PROCESS

Crisp input Fuzzy input

Fuzzification

Fuzzy set

Apply Fuzzy Operators and Implication

Crisp output

Defuzzyfication

Page 21: Fuzzy Logic

21

LOGICAL OPERATION OF THEN• The implication function then modifies that fuzzy

set to the degree specified by the antecedent. • The most common ways to modify the output fuzzy

set are – truncation using the min function – scaling using the prod function

Page 22: Fuzzy Logic

22

Page 23: Fuzzy Logic

23

SUMMARY OF IF-THEN RULES• Interpreting if-then rules is a three-part process. • Fuzzify inputs: Resolve all fuzzy statements in the antecedent to a

degree of membership between 0 and 1. If there is only one part to the antecedent, then this is the degree of support for the rule.

• Apply fuzzy operator to multiple part antecedents: If there are multiple parts to the antecedent, apply fuzzy logic operators and resolve the antecedent to a single number between 0 and 1. This is the degree of support for the rule.

• Apply implication method: Use the degree of support for the entire rule to shape the output fuzzy set. The consequent of a fuzzy rule assigns an entire fuzzy set to the output. This fuzzy set is represented by a membership function that is chosen to indicate the qualities of the consequent. If the antecedent is only partially true, (i.e., is assigned a value less than 1), then the output fuzzy set is truncated according to the implication method.

Page 24: Fuzzy Logic

24

SUMMARY OF IF-THEN RULES CONTD.• In general, one rule alone is not effective. • Two or more rules that can play off one another are

needed. • The output of each rule is a fuzzy set. • The output fuzzy sets for each rule are then

aggregated into a single output fuzzy set. • Finally the resulting set is defuzzified, or resolved to

a single number.

Page 25: Fuzzy Logic

25

FUZZY INFERENCE SYSTEMS

Page 26: Fuzzy Logic

26

WHAT ARE FUZZY INFERENCE SYSTEMS?• Fuzzy inference is the process of formulating the

mapping from a given input to an output using fuzzy logic.

• The mapping then provides a basis from which decisions can be made, or patterns discerned.

• The process of fuzzy inference involves all of the pieces: – Membership Functions– Logical Operations– If-Then Rules.

• We concentrate on the Mamdani-type FIS (Ebrahim Mamdani in 1975).

Page 28: Fuzzy Logic

28

OVERVIEW OF FUZZY INFERENCE PROCESS

Page 29: Fuzzy Logic

29

STEP 1. FUZZIFY INPUTS• The first step is to take the inputs and determine

the degree to which they belong to each of the appropriate fuzzy sets via membership functions.

Page 30: Fuzzy Logic

30

STEP 2. APPLY FUZZY OPERATOR• After fuzzification, the degree to which each part of the

antecedent is satisfied for each rule is known. If the antecedent of a given rule has more than one part, the fuzzy operator is applied to obtain one number that represents the result of the antecedent for that rule.

Page 31: Fuzzy Logic

31

STEP 3. APPLY IMPLICATION METHOD• After applying a weight to each rule, the implication

method is implemented. A consequent is a fuzzy set represented by a membership function, which weights appropriately the linguistic characteristics that are attributed to it. The consequent is reshaped using a function associated with the antecedent (a single number).

Page 32: Fuzzy Logic

32

Page 33: Fuzzy Logic

33

STEP 4. AGGREGATE ALL OUTPUTS• Because decisions are based on the testing of all of

the rules in a FIS, the rules must be combined in some manner in order to make a decision. Aggregation is the process by which the fuzzy sets that represent the outputs of each rule are combined into a single fuzzy set.

• Methods:– max (maximum)– probor (probabilistic OR)– sum (simply the sum of each rule's output set)

Page 34: Fuzzy Logic

34

fuzzy tipper

Page 35: Fuzzy Logic

35

STEP 5. DEFUZZIFY• The input for the defuzzification process is a fuzzy

set (the aggregate output fuzzy set) and the output is a single number. As much as fuzziness helps the rule evaluation during the intermediate steps, the final desired output for each variable is generally a single number. However, the aggregate of a fuzzy set encompasses a range of output values, and so must be defuzzified in order to resolve a single output value from the set.

• Methods: centroid, bisector, middle of max, largest of max, smallest of max.

Page 36: Fuzzy Logic

36

Page 37: Fuzzy Logic

37

SUMMARY

Page 38: Fuzzy Logic

38