Best-First Search Minimizing Space or Time RBFS

59
RBFS-1 © Gunnar Gotshalks Best-First Search Minimizing Space or Time RBFS Take more space than IDA* Take less time than IDA*

Transcript of Best-First Search Minimizing Space or Time RBFS

Page 1: Best-First Search Minimizing Space or Time RBFS

RBFS-1© Gunnar Gotshalks

Best-First SearchMinimizing Space or Time

RBFSTake more space than IDA* Take less time than IDA*

Page 2: Best-First Search Minimizing Space or Time RBFS

RBFS-2© Gunnar Gotshalks

RBFS general properties

◊  Similar to A* algorithm developed for heuristic search

Page 3: Best-First Search Minimizing Space or Time RBFS

RBFS-3© Gunnar Gotshalks

RBFS general properties – 2

◊  Similar to A* algorithm developed for heuristic search»  Both are recursive in the same sense

Page 4: Best-First Search Minimizing Space or Time RBFS

RBFS-4© Gunnar Gotshalks

RBFS general properties – 3

◊  Similar to A* algorithm developed for heuristic search»  Both are recursive in the same sense

◊  Difference between A* and RBFS

Page 5: Best-First Search Minimizing Space or Time RBFS

RBFS-5© Gunnar Gotshalks

RBFS general properties – 3

◊  Similar to A* algorithm developed for heuristic search»  Both are recursive in the same sense

◊  Difference between A* and RBFS»  A* keeps in memory all of the already generated nodes

Page 6: Best-First Search Minimizing Space or Time RBFS

RBFS-6© Gunnar Gotshalks

RBFS general properties – 4

◊  Similar to A* algorithm developed for heuristic search»  Both are recursive in the same sense

◊  Difference between A* and RBFS»  A* keeps in memory all of the already generated nodes

»  RBFS only keeps the current search path and the sibling nodes along the path

Page 7: Best-First Search Minimizing Space or Time RBFS

RBFS-7© Gunnar Gotshalks

RBFS space – 2

» When does RBFS suspend the search of a subtree?

Page 8: Best-First Search Minimizing Space or Time RBFS

RBFS-8© Gunnar Gotshalks

RBFS space – 3

» When does RBFS suspend the search of a subtree? >  When it no longer looks the best

Page 9: Best-First Search Minimizing Space or Time RBFS

RBFS-9© Gunnar Gotshalks

RBFS space – 3

» When does RBFS suspend the search of a subtree? >  When it no longer looks the best

» What does it do when a subtree is suspended?

Page 10: Best-First Search Minimizing Space or Time RBFS

RBFS-10© Gunnar Gotshalks

RBFS space – 3

» When does RBFS suspend the search of a subtree? >  When it no longer looks the best

» What does it do when a subtree is suspended?>  It forgets the subtree to save space

Page 11: Best-First Search Minimizing Space or Time RBFS

RBFS-11© Gunnar Gotshalks

RBFS space – 4

» When does RBFS suspend the search of a subtree? >  When it no longer looks the best

» What does it do when a subtree is suspended?>  It forgets the subtree to save space

» What is the space complexity?

Page 12: Best-First Search Minimizing Space or Time RBFS

RBFS-12© Gunnar Gotshalks

RBFS space – 5

» When does RBFS suspend the search of a subtree? >  When it no longer looks the best

» What does it do when a subtree is suspended?>  It forgets the subtree to save space

» What is the space complexity?>  Linear with depth of the search

Page 13: Best-First Search Minimizing Space or Time RBFS

RBFS-13© Gunnar Gotshalks

RBFS space – 6

» When does RBFS suspend the search of a subtree? >  When it no longer looks the best

» What does it do when a subtree is suspended?>  It forgets the subtree to save space

» What is the space complexity?>  Linear with depth of the search

–  Same as IDA*

Page 14: Best-First Search Minimizing Space or Time RBFS

RBFS-14© Gunnar Gotshalks

RBFS memory

» When RBFS suspends searching a subtree, what does it remember?

Page 15: Best-First Search Minimizing Space or Time RBFS

RBFS-15© Gunnar Gotshalks

RBFS memory – 2

» When RBFS suspends searching a subtree, what does it remember?

>  An updated f-value of the root of the subtree

Page 16: Best-First Search Minimizing Space or Time RBFS

RBFS-16© Gunnar Gotshalks

Updated f-values

»  How does RBFS update the f-values?

Page 17: Best-First Search Minimizing Space or Time RBFS

RBFS-17© Gunnar Gotshalks

Updated f-values – 2

»  How does RBFS update the f-values?

>  Backing up the f-values in the same way as A* does

Page 18: Best-First Search Minimizing Space or Time RBFS

RBFS-18© Gunnar Gotshalks

f-value notation

◊  Static f-value»  f(N)

>  Value returned by the evaluation function>  Always the same

Page 19: Best-First Search Minimizing Space or Time RBFS

RBFS-19© Gunnar Gotshalks

f-value notation – 2

◊  Static f-value»  f(N)

>  Value returned by the evaluation function>  Always the same

◊  Backed-up value»  F(N)

>  Changes during the search–  Depends upon descendants of N

Page 20: Best-First Search Minimizing Space or Time RBFS

RBFS-20© Gunnar Gotshalks

F(N) definition

◊  RBFS backs up f-values in the same way as A*

»  How is F(N) defined?

Page 21: Best-First Search Minimizing Space or Time RBFS

RBFS-21© Gunnar Gotshalks

F(N) definition – 2

◊  RBFS backs up f-values in the same way as A*

»  How is F(N) defined?

>  If N has never been expanded?

Page 22: Best-First Search Minimizing Space or Time RBFS

RBFS-22© Gunnar Gotshalks

F(N) definition – 3

◊  RBFS backs up f-values in the same way as A*

»  How is F(N) defined?

>  If N has never been expanded?–  F(N) = f(N)

Page 23: Best-First Search Minimizing Space or Time RBFS

RBFS-23© Gunnar Gotshalks

F(N) definition – 4

◊  RBFS backs up f-values in the same way as A*

»  How is F(N) defined?

>  If N has never been expanded?–  F(N) = f(N)

>  If N has been expanded?

Page 24: Best-First Search Minimizing Space or Time RBFS

RBFS-24© Gunnar Gotshalks

F(N) definition – 5

◊  RBFS backs up f-values in the same way as A*

»  How is F(N) defined?

>  If N has never been expanded?–  F(N) = f(N)

>  If N has been expanded?–  F(N) = min ( F ( Sj ) )–  Where Sj are the subtrees of N

Page 25: Best-First Search Minimizing Space or Time RBFS

RBFS-25© Gunnar Gotshalks

Subtree exploration

»  How does RBFS explore subtrees?

Page 26: Best-First Search Minimizing Space or Time RBFS

RBFS-26© Gunnar Gotshalks

Subtree exploration – 2

»  How does RBFS explore subtrees?

>  As in A*, within a given f-bound

Page 27: Best-First Search Minimizing Space or Time RBFS

RBFS-27© Gunnar Gotshalks

Subtree exploration – 3

»  How does RBFS explore subtrees?

>  As in A*, within a given f-bound

»  How is the bound determined?

Page 28: Best-First Search Minimizing Space or Time RBFS

RBFS-28© Gunnar Gotshalks

RBFS subtree exploration – 4

»  How does RBFS explore subtrees?

>  As in A*, within a given f-bound

»  How is the bound determined?

>  From the F-values of the siblings along the current search path

Page 29: Best-First Search Minimizing Space or Time RBFS

RBFS-29© Gunnar Gotshalks

Subtree exploration – 5

»  How does RBFS explore subtrees?

>  As in A*, within a given f-bound

»  How is the bound determined?

>  From the F-values of the siblings along the current search path

>  The smallest F-value–  The closest competitor

Page 30: Best-First Search Minimizing Space or Time RBFS

RBFS-30© Gunnar Gotshalks

Subtree exploration – 6

◊  Suppose N is currently the best node

Page 31: Best-First Search Minimizing Space or Time RBFS

RBFS-31© Gunnar Gotshalks

Subtree exploration – 7

◊  Suppose N is currently the best node>  N is expanded

Page 32: Best-First Search Minimizing Space or Time RBFS

RBFS-32© Gunnar Gotshalks

Subtree exploration – 8

◊  Suppose N is currently the best node>  N is expanded>  N’s children are expanded

Page 33: Best-First Search Minimizing Space or Time RBFS

RBFS-33© Gunnar Gotshalks

Subtree exploration – 9

◊  Suppose N is currently the best node>  N is expanded>  N’s children are expanded

»  Until when?

Page 34: Best-First Search Minimizing Space or Time RBFS

RBFS-34© Gunnar Gotshalks

Subtree exploration – 10

◊  Suppose N is currently the best node>  N is expanded>  N’s children are expanded

»  Until when?>  F(N) > Bound

Page 35: Best-First Search Minimizing Space or Time RBFS

RBFS-35© Gunnar Gotshalks

Subtree exploration – 10

◊  Suppose N is currently the best node>  N is expanded>  N’s children are expanded

»  Until when?>  F(N) > Bound

»  Then what happens?

Page 36: Best-First Search Minimizing Space or Time RBFS

RBFS-36© Gunnar Gotshalks

Subtree exploration – 11

◊  Suppose N is currently the best node>  N is expanded>  N’s children are expanded

»  Until when?>  F(N) > Bound

»  Then what happens?>  Nodes below N are forgotten

Page 37: Best-First Search Minimizing Space or Time RBFS

RBFS-37© Gunnar Gotshalks

Subtree exploration – 12

◊  Suppose N is currently the best node>  N is expanded>  N’s children are expanded

»  Until when?>  F(N) > Bound

»  Then what happens?>  Nodes below N are forgotten>  N’s F-value is updated

Page 38: Best-First Search Minimizing Space or Time RBFS

RBFS-38© Gunnar Gotshalks

Subtree exploration – 13

◊  Suppose N is currently the best node>  N is expanded>  N’s children are expanded

»  Until when?>  F(N) > Bound

»  Then what happens?>  Nodes below N are forgotten>  N’s F-value is updated>  RBFS selects which node to expand next

Page 39: Best-First Search Minimizing Space or Time RBFS

RBFS-39© Gunnar Gotshalks

F-value inheritance

◊  F-values can be inherited from a node’s parents

Page 40: Best-First Search Minimizing Space or Time RBFS

RBFS-40© Gunnar Gotshalks

F-value inheritance – 2

◊  F-values can be inherited from a node’s parents

◊  Let N be a node about to be expanded

Page 41: Best-First Search Minimizing Space or Time RBFS

RBFS-41© Gunnar Gotshalks

F-value inheritance – 3

◊  F-values can be inherited from a node’s parents

◊  Let N be a node about to be expanded»  If F(N) > f(N) then N had already been expanded

Page 42: Best-First Search Minimizing Space or Time RBFS

RBFS-42© Gunnar Gotshalks

F-value inheritance – 4

◊  F-values can be inherited from a node’s parents

◊  Let N be a node about to be expanded»  If F(N) > f(N) then N had already been expanded»  F(N) was determined from N’s children

Page 43: Best-First Search Minimizing Space or Time RBFS

RBFS-43© Gunnar Gotshalks

F-value inheritance – 5

◊  F-values can be inherited from a node’s parents

◊  Let N be a node about to be expanded»  If F(N) > f(N) then N had already been expanded»  F(N) was determined from N’s children»  Children have been removed from memory

Page 44: Best-First Search Minimizing Space or Time RBFS

RBFS-44© Gunnar Gotshalks

F-value inheritance – 6

◊  F-values can be inherited from a node’s parents

◊  Let N be a node about to be expanded»  If F(N) > f(N) then N had already been expanded»  F(N) was determined from N’s children»  Children have been removed from memory

◊  Suppose a child Nk of N is generated again

Page 45: Best-First Search Minimizing Space or Time RBFS

RBFS-45© Gunnar Gotshalks

F-value inheritance – 7

◊  F-values can be inherited from a node’s parents

◊  Let N be a node about to be expanded»  If F(N) > f(N) then N had already been expanded»  F(N) was determined from N’s children»  Children have been removed from memory

◊  Suppose a child Nk of N is generated again»  Compute f(Nk)

Page 46: Best-First Search Minimizing Space or Time RBFS

RBFS-46© Gunnar Gotshalks

F-value inheritance – 8

◊  F-values can be inherited from a node’s parents

◊  Let N be a node about to be expanded»  If F(N) > f(N) then N had already been expanded»  F(N) was determined from N’s children»  Children have been removed from memory

◊  Suppose a child Nk of N is generated again»  Compute F(Nk)»  F(Nk) = max ( F(N) , f(Nk) )

Page 47: Best-First Search Minimizing Space or Time RBFS

RBFS-47© Gunnar Gotshalks

F-value inheritance – 9

◊  F-values can be inherited from a node’s parents

◊  Let N be a node about to be expanded»  If F(N) > f(N) then N had already been expanded»  F(N) was determined from N’s children»  Children have been removed from memory

◊  Suppose a child Nk of N is generated again»  Compute f(Nk)»  F(Nk) = max ( F(N) , f(Nk) )

>  Nk’s F-value can be inherited from N

Page 48: Best-First Search Minimizing Space or Time RBFS

RBFS-48© Gunnar Gotshalks

F-value inheritance – 10

◊  F-values can be inherited from a node’s parents

◊  Let N be a node about to be expanded»  If F(N) > f(N) then N had already been expanded»  F(N) was determined from N’s children»  Children have been removed from memory

◊  Suppose a child Nk of N is generated again»  Compute f(Nk)»  F(Nk) = max ( F(N) , f(Nk) )

>  Nk’s F-value can be inherited from N–  Nk was generated earlier

Page 49: Best-First Search Minimizing Space or Time RBFS

RBFS-49© Gunnar Gotshalks

F-value inheritance – 11

◊  F-values can be inherited from a node’s parents

◊  Let N be a node about to be expanded»  If F(N) > f(N) then N had already been expanded»  F(N) was determined from N’s children»  Children have been removed from memory

◊  Suppose a child Nk of N is generated again»  Compute f(Nk)»  F(Nk) = max ( F(N) , f(Nk) )

>  Nk’s F-value can be inherited from N–  Nk was generated earlier–  F(Nk) was ≥ F(N), otherwise F(N) would be smaller

Page 50: Best-First Search Minimizing Space or Time RBFS

RBFS-50© Gunnar Gotshalks

Fig 12.2 snapshots

S is expanded

A is found to be the best child

h(n) in magentag(n) in cloverf(n) in mocha +=

7 = 2 + 5

8 = 4 + 4

10 = 6 + 4

12 = 9 + 3

9 = 2 + 7

11 = 7 + 4

11 = 9 + 2

F

S

E

G

A

B

C

D

T

2

5

2

2

2

2

2

3

3

11 = 11 + 0

F = f = 7 F = f = 9

S

EA

Page 51: Best-First Search Minimizing Space or Time RBFS

RBFS-51© Gunnar Gotshalks

Fig 12.2 snapshots – 2

A is expanded with bound 9

C has F-value 10

Stop expansion, backup F value

h(n) in magentag(n) in cloverf(n) in mocha +=

7 = 2 + 5

8 = 4 + 4

10 = 6 + 4

12 = 9 + 3

9 = 2 + 7

11 = 7 + 4

11 = 9 + 2

F

S

E

G

A

B

C

D

T

2

5

2

2

2

2

2

3

3

11 = 11 + 0

F = 7 F = 9

S

EA

B

C

F = f = 8

F = f = 10

Page 52: Best-First Search Minimizing Space or Time RBFS

RBFS-52© Gunnar Gotshalks

Fig 12.2 snapshots – 3

Forget expansion from A

A has backed up F value 10

E is best to expand next

h(n) in magentag(n) in cloverf(n) in mocha +=

7 = 2 + 5

8 = 4 + 4

10 = 6 + 4

12 = 9 + 3

9 = 2 + 7

11 = 7 + 4

11 = 9 + 2

F

S

E

G

A

B

C

D

T

2

5

2

2

2

2

2

3

3

11 = 11 + 0

F = 10 F = 9

S

EA

Page 53: Best-First Search Minimizing Space or Time RBFS

RBFS-53© Gunnar Gotshalks

Fig 12.2 snapshots – 4

E is expanded with bound 10

F has F-value 11

Stop expansion, backup F value

h(n) in magentag(n) in cloverf(n) in mocha +=

7 = 2 + 5

8 = 4 + 4

10 = 6 + 4

12 = 9 + 3

9 = 2 + 7

11 = 7 + 4

11 = 9 + 2

F

S

E

G

A

B

C

D

T

2

5

2

2

2

2

2

3

3

11 = 11 + 0

F = 10 F = 9

F

S

EA

F = f = 11

Page 54: Best-First Search Minimizing Space or Time RBFS

RBFS-54© Gunnar Gotshalks

Fig 12.2 snapshots – 5

Forget expansion from E

E has backed up F value 11

A is best to expand next

h(n) in magentag(n) in cloverf(n) in mocha +=

7 = 2 + 5

8 = 4 + 4

10 = 6 + 4

12 = 9 + 3

9 = 2 + 7

11 = 7 + 4

11 = 9 + 2

F

S

E

G

A

B

C

D

T

2

5

2

2

2

2

2

3

3

11 = 11 + 0

F = 10 F = 11

S

EA

Page 55: Best-First Search Minimizing Space or Time RBFS

RBFS-55© Gunnar Gotshalks

Fig 12.2 snapshots – 6

A is expanded with bound 11

D has F-value 12

Stop expansion, backup F valueh(n) in magentag(n) in cloverf(n) in mocha +=

7 = 2 + 5

8 = 4 + 4

10 = 6 + 4

12 = 9 + 3

9 = 2 + 7

11 = 7 + 4

11 = 9 + 2

F

S

E

G

A

B

C

D

T

2

5

2

2

2

2

2

3

3

11 = 11 + 0

When B and C areregenerated, they inherit F value 10 fromthe parent

F = 10 F = 11

S

EA

B

C

D

F = 10

F = f = 12

F = 10

Page 56: Best-First Search Minimizing Space or Time RBFS

RBFS-56© Gunnar Gotshalks

Fig 12.2 snapshots – 7

Forget expansion from A

A has backed up F value 12

E is best to expand next

h(n) in magentag(n) in cloverf(n) in mocha +=

7 = 2 + 5

8 = 4 + 4

10 = 6 + 4

12 = 9 + 3

9 = 2 + 7

11 = 7 + 4

11 = 9 + 2

F

S

E

G

A

B

C

D

T

2

5

2

2

2

2

2

3

3

11 = 11 + 0

F = 12 F = 11

S

EA

Page 57: Best-First Search Minimizing Space or Time RBFS

RBFS-57© Gunnar Gotshalks

Fig 12.2 snapshots – 8

E is expanded with bound 12

Reach goal, search endsh(n) in magentag(n) in cloverf(n) in mocha +=

7 = 2 + 5

8 = 4 + 4

10 = 6 + 4

12 = 9 + 3

9 = 2 + 7

11 = 7 + 4

11 = 9 + 2

F

S

E

G

A

B

C

D

T

2

5

2

2

2

2

2

3

3

11 = 11 + 0

F = 12 F = 11

F

S

E

G

A

T

F = 11

F = 11

Page 58: Best-First Search Minimizing Space or Time RBFS

RBFS-58© Gunnar Gotshalks

Algorithm

function NewF (N, F(N), Bound) if F(N) > Bound then NewF := F(N) else if goal(N) then exit search with success else if N has no children then NewF := infinity – dead end else for each child Nk of N do

if f(N) < F(N) then F(Nk) := max( F(N), f(Nk)) else F(Nk) := f(Nk)sort children Nk in increasing order of F-valuewhile F(N1) ≤ Bound and F(N1) < infinity do Bound1 := min ( Bound, F-value of sibling N1) F(N1) := NewF (N1, F(N1), Bound1) reorder nodes N1, N2 , … according to new F(N1) end

endNewF := F(N1)

Page 59: Best-First Search Minimizing Space or Time RBFS

RBFS-59© Gunnar Gotshalks

Summary RBFS properties

◊  Space complexity»  Linear in depth of search

◊  Cost of minimizing space»  Regenerate previously generated nodes

>  Overhead substantially less than IDA*

◊  Expands nodes in best-order»  Like A*, even with non-monotonic f-function»  Unlike IDA*, which requires a monotonic f-function