2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

52
Artificial Intelligence Techniques applied to Engineering Part 2. Genetic Fuzzy Systems Enrique Onieva Caracuel @EnriqueOnieva 1.Fuzzy Logic 2.Genetic Algorithms 3.Genetic Fuzzy Systems 4.Applications to Intelligent Transportation Systems: My Experience

Transcript of 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Page 1: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Artificial Intelligence Techniques applied to Engineering

Part 2. Genetic Fuzzy Systems Enrique Onieva Caracuel

@EnriqueOnieva

1.Fuzzy Logic

2.Genetic Algorithms

3.Genetic Fuzzy Systems

4.Applications to Intelligent Transportation Systems: My Experience

Page 2: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 2

Academic Background

2007 – B.S. Computer Science (Granada, Spain)

2009 – M.S. Soft Computing and Intelligent Systems (Granada, Spain)

2011 – Ph.D. Computer Science (Granada, Spain)

Fuzzy and Evolutionary techniques for vehicle control in both real and virtual environments

Page 3: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 3

Professional Background

2007-2012: AUTOPIA Program Center for Automation and Robotics. Spanish Research Council – Polytechnic

University of Madrid 2009: Visiting Scholar – SRI International (California, USA)

2010: Visiting Scholar – Politecnico di Milano (Italy)

2012-2013: Decision and Optimization Models Unit. Dept. Computer Science and Artificial Intelligence. University of Granada

2013: Mobility Unit. Deusto Institute of Technology

Today: Professor here!

La Sexta Noticias, Programa AUTOPIA

https://www.youtube.com/watch?v=4c3lt6VtX1o

Page 4: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 4

Fuzzy Logic

Lotfi Asker Zadeh 1965

It was designed to represent and reason about knowledge expressed in verbal or linguistic form

It goes from a Characteristic Function Crisp Set

𝜇𝑆:𝑋→{0,1}

To a Membership Function Fuzzy Set

𝜇𝐴:𝑋→[0,1]

Page 5: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 5

Example

Young People Crisp Set Fuzzy Set

𝜇𝑆 = 1, 𝑥 ≤ 200, 𝑥 > 20

𝜇𝐴 =

1, 𝑥 ≤ 2030 − 𝑥

10, 20 < 𝑥 < 30

0, 𝑥 ≥ 30

Page 6: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 6

Examples of Fuzzy Sets

Old People

Numbers near to zero

Tall people

Motivation: In many cases, the membership of an individual to a certain set it is not defined by exact criteria

Page 7: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 7

Membership Functions

Triangular

𝑓 𝑥, 𝑎, 𝑏, 𝑐 =

𝑥−𝑎

𝑏−𝑎; 𝑎 < 𝑥 < 𝑏

𝑐−𝑥

𝑐−𝑏; 𝑏 < 𝑥 < 𝑐

0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒

Trapezoidal

𝑓 𝑥, 𝑎, 𝑏, 𝑐, 𝑑 =

𝑥−𝑎

𝑏−𝑎; 𝑎 < 𝑥 < 𝑏

𝑑−𝑥

𝑑−𝑐; 𝑐 < 𝑥 < 𝑑

1; 𝑏 < 𝑥 < 𝑐0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒

1

a c b

a b c d

Page 8: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 8

Membership Functions 2

a b c d m d

Page 9: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 9

Operations with Fuzzy Sets

Join

𝜇𝐴∪𝐵 𝑥 = max{𝜇𝐴 𝑥 , 𝜇𝐵 𝑥 }, ∀𝑥 ∈ 𝑋

Intersection

𝜇𝐴∩𝐵 𝑥 = m𝑖𝑛{𝜇𝐴 𝑥 , 𝜇𝐵 𝑥 }, ∀𝑥 ∈ 𝑋

Complement

𝜇¬𝐴 𝑥 = 1 − 𝜇𝐴 𝑥

1

Page 10: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 10

Operations with Fuzzy Sets

Intersection: T-Norms

Binary Operation ⨂: [0,1]2→ [0,1]

Satisfies:

𝑥⨂𝑦 = 𝑦⨂𝑥

𝑥⨂(𝑦⨂𝑧) = 𝑥⨂𝑦 ⨂𝑧

𝐼𝑓𝑥 ≤ 𝑦 → 𝑥⨂𝑧 ≤ 𝑦⨂𝑧

𝑥⨂0 = 0; 𝑥⨂1 = 𝑥

2

Page 11: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 11

Operations with Fuzzy Sets

Join: T-Conorms

Binary Operation ⨁: [0,1]2→ [0,1]

Satisfies:

𝑥⨁𝑦 = 𝑦⨁𝑥

𝑥⨁(𝑦⨁𝑧) = 𝑥⨁𝑦 ⨁𝑧

𝐼𝑓𝑥 ≤ 𝑦 → 𝑥⨁𝑧 ≤ 𝑦⨁𝑧

𝑥⨁0 = 𝑥; 𝑥⨁1 = 1

3

Page 12: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 12

Operations with Fuzzy Sets

Complement

Unary Operation ¬: [0,1] → [0,1]

Satisfies:

¬(0) = 1 ¬(1) =0

∀𝛼, 𝛽 ∈ 0,1 𝛼 > 𝛽 → ¬(𝛼) < ¬(𝛽)

∀𝛼 ∈ 0,1 ¬(¬ 𝛼 ) = 𝛼

4

Page 13: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 13

Examples

T-Norms Minimum 𝒎𝒊𝒏{𝒙, 𝒚} Product 𝒙 · 𝒚 Bounded Product 𝒎𝒂𝒙 𝟎, 𝒙 + 𝒚 − 𝟏

T-Conorms Maximum 𝒎𝒂𝒙{𝒙, 𝒚} Algebraic sum 𝒙 + 𝒚 − 𝒙 · 𝒚 Bounded sum 𝒎𝒊𝒏 𝟏, 𝒙 + 𝒚

Complements General 𝟏 − 𝐱 Yager (𝟏 − 𝒙𝒑)𝟏/𝒑, 𝒑 ∈ [𝟎,∞]

Sugeno 𝟏−𝒙

(𝟏−𝒑·𝒙), 𝒑 ∈ [𝟎, 𝟏]

Page 14: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 14

Example: Basketball players

To choose players for a team

Classic logic criteria:

Height (Height≥𝟏𝟖𝟓𝒄𝒎)

Hit (Hit≥𝟖𝟎%)

1

Player Height Hit Classic Solution

A 167 75 ?

B 175 95 ?

C 179 75 ?

D 183 100 ?

E 186 85 ?

F 187 75 ?

G 190 80 ?

H 200 75 ?

Page 15: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 15

Example: Basketball players

To choose players for a team

Classic logic criteria:

Height (Height≥𝟏𝟖𝟓𝒄𝒎)

Hit (Hit≥𝟖𝟎%)

2

Player Height Hit Classic Solution

A 167 75 ?

B 175 95 ?

C 179 75 ?

D 183 100 ?

E 186 85 ?

F 187 75 ?

G 190 80 ?

H 200 75 ?

Page 16: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 16

Example: Basketball players

To choose players for a team

Classic logic criteria:

Height (Height≥𝟏𝟖𝟓𝒄𝒎)

Hit (Hit≥𝟖𝟎%)

3

Player Height Hit Classic Solution

A 167 75 0

B 175 95 0

C 179 75 0

D 183 100 0

E 186 85 1

F 187 75 0

G 190 80 1

H 200 75 0

Page 17: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 17

Example: Basketball players

Fuzzy Logic Criteria:

We look for the INTERSECTION between the set involving TALL players AND the set involving players with a GOOD hit

T-Norm: MINIMUM

Fuzzy Sets

4

Page 18: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 18

Example: Basketball players

Player Height Hit Classic Solution

¿Tall? 𝝁𝑻𝒂𝒍𝒍(𝑯𝒆𝒊𝒈𝒉𝒕)

¿Good? 𝝁𝑮𝒐𝒐𝒅(𝑯𝒊𝒕)

¿Tall AND Good? Min{𝝁𝑻𝒂𝒍𝒍(𝑯𝒆𝒊𝒈𝒉𝒕),𝝁𝑮𝒐𝒐𝒅(𝑯𝒊𝒕)}

A 167 75 0

B 175 95 0

C 179 75 0

D 183 100 0

E 186 85 1

F 187 75 0

G 190 80 1

H 200 75 0

5

Page 19: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 19

Example: Basketball players

Player Height Hit Classic Solution

¿Tall? 𝝁𝑻𝒂𝒍𝒍(𝑯𝒆𝒊𝒈𝒉𝒕)

¿Good? 𝝁𝑮𝒐𝒐𝒅(𝑯𝒊𝒕)

¿Tall AND Good? Min{𝝁𝑻𝒂𝒍𝒍(𝑯𝒆𝒊𝒈𝒉𝒕),𝝁𝑮𝒐𝒐𝒅(𝑯𝒊𝒕)}

A 167 75 0 0,10 0,75 0,10

B 175 95 0 0,50 1,00 0,50

C 179 75 0 0,70 0,75 0,70

D 183 100 0 0,90 1,00 0,90

E 186 85 1 1,00 1,00 1,00

F 187 75 0 1,00 0,75 0,75

G 190 80 1 1,00 1,00 1,00

H 200 75 0 1,00 0,75 0,75

6

Page 20: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 20

Example: Restaurant

NEAR

{B}

NEAR and CHEAP

{A,B,C,D,G,H}

NEAR and CHEAP or, if FAR, CHEAP and GOOD food

¿?

1 Rest Distance Price Quality

A 0,4 20 8,5

B 0,3 50 8,0

C 1 13 6,0

D 0,8 16 6,5

E 1,5 21 9,0

F 1,3 30 9,5

G 2 10 7,5

H 2.5 9 9,0

Page 21: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 21

Example: Restaurant

NEAR

2

RES DIST PRI QUA

NEAR

CHEAP NEAR AND

CHEAP

FAR GOOD NEAR AND CHEAP OR FAR AND CHEAP AND GOOD

A 0,4 20 8,5 1,00

B 0,3 50 8,0 1,00

C 1 13 6,0 0,75

D 0,8 16 6,5 0,85

E 1,5 21 9,0 0,50

F 1,3 30 9,5 0,60

G 2 10 7,5 0,25

H 2,5 9 9,0 0,00

0 10 20 30 40 500

0.5

1

Price

CHEAP

0 0.5 1 1.5 2 2.5 30

0.5

1

Dis

tan

ce

NEAR FAR

0 2 4 6 8 100

0.5

1

Qu

alit

y

GOOD

Page 22: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 22

Example: Restaurant

NEAR

NEAR and CHEAP

AND = MINIMUM

3

RES DIST PRI QUA NEAR

CHEAP NEAR AND

CHEAP

FAR GOOD NEAR AND CHEAP OR FAR AND CHEAP AND GOOD

A 0,4 20 8,5 1,00 0,60 0,60

B 0,3 50 8,0 1,00 0,00 0,00

C 1 13 6,0 0,75 0,88 0,75

D 0,8 16 6,5 0,85 0,76 0,76

E 1,5 21 9,0 0,50 0,56 0,50

F 1,3 30 9,5 0,60 0,20 0,20

G 2 10 7,5 0,25 1,00 0,25

H 2,5 9 9,0 0,00 1,00 0,00

0 10 20 30 40 500

0.5

1

Price

CHEAP

0 0.5 1 1.5 2 2.5 30

0.5

1

Dis

tan

ce

NEAR FAR

0 2 4 6 8 100

0.5

1

Qu

alit

y

GOOD

Page 23: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 23

Example: Restaurant

NEAR NEAR and CHEAP

AND = MINIMUM

NEAR and CHEAP or, if FAR, CHEAP and GOOD food OR = MAXIMUM

4

RES DIST PRI QUA NEAR

CHEAP NEAR AND

CHEAP

FAR GOOD NEAR AND CHEAP OR FAR AND CHEAP AND GOOD

A 0,4 20 8,5 1,00 0,60 0,60 0,00 0,57 0,60

B 0,3 50 8,0 1,00 0,00 0,00 0,00 0,42 0,00

C 1 13 6,0 0,75 0,88 0,75 0,25 0,00 0,75

D 0,8 16 6,5 0,85 0,76 0,76 0,15 0,00 0,76

E 1,5 21 9,0 0,50 0,56 0,50 0,50 0,71 0,50

F 1,3 30 9,5 0,60 0,20 0,20 0,40 0,85 0,20

G 2 10 7,5 0,25 1,00 0,25 0,75 0,28 0,28

H 2,5 9 9,0 0,00 1,00 0,00 1,00 0,71 0,71

0 10 20 30 40 500

0.5

1

Price

CHEAP

0 0.5 1 1.5 2 2.5 30

0.5

1

Dis

tan

ce

NEAR FAR

0 2 4 6 8 100

0.5

1

Qu

alit

y

GOOD

Page 24: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 24

Fuzzy Rules

IF-THEN rules that allow to represent the human knowledge IF <fuzzy proposition> Antecedent

THEN <fuzzy proposition> Consequent

Types of fuzzy propositions: Atomic: (x is A), where x is a variable and A is a linguistic

term

Composed: by using (AND,OR,NOT) connectives (X is A) or (X is not B)

(X is A) and (X is Y)

(X is A) and (Z is B)

1

Page 25: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 25

Fuzzy Rules

T-norms are used for “AND” connectives

(X is A) AND (Z is B)

𝜇𝐴∩𝐵 𝑥, 𝑧 = 𝜇𝐴 𝑥 ⨂𝜇𝐵 𝑧

T-conorms are used for “OR” connectives

(X is A) OR (Z is B)

𝜇𝐴∪𝐵 𝑥, 𝑧 = 𝜇𝐴 𝑥 ⨁𝜇𝐵 𝑧

2

Page 26: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 26

Fuzzy Rules

The meaning of a rule is stablished by a relationship among the antecedent and the consequent

Implication operator

Usually T-norms (AND)

When more than a rule exist, individual results must be combined to provide a single output

Aggregation operator

Usually T-conorms (OR)

3

Page 27: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 27

Implication

IF (x is A) THEN (y is B) IF speed is Medium THEN brake is Medium

Speed= 60 km/h Brake = ¿?

Implication

1

10 20 30 40 50 60 70 80 90 100

Baja Media Alta

Velocidad

Km/h

10 20 30 40 50 60 70 80 90

Baja Media Alta

Frenado

%

0.66

¿?

1.00

0.00

1.00

0.00

Low Medium High Low Medium High

Speed Brake

Page 28: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 28

Implication

Larsen 𝒙 · 𝒚

Mamdani 𝒎𝒊𝒏{𝒙, 𝒚}

2

10 20 30 40 50 60 70 80 90 100

Baja Media Alta

Velocidad

Km/h

10 20 30 40 50 60 70 80 90

Baja Media Alta

Frenado

%

0.66

1.00

0.00

1.00

0.00

10 20 30 40 50 60 70 80 90 100

Baja Media Alta

Velocidad

Km/h

10 20 30 40 50 60 70 80 90

Baja Media Alta

Frenado

%

0.66

1.00

0.00

1.00

0.00

Low Medium High

Speed

Low Medium High

Brake

Low Medium High

Speed

Low Medium High

Brake

Page 29: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 29

Aggregation

IF speed is Low THEN brake is Low

IF speed is Medium THEN brake is Medium

IF speed is High THEN brake is High Speed = 60 km/h brake = ¿?

Mamdani Implication (𝒎𝒊𝒏{𝒙,𝒚})

1.00

0.00

1.00

0.00

1.00

0.00

1.00

0.00

1.00

0.00

1.00

0.00

1.00

0.00

Page 30: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 30

Defuzzification

Is the process to generate a single number from the fuzzy set given by the aggregation

Braking force?

1

1.00

0.00

1.00

0.00

1.00

0.00

1.00

0.00

1.00

0.00

1.00

0.00

1.00

0.00

Page 31: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 31

Defuzzification

The most common method: Center of Mass

𝐶𝑜𝑀 = 𝜇(𝑧)𝑖·𝑧𝑖𝑛𝑖=0

𝜇(𝑧)𝑖𝑛𝑖=0

(0·0,0+10·0,2+20·0,4+30·0,6+40·0,66+50·0,66+60·0,66+70·0,6+80·0,4+90·0,33+100·0,33)

(0,0+0,2+0,4+0,6+0,66+0,66+0,66+0,6+0,4+0,33+0,33)

=54,48

When speed is 60, brake must be 54.48 %

2

1.00

0.00

10 20 30 40 50 60 70 80 90

0.66

0.33

Page 32: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 32

Fuzzy Rule Based Systems

1

Page 33: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 33

Fuzzy Rule Based Systems

Data Base Fuzzy sets to define inputs/outputs terms

Rule Base Rules defining the behavior

Rule Operators AND Operator OR Operator NOT Operator Linguistic Modifiers

Implication Operator Aggregation Operator Defuzzification Operator

2

Page 34: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 34

Example

Data Base

Rule Base IF (X is Low) THEN (Z is Low)

IF (X is Medium) AND (Y is Low) THEN (Z is Low)

IF (X is Medium) AND ((Y is Medium) OR (Y is High)) THEN (Z is Medium)

IF (X is High) THEN (Z is High)

1

Low Medium High

Input X Low Medium High

Input Y Low Medium High

Output Z

Page 35: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 35

Example

We want to know the system’s output when inputs are known:

Variable X = 20

Variable Y = 40

Step 1: Fuzzification

2

10 30 50 70 90

Baja Media Alta

Entrada X

10 30 50 70 90

Baja Media Alta

Entrada Y

X=20 Y=40

0.5 0.5 0.00.0 0.75 0.25

𝝁𝑳𝒐𝒘 𝑿 = 𝟎. 𝟓 𝝁𝑴𝒆𝒅𝒊𝒖𝒎 𝑿 = 𝟎. 𝟓 𝝁𝑯𝒊𝒈𝒉 𝑿 = 𝟎.0

𝝁𝑳𝒐𝒘 𝒀 = 𝟎.0 𝝁𝑴𝒆𝒅𝒊𝒖𝒎 𝒀 = 𝟎. 𝟕𝟓 𝝁𝑯𝒊𝒈𝒉 𝒀 = 𝟎. 𝟐𝟓

Low Medium High

Input X Low Medium High

Input Y

Page 36: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 36

Example

Rule Base “goes” from this: IF (X is Low) THEN (Z is Low)

IF (X is Medium) AND (Y is Low) THEN (Z is Low)

IF (X is Medium) AND ((Y is Medium) OR (Y is High)) THEN (Z is Medium)

IF (X is High) THEN (Z is High)

To this IF (0,50) THEN (Z is Low)

IF (0,50) AND (0,00) THEN (Z is Low)

IF (0,50) AND ((0,75) OR (0,25)) THEN (Z is Medium)

IF (0,25) THEN (Z is High)

3

𝝁𝑳𝒐𝒘 𝑿 = 𝟎. 𝟓 𝝁𝑴𝒆𝒅𝒊𝒖𝒎 𝑿 = 𝟎. 𝟓 𝝁𝑯𝒊𝒈𝒉 𝑿 = 𝟎.0

𝝁𝑳𝒐𝒘 𝒀 = 𝟎.0 𝝁𝑴𝒆𝒅𝒊𝒖𝒎 𝒀 = 𝟎. 𝟕𝟓 𝝁𝑯𝒊𝒈𝒉 𝒀 = 𝟎. 𝟐𝟓

Page 37: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 37

Example

Step 2: To solve rule operators AND MIN OR MAX

Rule Base “goes” from this: IF (0,50) THEN (Z is Low) IF (0,50) AND (0,00) THEN (Z is Low) IF (0,50) AND ((0,75) OR (0,25)) THEN (Z is Medium) IF (0,25) THEN (Z is High)

To this: IF (0,50) THEN (Z is Low) IF (0,00) THEN (Z is Low) IF (0,50) THEN (Z is Medium) IF (0,25) THEN (Z is High)

Page 38: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 38

Example

Implication IF (0,5) THEN (Z is Low)

IF (0,0) THEN (Z is Low)

IF (0,5) THEN (Z is Medium)

IF (0,25) THEN (Z is High)

Aggregation

Defuzzification

8

Page 39: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 39

Takagi-Sugeno-Kang Systems

Up to now, we have seen Mamdani systems.

Rules in Mamdani systems are like:: 𝑰𝒇 𝑿𝟏𝒊𝒔𝑨𝟏 𝒀 𝑿𝟐𝒊𝒔𝑨𝟐 𝒀… 𝒀 𝑿𝑵𝒊𝒔𝑨𝑵 𝑻𝑯𝑬𝑵 𝒁𝒊𝒔𝑩

Rules in Takagi-Sugeno-Kang (TSK) are like: 𝑰𝒇 𝑿𝟏𝒊𝒔𝑨𝟏 𝒀 𝑿𝟐𝒊𝒔𝑨𝟐 𝒀… 𝒀 𝑿𝑵𝒊𝒔𝑨𝑵 𝑻𝑯𝑬𝑵𝒁 = 𝒇(𝑿𝟏, 𝑿𝟐, … , 𝑿𝑵)

1

Page 40: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 40

Takagi-Sugeno-Kang Systems

The consequent is a function of the inputs The antecedent is processed in the same way that in Mamdani systems For a input, result of triggering a rule in a real value (instead of a fuzzy set)

Zero-order TSK system: 𝒇 𝑿𝟏, 𝑿𝟐, … , 𝑿𝑵 = 𝒂𝟎

One-order TSK system: 𝒇 𝑿𝟏, 𝑿𝟐, … , 𝑿𝑵 = 𝒂𝟎 + 𝒂𝒊 · 𝑿𝒊𝒊=𝟏:𝑵

When more than one rules are triggered, results are combined in a unique value: Maximum Average Weighted average

2

Page 41: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 41

Example

Data Base

Rule Base IF (X is Low) THEN (Z = 20)

IF (X is Medium) AND (Y is Low) THEN (Z = 0)

IF (X is Medium) AND ((Y is Medium) OR (Y is High)) THEN (Z = 70)

IF (X is High) THEN (Z = 100)

1

Low Medium High

Input X Low Medium High

Input Y Low Medium High

Output Z

Page 42: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 42

Example

Operadores

AND MIN

OR MAX

Implication MIN

Aggregation & Defuzzification Weighted average

Input Values

Variable X = 20

Variable Y = 40

2

Page 43: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 43

Example

Step 1: Fuzzyfication

Step 2: To solve rule operators Y = MIN O = MAX IF (0,50) THEN (Z = 20) IF (0,00) THEN (Z = 0) IF (0,50) THEN (Z = 70) IF (0,25) THEN (Z = 100)

2

10 30 50 70 90

Baja Media Alta

Entrada X

10 30 50 70 90

Baja Media Alta

Entrada Y

X=20 Y=40

0.5 0.5 0.00.0 0.75 0.25

𝝁𝑳𝒐𝒘 𝑿 = 𝟎. 𝟓 𝝁𝑴𝒆𝒅𝒊𝒖𝒎 𝑿 = 𝟎. 𝟓 𝝁𝑯𝒊𝒈𝒉 𝑿 = 𝟎.0

𝝁𝑳𝒐𝒘 𝒀 = 𝟎.0 𝝁𝑴𝒆𝒅𝒊𝒖𝒎 𝒀 = 𝟎. 𝟕𝟓 𝝁𝑯𝒊𝒈𝒉 𝒀 = 𝟎. 𝟐𝟓

Low Medium High

Input X Low Medium High

Input Y

Page 44: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 44

Example

IF (0,50) THEN (Z = 20)

IF (0,00) THEN (Z = 0)

IF (0,50) THEN (Z = 70)

IF (0,25) THEN (Z = 100)

Step 3: Aggregation + Defuzzification

𝑜𝑢𝑡𝑝𝑢𝑡 = (20·0.5+0·0,0+70·0,5+100·0,25)

0,5+0,0+0,5+0,25= 56

Page 45: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 45

Properties of Fuzzy Rule Based Systems

Granularity: Number of fuzzy sets [3,7]

Coverage: Portion of the Universe of discourse covered by fuzzy sets

Distinguishability: Each fuzzy set must have an unique meaning

1

Page 46: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 46

Properties of Fuzzy Rule Based Systems

Consistency: There are not two rules with same antecedent an different consequent

IF (X is Low) THEN (Z is Low)

IF (X is Low) THEN (Z is High)

Completeness: Any input combination produces an output (triggers, at least, one rule)

2

Page 47: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 47

Fuzzy Logic Application

We want to handle a car’s pedals

Throttle and Brake Signal in [-1, 1] (Pedal)

We only have speed error (actual speed – desired speed)

Speed error< 0 Car goes slow

Speed error> 0 Car goes fast

1

Page 48: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 48

Fuzzy Logic Application

If the car is slow Speed up

If the car is fast Slow down

If error is zero, we do nothing

2

IF speed error is Slow THEN Pedal = Throttle

IF speed error is Adequate THEN Pedal = Nothing

IF speed error is Fast THEN Pedal = Brake

Pedal = - error / 50

Page 49: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 49

Fuzzy Logic Application

If the car is slow Speed up

If the car is fast Slow down

If error is zero, we do nothing

If the car is 20 km/h slower maximum throttle

3

IF speed error is Slow THEN Pedal = Throttle

IF speed error is Adequate THEN Pedal = Nothing

IF speed error is Fast THEN Pedal = Brake

If error<-20 pedal = 1

If error<0 pedal = -error/20

If error>0 pedal = -error/50

Page 50: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 50

Fuzzy Logic Application

If the car is slow Speed up

If the car is fast Slow down

If error is zero, we do nothing

If the car is 20 km/h slower maximum throttle

Brake pedal is stronger than throttle pedal

4

IF speed error is Slow THEN Pedal = Throttle

IF speed error is Adequate THEN Pedal = Nothing

IF speed error is Fast THEN Pedal = Brake

If error<-20 pedal = 1

If error<0 pedal = -error/20

If error>0 pedal = -error/100

Page 51: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Técnicas de Inteligencia Artificial aplicadas a la Ingeniería @EnriqueOnieva 2014/2015 51

Fuzzy Logic Application

If the car is slow Speed up If the car is fast Slow down If error is zero, we do nothing If the car is 20 km/h slower maximum throttle Brake pedal is stronger than throttle pedal If the car is near error=0 do nothing

5

IF speed error is Slow THEN Pedal = Throttle

IF speed error is Adequate THEN Pedal = Nothing

IF speed error is Fast THEN Pedal = Brake

If error<-20 pedal = 1

If error<-5 pedal =-(error+5)/15

If error<5 pedal = 0

If error>5 pedal = -error/100

Page 52: 2015 Artificial Intelligence Techniques at Engineering Seminar - Chapter 2 - Part 1: Fuzzy Logic

Thank you very much

Any Question?