1 Kuliah 4 : Informed Search. 2 Outline Best-First Search Greedy Search A* Search.
Recursive Best-First Search
Transcript of Recursive Best-First Search
• RBFS is a linear-space algorithm that expands nodes in best-first order even with a non-monotonic cost function and generates fewer nodes than iterative deepening with a monotonic cost function.
Recursive Best-First SearchRecursive Best-First Search
Simple Recursive Best-First SearchSimple Recursive Best-First Search• SRBFS uses a local cost threshold for each recursive
call.• It takes 2 arguments:
– a node– an upper bound
• It explores the subtree below the node as long as it contains frontier nodes whose costs do not exceed the upped bound.
• Every node has an upper bound on cost.• Upper bound=min(upper bound on it’s parent,current
value of it’s lowest cost brother)
SRBFS example with non-SRBFS example with non-monotonic cost function monotonic cost function
Expand the root and
compute the costs of the
children
55
1122 2
SRBFS example with non-SRBFS example with non-monotonic cost function monotonic cost function
Expand the root and
compute the costs of the
children
55
1122 2
55
22 11
3344
2
Expand the right child , evaluate grandchildren.
The recursive call terminates and return the minimum value of
children
SRBFS example with non-SRBFS example with non-monotonic cost function monotonic cost function
Expand the root and
compute the costs of the
children
55
1122 2
55
22 11
3344
2
Expand the right child , evaluate grandchildren.
The recursive call terminates and return the minimum value of
children
55
33223
The backed-up value of 3 is stored as
the new value of the right
child
SRBFS example with cost SRBFS example with cost equal to depthequal to depth
11111
SRBFS example with cost SRBFS example with cost equal to depthequal to depth
11111
2222
SRBFS example with cost SRBFS example with cost equal to depthequal to depth
2211 2
SRBFS example with cost SRBFS example with cost equal to depthequal to depth
2211 2
2222 2
SRBFS example with cost SRBFS example with cost equal to depthequal to depth
2211 2
2222 2
3333
SRBFS example with cost SRBFS example with cost equal to depthequal to depth
2211 2
3322 2
SRBFS example with cost SRBFS example with cost equal to depthequal to depth
2211 2
3322 2
3333
SRBFS example with cost SRBFS example with cost equal to depthequal to depth
2211 2
3333
SRBFS example with cost SRBFS example with cost equal to depthequal to depth
2233
SRBFS -The AlgorithmSRBFS -The Algorithm
SRBFS ( node: N ,bound B)
IF f( N) > B RETURN f(n)
IF N is a goal, EXIT algorithm
IF N has no children, RETURN infinity
FOR each child Ni of N, F[i] := f(Ni)
sort Ni and F[i] in increasing order of F[i]
IF only one child, F[2] = infinity
WHILE (F[1] B and f[1] < infinity)
F[1] := SRBFS (N1, MIN(B, F[2]))
insert N1 and F[1] in sorted order
RETURN F[1]
SRBFS expands nodes in best-first order, even if the cost function is non-monotonic.Unfortunately, however, SRBFS is inefficient - much of the work done is redundant.
Continuing the previous example will reach this state
SRBFS -UnefficiencySRBFS -Unefficiency
8877 8 8877 8
2222 2
Full Recursive Best-First SearchFull Recursive Best-First Search
The way to avoid this inefficiency is for children to inherit their parent’s values as their own, if the parent’s values are greater than the children’s values.
Inefficiency of SRBFS and its solution.
8877 8
2222 2
8877 8
7777 7
• In order to be expanded, the upper bound on a node must be at least as large as its stored value.
• If a node has been previously expanded, its stored value will be greater than its static value.
• If the stored value of a node is greater than its static value, its stored value is the minimum of the last stored values of its children.
In general, a parent’s stored value is passed down to its children, which inherit the value only if it exceeds both the parent’s static value and the child’s static value.
Full Recursive Best-First SearchFull Recursive Best-First Search
Full RBFS -The AlgorithmFull RBFS -The AlgorithmRBFS ( node: N ,value: F(N), bound B)
IF f( N) > B RETURN f(n)
IF N is a goal, EXIT algorithm
IF N has no children, RETURN infinity
FOR each child Ni of N, F[i] := f(Ni)
IF f(N) < F(N) THEN F[i] := MAX (F(N), f(Ni))
ELSE F[i] := f(Ni)
sort Ni and F[i] in increasing order of F[i]
IF only one child, F[2] = infinity
WHILE (F[1] B and f[1] < infinity)
F[1] := SRBFS (N1, MIN(B, F[2]))
insert N1 and F[1] in sorted order
RETURN F[1]
Full Recursive Best-First Search Full Recursive Best-First Search ExampleExample
4433 4
Full Recursive Best-First Search Full Recursive Best-First Search ExampleExample
4433 4
3333 3
Full Recursive Best-First Search Full Recursive Best-First Search ExampleExample
4433 4
3333 3
3333 3
Full Recursive Best-First Search Full Recursive Best-First Search ExampleExample
4433 4
3333 3
3333 3
4444
RBFS vs SRBFSRBFS vs SRBFS
• RBFS behaves differently depending on whether it is expanding new nodes, or previously expanded nodes:
– New nodesNew nodes - proceeds like Best-First.– Previously expanded nodesPreviously expanded nodes - behaves like BFS
until it reaches a lowest - cost node.Then it reverts back to Best-First.
Space Complexity of SRBFS Space Complexity of SRBFS and RBFS and RBFS
where b is the branching factor and d is the maximum search depth.
The space complexity of SRBFS and RBFS is O(bd)
Time Complexity of SRBFS and Time Complexity of SRBFS and RBFSRBFS
• The asymptotic time complexity of SRBFS and RBFS is the number of node generations.
• The actual number of nodes generated depends on the particular cost function.
Worst case Time ComplexityWorst case Time Complexity
• As with ID, the worst-case time complexity occurs when
– all nodes have unique cost values. – they must be arranged so that successive
nodes in an ordered sequence of cost values are in different subtrees of the root node.
• In order to expand each new node to depth d, both SRBFS and RBFS must abandon their current path all the way back to the root.
Worst case Time ComplexityWorst case Time Complexity
0
1 2
c3 5 c c4 6
7 912
14
c1113 8
10
Worst case Time ComplexityWorst case Time Complexity
The worst case time complexity of SRBFS and RBFS is O(b2d-1)
RBFS vs. IDRBFS vs. ID
• If the cost function is non-monotonic, the two If the cost function is non-monotonic, the two algorithms are not directly comparable.algorithms are not directly comparable.
• RBFS generate fewer nodes than ID on average.RBFS generate fewer nodes than ID on average.
• If the expected number of zero-cost children of a node is less then 1, then DFBnB will run in exponential time in the search depth but the space complexity is linear.