Best-First Search Minimizing Space or Time RBFS
Transcript of 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*
RBFS-2© Gunnar Gotshalks
RBFS general properties
◊ Similar to A* algorithm developed for heuristic search
RBFS-3© Gunnar Gotshalks
RBFS general properties – 2
◊ Similar to A* algorithm developed for heuristic search» Both are recursive in the same sense
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
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
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
RBFS-7© Gunnar Gotshalks
RBFS space – 2
» When does RBFS suspend the search of a subtree?
RBFS-8© Gunnar Gotshalks
RBFS space – 3
» When does RBFS suspend the search of a subtree? > When it no longer looks the best
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?
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
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?
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
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*
RBFS-14© Gunnar Gotshalks
RBFS memory
» When RBFS suspends searching a subtree, what does it remember?
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
RBFS-16© Gunnar Gotshalks
Updated f-values
» How does RBFS update the f-values?
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
RBFS-18© Gunnar Gotshalks
f-value notation
◊ Static f-value» f(N)
> Value returned by the evaluation function> Always the same
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
RBFS-20© Gunnar Gotshalks
F(N) definition
◊ RBFS backs up f-values in the same way as A*
» How is F(N) defined?
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?
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)
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?
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
RBFS-25© Gunnar Gotshalks
Subtree exploration
» How does RBFS explore subtrees?
RBFS-26© Gunnar Gotshalks
Subtree exploration – 2
» How does RBFS explore subtrees?
> As in A*, within a given f-bound
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?
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
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
RBFS-30© Gunnar Gotshalks
Subtree exploration – 6
◊ Suppose N is currently the best node
RBFS-31© Gunnar Gotshalks
Subtree exploration – 7
◊ Suppose N is currently the best node> N is expanded
RBFS-32© Gunnar Gotshalks
Subtree exploration – 8
◊ Suppose N is currently the best node> N is expanded> N’s children are expanded
RBFS-33© Gunnar Gotshalks
Subtree exploration – 9
◊ Suppose N is currently the best node> N is expanded> N’s children are expanded
» Until when?
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
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?
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
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
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
RBFS-39© Gunnar Gotshalks
F-value inheritance
◊ F-values can be inherited from a node’s parents
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
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
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
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
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
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)
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) )
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
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
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
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
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
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
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
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
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
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
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
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)
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