optimal search

27
OPTIMAL Search OPTIMAL Search When cost of When cost of TRAVERSING TRAVERSING the path should be the path should be minimized (even at expense of more minimized (even at expense of more complicated complicated SEARCHING SEARCHING ) : ) : Uniform Cost Uniform Cost Branch and Bound Branch and Bound Introducing Underestimates Introducing Underestimates Path Deletion Path Deletion A* A*

Upload: mervin

Post on 20-Jan-2016

41 views

Category:

Documents


0 download

DESCRIPTION

OPTIMAL Search. Uniform Cost Branch and Bound Introducing Underestimates Path Deletion A*. When cost of TRAVERSING the path should be minimized (even at expense of more complicated SEARCHING ) :. 4. 4. 3. 5. 5. 4. 3. 2. 4. 4. 3. S. 4. A. D. 2. 5. 5. A. B. C. B. D. A. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: OPTIMAL Search

OPTIMAL SearchOPTIMAL Search

When cost of When cost of TRAVERSINGTRAVERSING the path should be the path should be minimized (even at expense of more complicatedminimized (even at expense of more complicated

SEARCHINGSEARCHING) :) :

Uniform CostUniform Cost

Branch and BoundBranch and Bound

Introducing UnderestimatesIntroducing Underestimates

Path DeletionPath Deletion

A*A*

Page 2: OPTIMAL Search

2

Re-introduce the costs Re-introduce the costs of arcs in the NETof arcs in the NET

AA

DD

BB

EE

CC

FFGGSS

33

44

44

44

55 55

44

3322

SSAA DD

BB DD EEAA

CC EE EE BB BB FF

DD FF BB FF CC EE AA CC GG

GG CC GG FF

GG

33

33 33

33

33

22

22

2244

44

4444

44

4444

44

44

44

44

44

5555

55 55

5555

Page 3: OPTIMAL Search

3

Uniform cost algorithmUniform cost algorithm= uniformed best-first= uniformed best-first

SS

AA DD

BB DD AA EE

EE BB BB FF

BB FF CC EE AA CC GG

GG

GG FFCC

33 44

44 55

55

55 22

55 44

33

33 44

77 88 99 66

10101111CC EE

DD FF

GG

44 55

1111 1212 1313 1313

1313

44

At each At each step, step, select the select the node with node with the lowest the lowest accumul-accumul-ated cost.ated cost.

Page 4: OPTIMAL Search

4

Uniform cost algorithm:Uniform cost algorithm:

(BY ACCUMULATED COST(BY ACCUMULATED COST))

1. 1. QUEUEQUEUE <-- path only containing the root; <-- path only containing the root;

2. 2. WHILEWHILE QUEUEQUEUE is not empty is not empty ANDAND goal is not reached goal is not reached

DODO remove the first path from the remove the first path from the QUEUEQUEUE;; create new paths (to all children);create new paths (to all children); reject the new paths with loops;reject the new paths with loops; add the new paths and sort the entire add the new paths and sort the entire QUEUEQUEUE;;

3. 3. IFIF goal reached goal reached THENTHEN success; success; ELSEELSE failure; failure;

Page 5: OPTIMAL Search

5

Problem: NOT always optimal!Problem: NOT always optimal!

GG

100100

55

DD

55

1010

EE55

1515

FF55

2020

SSAA CC

11 5555

11

BB11

22 Uniform cost Uniform cost

returns the path returns the path with cost 102, with cost 102, while there is a while there is a path with cost 25.path with cost 25.

Page 6: OPTIMAL Search

6

The Branch-and-Bound principleThe Branch-and-Bound principle

Use any (complete) search Use any (complete) search method to find method to find a patha path..

Remove all partial paths Remove all partial paths that have an accumulated that have an accumulated cost larger or equal than cost larger or equal than the found path.the found path.

Continue search for the Continue search for the next path.next path.

Iterate.Iterate.

3.53.5

SS

BB

DDCCGG

AA

5555

EE 66

FirstFirstgoalgoalreachedreached

22

33

33

22 330.50.5

GGXX

ignoreignore

XXignoreignore

Page 7: OPTIMAL Search

7

A weak integration of branch A weak integration of branch and bound in uniform cost:and bound in uniform cost:

Change the Change the termination condition:termination condition: only terminate when only terminate when

a path to a goal node a path to a goal node HAS BECOME THE HAS BECOME THE BEST PATH.BEST PATH.

GG

100100

BB

55SS

AA CC

11

11

5511

22

102102

FF55

DD

EE

55

55

55

1010

1515

2020

2525

Page 8: OPTIMAL Search

8

Optimal Uniform cost version:Optimal Uniform cost version:

(by accumulated cost(by accumulated cost))

1. 1. QUEUEQUEUE <-- path only containing the root; <-- path only containing the root;

2. 2. WHILE WHILE QUEUEQUEUE is not empty is not empty ANDAND first pathfirst path does not reach goal does not reach goal remove the first path from the remove the first path from the QUEUEQUEUE;; create new paths (to all children);create new paths (to all children); reject the new paths with loops;reject the new paths with loops; add the new paths and sort the entire add the new paths and sort the entire QUEUEQUEUE;;

3. 3. IFIF goal reached goal reached THENTHEN success; success; ELSEELSE failure; failure;

Page 9: OPTIMAL Search

9

Example:Example:

SS

AA DD 44

SS

AA

BB DD77 88DD

SS

AA DD

BB DD77 88 AA EE99

AA DD33 44SS

AA

BB DD77 88

DD

AA EE99 66

EE

BB FF1111 1010

Page 10: OPTIMAL Search

10

SSAA DD

BB DD 88 AA EE99BB FF1111 1010

SSAA DD

BB DD AA EE99BB FF1111 1010CC EE1111 1212

SSAA DD

BB DD AA EEBB FF1111 1010CC EE1111 1212 EE 1010

SSAA DD

BB DD AA EEBB FF1111 1010CC EE1111 1212 EE BB 1313

BB

CC EE1111 1212

DD

EE 1010

AA

BB 1313

EEBB FF1515 1414

Page 11: OPTIMAL Search

11

SSAA DD

BB DD AA EEBB FF1111CC EE1111 1212 EE BB 1313

BB FF1515 1414

SSAA DD

BB DD AA EEBB FFCC EE1111 1212 EE BB 1313

BB FF1515 1414 GG 1313

SSAA DD

BB DD AA EEBB FFCC EE EE BB 1313

BB FF1515 1414 GG 1313AA CC1515 1515

FF

GG 1313Don’t stop yet!Don’t stop yet!

BB

AA CC1515 1515

EE

FFDD1414 1616 STOP!STOP!

Page 12: OPTIMAL Search

12

Properties of extended uniform Properties of extended uniform cost :cost :

Optimal path:Optimal path: IfIf there exists a number there exists a number > > 0, such that every arc 0, such that every arc

has has costcost , and if the branching factor is finite, , and if the branching factor is finite, ThenThen extended uniform cost finds the optimal path extended uniform cost finds the optimal path

(if one exists).(if one exists).

Memory and speed:Memory and speed: In the worst case, at least as bad as for breadth-In the worst case, at least as bad as for breadth-

first:first: needs additional sorting step after each path- needs additional sorting step after each path-

expansion ! expansion ! How to improve ?How to improve ?

Page 13: OPTIMAL Search

13

Extension with Extension with heuristic estimates:heuristic estimates:

Replace the ‘accumulated cost’ in the ‘extended uniform Replace the ‘accumulated cost’ in the ‘extended uniform cost’ algorithm by a function:cost’ algorithm by a function:

f(f(pathpath) ) == cost( cost(pathpath) ) ++ h( h(endpoint_pathendpoint_path))

cost(cost(pathpath) ) = = the accumulated cost of the partial paththe accumulated cost of the partial pathh(h(TT) ) == a heuristic estimate of the cost remaining a heuristic estimate of the cost remaining from from TT to a goal node to a goal node

f(f(pathpath) ) == an estimate of the cost of a path extending an estimate of the cost of a path extending the current path to reach a goal.the current path to reach a goal.

++

where:where:

Page 14: OPTIMAL Search

14

Example: Reconsider the Example: Reconsider the straight-line distance:straight-line distance:

h(h(TT)) = the straight-line distance from = the straight-line distance from TT to G to G

DD EE

GGSS

AA BB CC

FF

44

4444

4433

3322

55 55

DD EE

GGSS

AA BB CC

FF

446.76.710.410.4

1111

8.98.96.96.9 33

Page 15: OPTIMAL Search

15

AA DD3 + 10.4 = 13.43 + 10.4 = 13.4 4 + 8.9 = 12.94 + 8.9 = 12.9

SS

SS

AA DD13.413.4

SSAA DD

AA EE13.413.4

19.419.4

SSAA DD

AA EEBB FF

13.413.419.419.4

17.717.7

DD

AA EE9 + 10.4 = 19.49 + 10.4 = 19.4 6 + 6.9 = 12.96 + 6.9 = 12.9

EEBB FF10 + 3.0 = 13.010 + 3.0 = 13.011 + 6.7 = 17.711 + 6.7 = 17.7

FF

GG13 + 0.0 = 13.013 + 0.0 = 13.0

STOP!STOP!

Page 16: OPTIMAL Search

16

Estimate-extended Estimate-extended Uniform cost algorithm: Uniform cost algorithm:

(by f = cost + h(by f = cost + h))

1. 1. QUEUEQUEUE <-- path only containing the root; <-- path only containing the root;

2. 2. WHILE WHILE QUEUEQUEUE is not empty is not empty ANDAND first pathfirst path does not reach goal does not reach goal remove the first path from the remove the first path from the QUEUEQUEUE;; create new paths (to all children);create new paths (to all children); reject the new paths with loops;reject the new paths with loops; add the new paths and sort the entire add the new paths and sort the entire QUEUEQUEUE;;

3. 3. IFIF goal reached goal reached THENTHEN success; success; ELSEELSE failure; failure;

Page 17: OPTIMAL Search

17

OptimalityOptimality With the same condition on the arcs-costs and on the With the same condition on the arcs-costs and on the

branching factor:branching factor:

SSAA DD

AA EEBB FF

13.413.419.419.4

17.717.7

GG 1313

IFIF for all for all TT: : h(h(TT)) is an UNDERestimate of the is an UNDERestimate of the remaining cost to a goal noderemaining cost to a goal node

THENTHEN estimate-extended uniform cost is optimal. estimate-extended uniform cost is optimal.

Intuition: Intuition:

includes includes underestimatedunderestimatedremaining costremaining cost

GG

with with realreal remaining remainingcost, this path mustcost, this path mustat least be 13.4at least be 13.4

Page 18: OPTIMAL Search

18

More on underestimates:More on underestimates: Example:Example:

SS

AA

DD

FF

BB

EE

HH

CC

GG

II

1111 11

11

11

11

11

11

11

11

11

Real Real remainingremainingcostscosts

33 22 11

22 11

33 22 11

33 22 11

55

44

44

33 22

Over-Over-estimateestimate

If If hh is NOT an underestimate: is NOT an underestimate:

SS

AA

DD

FF

1+31+3

1+51+5

1+41+4

BB2+22+2

AA BB CC3+13+1

CC

GG44

Not the optimal pathNot the optimal path!!

Page 19: OPTIMAL Search

19

More on underestimates:More on underestimates: Example:Example:

33 22

SS

AA

DD

FF

BB

EE

HH

CC

GG

II

1111 11

11

11

11

11

11

11

11

11 33

22

22

11

11

11

Real Real remainingremainingcostscosts

If If hh is an underestimate: is an underestimate:

SS

AA

DD

FF

1+11+1

1+21+2

1+31+3

11 00 00

22

33

11

22 11

Under-Under-estimateestimate

AA BB2+02+0

CC3+03+0

BB

GG44GG

CC

DD EEEE 3 !3 !

Bad underestimates always get cor-Bad underestimates always get cor-rected by increasing accumulated costrected by increasing accumulated cost

2+12+1

Page 20: OPTIMAL Search

20

Speed and memorySpeed and memory

In the worst case: no improvement over ‘branch In the worst case: no improvement over ‘branch and bounded extended uniform cost’ and bounded extended uniform cost’ Just take h = 0 everywhere.Just take h = 0 everywhere.

For good heuristic functions: search may For good heuristic functions: search may expand much less nodes !expand much less nodes ! See our running example.See our running example.

BUT:BUT: the cost of computing such functions may the cost of computing such functions may be highbe high Trade-off Trade-off

Page 21: OPTIMAL Search

21

An orthogonal extension:An orthogonal extension:path deletionpath deletion

Discard redundant paths:Discard redundant paths: in the ‘branch and bound extended uniform cost’ :in the ‘branch and bound extended uniform cost’ :

Principle:Principle: the minimum distance from the minimum distance from SS to to GG via Ivia I = =

(min. dist. from (min. dist. from SS to to II) + (min. dist. from ) + (min. dist. from II to to GG) )

SS

AA DD 4433AA

BB DD77 88Accumulated distanceAccumulated distanceXX

discard !discard !

Page 22: OPTIMAL Search

22

More precisely:More precisely:

IFIF the QUEUE contains: the QUEUE contains: a path a path PP terminating in terminating in II, with cost , with cost cost_Pcost_P a path a path QQ containing containing I I, with cost , with cost cost_Qcost_Q cost_Pcost_P cost_Qcost_Q

THENTHEN delete delete PP

SS

AA DD

BB DD77 88 AA EE99 66XX

QQ PP

Page 23: OPTIMAL Search

23

AA DD33 44SS

SS

AA DD 44

BB DD77 88XX

SS

AA DD

BB DD77 AA EE99 66XX XX

SS

AA DD

BB DD77 AA EE

BB FF1111 1010XX

XX XX

Page 24: OPTIMAL Search

24

SSAA DD

BB DD AA EEBB FF 1010CC EE1111 1212

XX XX

XXXX

SSAA DD

BB DD AA EEBB FFCC EE1111

GG 1313

XX XX

XXXX

Note how this optimization reduces the number of Note how this optimization reduces the number of expansions VERY much, compared to ‘branch and expansions VERY much, compared to ‘branch and bound extended uniform cost’.bound extended uniform cost’.

5 expansions less !5 expansions less !

Page 25: OPTIMAL Search

25

A* searchA* search

IS:IS: Branch and bound extended,Branch and bound extended, Heuristic Underestimate extended,Heuristic Underestimate extended, Redundant path deletion extended,Redundant path deletion extended, Uniform Cost Search.Uniform Cost Search.

Note that redundant path deletion is based on the Note that redundant path deletion is based on the accumulated costsaccumulated costs only, so that there is no problem only, so that there is no problem combining it with heuristic underestimates.combining it with heuristic underestimates.

Page 26: OPTIMAL Search

26

A* algorithm:A* algorithm:1. 1. QUEUEQUEUE <-- path only containing the root; <-- path only containing the root;

2. 2. WHILE WHILE QUEUEQUEUE is not empty is not empty ANDAND first pathfirst path does not reach goal does not reach goal remove the first path from the remove the first path from the QUEUEQUEUE;; create new paths (to all children);create new paths (to all children); reject the new paths with loops;reject the new paths with loops; add the new paths and sort the entire add the new paths and sort the entire QUEUEQUEUE;;

IFIF QUEUEQUEUE contains contains path P terminating in I, with cost cost_P, and path Q containing I, with cost cost_Q ANDAND cost_P cost_Q

THENTHEN delete P3. 3. IFIF goal reached goal reached THENTHEN success; success; ELSEELSE failure; failure;

(by f = cost + h(by f = cost + h))

Page 27: OPTIMAL Search

27

AA DD3 + 10.4 = 13.43 + 10.4 = 13.4 4 + 8.9 = 12.94 + 8.9 = 12.9

SS

SS

AA DD

AA EE

13.413.4

9 + 10.4 = 19.49 + 10.4 = 19.4 6 + 6.9 = 12.96 + 6.9 = 12.9XX

SSAA DD

AA EEBB FF

13.413.4

11 + 6.7 = 17.711 + 6.7 = 17.7 10 + 3.0 = 13.010 + 3.0 = 13.0XX

SSAA DD

AA EEBB FF

13.413.4

17.717.7

GG13 + 0.0 = 13.013 + 0.0 = 13.0

STOP!STOP!XX

Only difference is here.Only difference is here.