30
• 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 Recursive Best-First Search Search

Recursive Best-First Search

  • Upload
    raresh

  • View
    318

  • Download
    6

Embed Size (px)

Citation preview

Page 1: 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

Page 2: Recursive 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)

Page 3: Recursive Best-First Search

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

Page 4: Recursive Best-First Search

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

Page 5: Recursive Best-First Search

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

Page 6: Recursive Best-First Search

SRBFS example with cost SRBFS example with cost equal to depthequal to depth

11111

Page 7: Recursive Best-First Search

SRBFS example with cost SRBFS example with cost equal to depthequal to depth

11111

2222

Page 8: Recursive Best-First Search

SRBFS example with cost SRBFS example with cost equal to depthequal to depth

2211 2

Page 9: Recursive Best-First Search

SRBFS example with cost SRBFS example with cost equal to depthequal to depth

2211 2

2222 2

Page 10: Recursive Best-First Search

SRBFS example with cost SRBFS example with cost equal to depthequal to depth

2211 2

2222 2

3333

Page 11: Recursive Best-First Search

SRBFS example with cost SRBFS example with cost equal to depthequal to depth

2211 2

3322 2

Page 12: Recursive Best-First Search

SRBFS example with cost SRBFS example with cost equal to depthequal to depth

2211 2

3322 2

3333

Page 13: Recursive Best-First Search

SRBFS example with cost SRBFS example with cost equal to depthequal to depth

2211 2

3333

Page 14: Recursive Best-First Search

SRBFS example with cost SRBFS example with cost equal to depthequal to depth

2233

Page 15: Recursive Best-First Search

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]

Page 16: Recursive Best-First Search

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

Page 17: Recursive Best-First Search

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

Page 18: Recursive Best-First Search

• 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

Page 19: 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]

Page 20: Recursive Best-First Search

Full Recursive Best-First Search Full Recursive Best-First Search ExampleExample

4433 4

Page 21: Recursive Best-First Search

Full Recursive Best-First Search Full Recursive Best-First Search ExampleExample

4433 4

3333 3

Page 22: Recursive Best-First Search

Full Recursive Best-First Search Full Recursive Best-First Search ExampleExample

4433 4

3333 3

3333 3

Page 23: Recursive Best-First Search

Full Recursive Best-First Search Full Recursive Best-First Search ExampleExample

4433 4

3333 3

3333 3

4444

Page 24: Recursive Best-First Search

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.

Page 25: Recursive Best-First Search

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)

Page 26: Recursive Best-First Search

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.

Page 27: Recursive Best-First Search

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.

Page 28: Recursive Best-First Search

• 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

Page 29: Recursive Best-First Search

Worst case Time ComplexityWorst case Time Complexity

The worst case time complexity of SRBFS and RBFS is O(b2d-1)

Page 30: Recursive Best-First Search

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.