chapter 3 heuristic search techniques 323-670 artificial intelligence ดร. วิภาดา...

43
Chapter 3 Chapter 3 Heuristic Search Techniques Heuristic Search Techniques 323-670 Artificial Intelligence 323-670 Artificial Intelligence ดด ดด . . ดดดดดด ดดดดดดดดดดดดดด ดดดดดด ดดดดดดดดดดดดดด ดดดดดดดดดดดดดดด ดดดดดดดดดดดดดดด ดดดดดดดดดดด ดดดดดดดดดดดดดด ดดดดดดดดดดดดดดดด ดดดดดดดดดดด ดดดดดดดดดดดดดด ดดดดดดดดดดดดดดดด

Upload: nathanial-mcneil

Post on 31-Mar-2015

227 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

Chapter 3Chapter 3

Heuristic Search TechniquesHeuristic Search Techniques

Chapter 3Chapter 3

Heuristic Search TechniquesHeuristic Search Techniques

323-670 Artificial Intelligence323-670 Artificial Intelligence ดรดร..วิ�ภาดา เวิทย์�ประสิ�ทธิ์��วิ�ภาดา เวิทย์�ประสิ�ทธิ์�� ภาควิ�ชาวิ�ทย์าการคอมพิ�วิเตอร� คณะวิ�ทย์าศาสิตร� ภาควิ�ชาวิ�ทย์าการคอมพิ�วิเตอร� คณะวิ�ทย์าศาสิตร�

มหาวิ�ทย์าลั�ย์สิงขลัานคร�นทร� มหาวิ�ทย์าลั�ย์สิงขลัานคร�นทร�

Page 2: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 2

Production System

Working memory Production set = Rules Figure 5.3 Trace Figure 5.4

Data driven Figure 5.9 Goal driven Figure 5.10

Iteration # Working memory Conflict sets Rule fired

Page 3: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 3

And-Or Graph a

Data driven Goal driven

b c d

e f g

Page 4: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 4

Generate-and-test

Generate all possible solutions DFS + backtracking Generate randomly Test function yes/no Algorithm page 64

Page 5: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 5

Hill Climbing

Similar to generate-and-test Test function + heuristic function Stop

Goal state meet No alternative state to move

Page 6: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 6

Simple Hill Climbing

Task specific knowledge into the control process

Is one state better than another The first state is better than the

current state Algorithm page 66

Page 7: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 7

Steepest-Ascent Hill Climbing

Consider all moves from the current state

Select the best one as the next state

Algorithm page 67 Searching time?

Page 8: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 8

Hill Climbing Problem

No solution found : Problem Local maximum : a state that is

better than all its neighbors but it is not better than some other states farther away. backtracking

Plateau : a flat area of the search space in which a whole set of neighboring states have the same value. It is not possible to determine the best direction by using local comparison. Make big jump

Page 9: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 9

Hill Climbing Problem

Ridge : an area of the search space that is higher than surrounding areas and itself has a slope. We can not do with a single move. Fired more rules for several

direction

Page 10: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 10

Hill Climbing Characteristic

Local method It decides what to do next by

looking only at the immediate consequences of its choice (rather than by exhaustively exploring all of the consequence)

Look only one more ahead

Page 11: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 11

Local heuristic function Block world figure 3.1 p. 69 Local heuristic function

1. Add one point for every block that is resting on the thing it is supposed to be resting on.

2. Subtract one point for every block that is sitting on the wrong thing.

Initial state score = 4 (6-2) C,D,E,F,G,H correct = 6 A,B wrong = -2

Goal state score = 8 A,B,C,D,E,F,F,H all correct

Page 12: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 12

Local heuristic function

Current state : จากรู�ป 3.1 หยิบ A วางบนโต๊�ะ B C D E F G H วางเรู�ยิง

เหมื�อนเดิมื Score = 6 (B C D E F G H correct)

Block world figure 3.2 p. 69 Next state score = 4

All 3 cases Stop : no better score than the

current state = 6

Local minimum problem ต๊ดิอยิ��ในกลุ่��มืรูะดิ�บ local มืองไปไมื�พ้ นอ�าง

Page 13: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 13

Global heuristic function

Block world figure 3.1 p. 69 Global heuristic function

1. For each block that has the correct support structure add one point for every block in the support structure. (น�บหมืดิ)

For each block that has an incorrect support structure, subtract one point for every block in the existing support structure.

Page 14: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 14

Global heuristic function initial state score = -28

C = -1, D = -2, E = -3, F = -4, G = -5, H = -6, A = -7

Goal state score = 28 B = 1, C = 2, D = 3, E = 4, F = 5, G

= 6, H = 7

Page 15: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 15

Global heuristic function Current state : จากรู�ป 3.1

หยิบ A วางบนโต๊�ะ B C D E F G H วางเรู�ยิงเหมื�อนเดิมื Score = -21

(C = -1, D = -2, E= -3, F = -4, G= -5, H = -6) Block world figure 3.2 p. 69

Next state : move to case(c) Case(a) = -28 same as initial state Case(b) = -16 (C = -1, D = -2, E= -3, F = -4, G= -5, H = -1)

Case(c) = -15 (C = -1, D = -2, E= -3, F = -4, G= -5)

No Local minimum problem It’s work

Page 16: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 16

New heuristic function

1. Incorrect structure are bad and should be taken apart.More subtract score

2. Correct structure are good and should built up. Add more score for the correct structure.

สิ่"งที่�"เรูาต๊ องพ้จารูณา How to find a perfect heuristic function? เข้ าไปในเมืองที่�"ไมื�เคยิไปจะหลุ่�กเลุ่�"ยิงที่างต๊�น dead

end ไดิ อยิ�างไรู

Page 17: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 17

Simulated Annealing Hill climbing variation At the beginning of the process some

down hill moves may be made. Do enough exploration of the whole

space early on so that the final solution is relatively insensitive to the starting state.

ป'องก�นป(ญหา local maximum, plateau,ridge Use objective function (not heuristic

function) Use minimize value of objective function

Page 18: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 18

Simulated Annealing

Annealing schedule ถ้ าเรูาที่+าให เยิ,นเรู,วมืาก จะไดิ ผลุ่ลุ่�พ้ธ์/ high

energy อาจเกดิ local minimum ไดิ ถ้ าเรูาที่+าให เยิ,นช้ ามืาก จะไดิ ผลุ่ลุ่�พ้ธ์/ดิ� แต๊�เสิ่�ยิเวลุ่า

มืาก at low temperatures a lot of time may be wasted after the final structure has already been formed.

ควรูที่+าแบบพ้อดิ� empirical structure

Page 19: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 19

Simulated Annealing Annealing : metals are melted Cool down to get the solid structure Objective function : energy level

Try to use less energy P : probability T : temperature : annealing schedule K : Boltzmann’s constant : describe the

correspondence between the units of temperature and the unit of energy

E = ( value of current) – (value of new state) positive change in the energy

- e/KTp = e

Page 20: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 20

Simulated Annealing

Probability of a large uphill move is lower than probability of a small uphill move

Probability uphill move decrease when temperature decrease.

In the beginning of the annealing large upward moves may occur early on

Downhill moves are allowed anytime Only relative small upward moves are

allowed until finally the process converges to a local minimum configuration

Page 21: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 21

Simulated AnnealingP -Dellta(E)/T

2.718282 0 12.718282 -0.001 0.99900052.718282 -0.01 0.99004982.718282 -0.1 0.90483742.718282 -0.5 0.60653072.718282 -0.8 0.4493292.718282 -1 0.36787942.718282 -10 4.54E-052.718282 -100 3.72E-44

-0.2

0

0.2

0.4

0.6

0.8

1

1.2

-150 -100 -50 0

ช้�ดิข้ อมื�ลุ่1

- e/KTp = e

Page 22: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 22

เหมืาะสิ่+าหรู�บป(ญหาที่�"มื�จ+านวน move มืากๆหลั�กการ1. What is initial Temperature2. Criteria for decreasing T3. Level to decrease T value4. When to quitข้ อสิ่�งเกต๊ 1. When T approach 0 simulated annealing identical with simple hill climbing

Algorithm Simulated Annealing

Page 23: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 23

ข อแตกต"าง Algorithm Simulated Annealing p.71 แลัะ Hill Climbing1. The annealing schedule must be maintained.2. Move to worse states may be accepted.3. Maintain the best state found so far. If the final state is worse than that earlier state, then earlier state is still available.

Algorithm Simulated Annealing

Page 24: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 24

Best first search

OR GRAPH : Search in the graphHeuristic function : min value

page 74

Page 25: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 25

Best First Search OR GRAPH : each of its branches

represents an alternative problem-solving pattern

we assumed that we could evaluate multiple paths to the same node independently of each other

we want to find a single path to the goal use DFS : select most promising path use BSF : when no promising path/ switch

part to receive the better value old branch is not forgotten solution can be find without all completing

branches having to expanded

Page 26: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 26

Best First Search

f’ = g + h’ g: cost from initial state to current stateh’: estimate cost current state to goal statef’: estimate cost initial state to goal stateOpen node : most promising nodeClose node : keep in memory, already discover node.

Page 27: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 27

Best First Search Algorithm

page 75-76

Page 28: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 28

A* algorithm

h’ : count the nodes that we step down the path, 1 level down = 1 point, except the root node.

Underestimate : we generate up until f’(F)= 6 > f’(C) =5

then we have to go back to C.

1 level

2 level

3 level

f’(E) = f’(C) = 5

f’ = g + h’

Page 29: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 29

A* algorithm

f’ = g + h’

1 level

2 level

3 level

Overestimate : Suppose the solution is under D : we will not generate D because F’(D) = 6 > f’(G) = 4.

Page 30: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 30

A* Algorithmpage 76

Page 31: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 31

A* Algorithm

Page 32: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 32

Agenda

Agenda : a list of tasks a system could perform. a list of reasons a rating representing overall weight of evidence

suggesting that the task would be useful

When a new task is created, insert into the agenda in its proper place, we need to re-compute its rating and move it to the correct place in the list

find the better location put at the end of agenda

need a lot more time to compute a new rating

Page 33: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 33

Not acceptable dialog

agenda is not good for when interacting with people page 81-82 person...............China.........

computer............................. person...............Italy.......... computer.............................. person................................... computer.........China..........

something reasonable now may not be continue to be so after the conversation has processed for a while.

Page 34: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 34

Agenda

Page 35: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 35

And-Or Graph / Tree

can be solved by decomposing them into a set of smaller problems

And arcs are indicated with a line connecting all the components

Page 36: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 36

And-Or Graph / Tree

each arc with the successor has a cost of 1

3+4+1+1

15+10+1+1

9+27+1+1

choose lowest value = f’(B) = 5

ABEF = 17 + 1

Page 37: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 37

And-Or Graph / Tree Futility : some value use to compare the result/ threshold value

If... the estimate cost of a solution > Futility

then.....abandon the search

Page 38: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 38

Problem Reduction

Page 39: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 39

Problem Reduction

E come from J not C

Page 40: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 40

Problem Reduction

Can not find a solution from this algorithm because of C

Page 41: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 41

Problem Reduction : AO* Algorithm

Page 42: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 42

Problem Reduction : AO* Algorithm

use a single structure GRAPH we will not store g algorithm will insert all ancestor nodes into a set

path C will always be better than path B

Page 43: Chapter 3 Heuristic Search Techniques 323-670 Artificial Intelligence ดร. วิภาดา เวทย์ประสิทธิ์ ภาควิชาวิทยาการคอมพิวเตอร์

323-670 Artificial Intelligence Lecture 7-12

Page 43

Problem Reduction : AO* Algorithm

change G from 5 to 10

no backward propagation need backward propagation