Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search •...
Transcript of Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search •...
![Page 1: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/1.jpg)
Review: Search problem formulationReview: Search problem formulation
• Initial stateInitial state
• Actions
i i d l• Transition model
• Goal state
• Path cost
• What is the optimal solution?
Wh i h ?• What is the state space?
![Page 2: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/2.jpg)
Review: Tree searchReview: Tree search
• Initialize the fringe using the starting state• Initialize the fringe using the starting state
• While the fringe is not empty
– Choose a fringe node to expand according to search strategyg p g gy
– If the node contains the goal state, return solution
– Else expand the node and add its children to the fringe
![Page 3: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/3.jpg)
Search strategiesSearch strategies
• A search strategy is defined by picking the order of node expansion
• Strategies are evaluated along the following dimensions:– Completeness: does it always find a solution if one exists?Completeness: does it always find a solution if one exists?– Optimality: does it always find a least‐cost solution?– Time complexity: number of nodes generated– Space complexity:maximum number of nodes in memory– Space complexity: maximum number of nodes in memory
• Time and space complexity are measured in terms of – b:maximum branching factor of the search tree
d d h f h i l l i– d: depth of the optimal solution– m: maximum length of any path in the state space (may be infinite)
![Page 4: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/4.jpg)
Uninformed search strategiesUninformed search strategies
• Uninformed search strategies use only theUninformed search strategies use only the information available in the problem definition
• Breadth‐first search
• Uniform‐cost search
• Depth‐first searchp
• Iterative deepening search
![Page 5: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/5.jpg)
Breadth‐first searchBreadth first search
• Expand shallowest unexpanded nodeExpand shallowest unexpanded node
• Implementation:f i i FIFO i t d– fringe is a FIFO queue, i.e., new successors go at end
AA
D F
B C
E GD FE G
![Page 6: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/6.jpg)
Breadth‐first searchBreadth first search
• Expand shallowest unexpanded nodeExpand shallowest unexpanded node
• Implementation:f i i FIFO i t d– fringe is a FIFO queue, i.e., new successors go at end
AA
D F
B C
E GD FE G
![Page 7: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/7.jpg)
Breadth‐first searchBreadth first search
• Expand shallowest unexpanded nodeExpand shallowest unexpanded node
• Implementation:f i i FIFO i t d– fringe is a FIFO queue, i.e., new successors go at end
AA
D F
B C
E GD FE G
![Page 8: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/8.jpg)
Breadth‐first searchBreadth first search
• Expand shallowest unexpanded nodeExpand shallowest unexpanded node
• Implementation:f i i FIFO i t d– fringe is a FIFO queue, i.e., new successors go at end
AA
D F
B C
E GD FE G
![Page 9: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/9.jpg)
Breadth‐first searchBreadth first search
• Expand shallowest unexpanded nodeExpand shallowest unexpanded node
• Implementation:f i i FIFO i t d– fringe is a FIFO queue, i.e., new successors go at end
AA
D F
B C
E GD FE G
![Page 10: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/10.jpg)
Properties of breadth‐first searchProperties of breadth first search
• Complete? pYes (if branching factor b is finite)
• Optimal?Yes – if cost = 1 per step
• Time?N b f d i b f d h d O(bd)Number of nodes in a b‐ary tree of depth d: O(bd)(d is the depth of the optimal solution)
• Space?Space?O(bd)
• Space is the bigger problem (more than time)
![Page 11: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/11.jpg)
Uniform‐cost searchUniform cost search• Expand least‐cost unexpanded node• Implementation: fringe is a queue ordered by path cost (priority p f g q y p (p y
queue)• Equivalent to breadth‐first if step costs all equal
• Complete?Yes, if step cost is greater than some positive constant ε
• Optimal?• Optimal?Yes – nodes expanded in increasing order of path cost
• Time?Number of nodes with path cost ≤ cost of optimal solution (C*) O(bC*/ ε)Number of nodes with path cost ≤ cost of optimal solution (C ), O(bC / ε)This can be greater than O(bd): the search can explore long paths consisting
of small steps before exploring shorter paths consisting of larger steps • Space?Space?
O(bC*/ ε)
![Page 12: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/12.jpg)
Depth‐first searchDepth first search
• Expand deepest unexpanded nodeExpand deepest unexpanded node
• Implementation:– fringe = LIFO queue, i.e., put successors at frontfringe LIFO queue, i.e., put successors at front
AA
D F
B C
E GD FE G
![Page 13: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/13.jpg)
Depth‐first searchDepth first search
• Expand deepest unexpanded nodeExpand deepest unexpanded node
• Implementation:– fringe = LIFO queue, i.e., put successors at frontfringe LIFO queue, i.e., put successors at front
AA
D F
B C
E GD FE G
![Page 14: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/14.jpg)
Depth‐first searchDepth first search
• Expand deepest unexpanded nodeExpand deepest unexpanded node
• Implementation:– fringe = LIFO queue, i.e., put successors at frontfringe LIFO queue, i.e., put successors at front
AA
D F
B C
E GD FE G
![Page 15: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/15.jpg)
Depth‐first searchDepth first search
• Expand deepest unexpanded nodeExpand deepest unexpanded node
• Implementation:– fringe = LIFO queue, i.e., put successors at frontfringe LIFO queue, i.e., put successors at front
AA
D F
B C
E GD FE G
![Page 16: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/16.jpg)
Depth‐first searchDepth first search
• Expand deepest unexpanded nodeExpand deepest unexpanded node
• Implementation:– fringe = LIFO queue, i.e., put successors at frontfringe LIFO queue, i.e., put successors at front
AA
D F
B C
E GD FE G
![Page 17: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/17.jpg)
Depth‐first searchDepth first search
• Expand deepest unexpanded nodeExpand deepest unexpanded node
• Implementation:– fringe = LIFO queue, i.e., put successors at frontfringe LIFO queue, i.e., put successors at front
AA
D F
B C
E GD FE G
![Page 18: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/18.jpg)
Depth‐first searchDepth first search
• Expand deepest unexpanded nodeExpand deepest unexpanded node
• Implementation:– fringe = LIFO queue, i.e., put successors at frontfringe LIFO queue, i.e., put successors at front
AA
D F
B C
E GD FE G
![Page 19: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/19.jpg)
Depth‐first searchDepth first search
• Expand deepest unexpanded nodeExpand deepest unexpanded node
• Implementation:– fringe = LIFO queue, i.e., put successors at frontfringe LIFO queue, i.e., put successors at front
AA
D F
B C
E GD FE G
![Page 20: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/20.jpg)
Depth‐first searchDepth first search
• Expand deepest unexpanded nodeExpand deepest unexpanded node
• Implementation:– fringe = LIFO queue, i.e., put successors at frontfringe LIFO queue, i.e., put successors at front
AA
D F
B C
E GD FE G
![Page 21: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/21.jpg)
Properties of depth‐first searchProperties of depth first search
• Complete?pFails in infinite‐depth spaces, spaces with loopsModify to avoid repeated states along path
complete in finite spacescomplete in finite spaces
• Optimal?No – returns the first solution it finds
• Time?Could be the time to reach a solution at maximum depth m: O(bm)Terrible ifm is much larger than dTerrible if m is much larger than dBut if there are lots of solutions, may be much faster than BFS
• Space?O(bm), i.e., linear space!
![Page 22: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/22.jpg)
Iterative deepening searchIterative deepening search
• Use DFS as a subroutineUse DFS as a subroutine1. Check the root
2 Do a DFS searching for a path of length 12. Do a DFS searching for a path of length 1
3. If there is no path of length 1, do a DFS searching for a path of length 2for a path of length 2
4. If there is no path of length 2, do a DFS searching for a path of length 3for a path of length 3…
![Page 23: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/23.jpg)
Iterative deepening searchIterative deepening search
![Page 24: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/24.jpg)
Iterative deepening searchIterative deepening search
![Page 25: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/25.jpg)
Iterative deepening searchIterative deepening search
![Page 26: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/26.jpg)
Iterative deepening searchIterative deepening search
![Page 27: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/27.jpg)
Properties of iterative deepening hsearch
• Complete?Complete?Yes
• Optimal?• Optimal?Yes, if step cost = 1
• Time?(d+1)b0 + d b1 + (d‐1)b2 + … + bd = O(bd)
• Space?O(bd)( )
![Page 28: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/28.jpg)
Informed searchInformed search
• Idea: give the algorithm “hints” about theIdea: give the algorithm hints about the desirability of different states – Use an evaluation function to rank nodes and– Use an evaluation function to rank nodes and select the most promising one for expansion
• Greedy best‐first search
A* h• A* search
![Page 29: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/29.jpg)
Heuristic function
• Heuristic function h(n) estimates the cost of reaching goal from node nreaching goal from node n
• Example:Start state
Goal state
![Page 30: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/30.jpg)
Heuristic for the Romania problemHeuristic for the Romania problem
![Page 31: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/31.jpg)
Greedy best‐first searchGreedy best first search
• Expand the node that has the lowest value ofExpand the node that has the lowest value of the heuristic function h(n)
![Page 32: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/32.jpg)
Greedy best‐first search exampleGreedy best first search example
![Page 33: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/33.jpg)
Greedy best‐first search exampleGreedy best first search example
![Page 34: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/34.jpg)
Greedy best‐first search exampleGreedy best first search example
![Page 35: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/35.jpg)
Greedy best‐first search exampleGreedy best first search example
![Page 36: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/36.jpg)
Properties of greedy best‐first searchProperties of greedy best first search
• Complete?p
No – can get stuck in loops
startgoalgoal
![Page 37: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/37.jpg)
Properties of greedy best‐first searchProperties of greedy best first search
• Complete?p
No – can get stuck in loops
• Optimal?
No
![Page 38: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/38.jpg)
Properties of greedy best‐first searchProperties of greedy best first search
• Complete?p
No – can get stuck in loops
• Optimal?
No
• Time?
( )Worst case: O(bm)
Best case: O(bd) – If h(n) is 100% accurate
• Space?• Space?
Worst case: O(bm)
![Page 39: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/39.jpg)
How can we fix the greedy problem?How can we fix the greedy problem?
![Page 40: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/40.jpg)
A* searchA search
• Idea: avoid expanding paths that are already expensiveIdea: avoid expanding paths that are already expensive
• The evaluation function f(n) is the estimated total cost of the path through node n to the goal:p g g
f(n) = g(n) + h(n)f g
g(n): cost so far to reach n (path cost)
h(n): estimated cost from n to goal (heuristic)
![Page 41: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/41.jpg)
A* search exampleA search example
![Page 42: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/42.jpg)
A* search exampleA search example
![Page 43: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/43.jpg)
A* search exampleA search example
![Page 44: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/44.jpg)
A* search exampleA search example
![Page 45: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/45.jpg)
A* search exampleA search example
![Page 46: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/46.jpg)
A* search exampleA search example
![Page 47: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/47.jpg)
Admissible heuristicsAdmissible heuristics
• A heuristic h(n) is admissible if for every node n, h(n)A heuristic h(n) is admissible if for every node n, h(n)≤ h*(n), where h*(n) is the true cost to reach the goal state from n
• An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic
• Example: straight line distance never overestimates the actual road distance
• Theorem: If h(n) is admissible, A* is optimal
![Page 48: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/48.jpg)
Optimality of A*
n*
n'
• Proof by contradiction
– Let n* be an optimal goal state, i.e., f(n*) = C*
n
Let n be an optimal goal state, i.e., f(n ) C
– Suppose a solution node n with f(n) > C* is about to be expanded
– Let n' be a node in the fringe that is on the path to n*
– We have f(n') = g(n') + h(n') ≤ C*
– But then, n' should be expanded before n – a contradiction
![Page 49: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/49.jpg)
Optimality of A*
n*f(n*) = C*
f( ) *n f(n) > C*
n' g(n') ≥ f(n) > C*
• In other words:
– Suppose A* terminates its search at n*
h f d h h l f( *) ( *) l
n
– It has found a path whose actual cost f(n*) = g(n*) is lower than the estimated cost f(n) of any path going through any fringe nodeg
– Since f(n) is an optimistic estimate, there is no way n can have a successor goal state n’ with g(n’) < C*
![Page 50: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/50.jpg)
Optimality of A*Optimality of A
• A* is optimally efficient – no other tree‐basedA is optimally efficient no other tree based algorithm that uses the same heuristic can expand fewer nodes and still be guaranteed toexpand fewer nodes and still be guaranteed to find the optimal solution– Any algorithm that does not expand all nodes with– Any algorithm that does not expand all nodes with f(n) < C* risks missing the optimal solution
![Page 51: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/51.jpg)
Properties of A*Properties of A
• Complete?p
Yes – unless there are infinitely many nodes with f(n) ≤ C*
• Optimal?
Yes
• Time?
( ) * ( )Number of nodes for which f(n) ≤ C* (exponential)
• Space?
ExponentialExponential
![Page 52: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/52.jpg)
Designing heuristic functions• Heuristics for the 8‐puzzle
h1(n) = number of misplaced tilesh1(n) number of misplaced tiles
h2(n) = total Manhattan distance (number of squares from desired location of each tile)
h1(start) = 8
h2(start) = 3+1+2+2+2+3+3+2 = 18
• Are h1 and h2 admissible?
![Page 53: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/53.jpg)
Heuristics from relaxed problems
• A problem with fewer restrictions on the actions is called a relaxed problemcalled a relaxed problem
• The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problemis an admissible heuristic for the original problem
• If the rules of the 8‐puzzle are relaxed so that a tile can move anywhere, then h1(n) gives the shortest solution
• If the rules are relaxed so that a tile can move to any adjacent square then h (n) gives the shortestadjacent square, then h2(n) gives the shortest solution
![Page 54: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/54.jpg)
DominanceDominance
• If h1 and h2 are both admissible heuristics and1 2 h2(n) ≥ h1(n) for all n, (both admissible) then h2 dominates h1Whi h i b tt f h?• Which one is better for search?
– A* search expands every node with f(n) < C* orh(n) < C* – g(n)( ) g( )
– Therefore, A* search with h1 will expand more nodes
![Page 55: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/55.jpg)
DominanceDominance
• Typical search costs for the 8‐puzzle (average number of yp p ( gnodes expanded for different solution depths):
• d=12 IDS = 3,644,035 nodesA*(h1) = 227 nodes A*(h2) = 73 nodes ( 2)
• d=24 IDS ≈ 54,000,000,000 nodes A*(h1) = 39,135 nodes A*(h2) = 1,641 nodes
![Page 56: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/56.jpg)
Heuristics from subproblemsHeuristics from subproblems
• Let h3(n) be the cost of getting a subset of tiles 3( ) g g(say, 1,2,3,4) into their correct positions
• Can precompute and save the exact solution cost for every ibl b bl i t tt d t bpossible subproblem instance – pattern database
![Page 57: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/57.jpg)
Combining heuristicsCombining heuristics
• Suppose we have a collection of admissible heuristicsSuppose we have a collection of admissible heuristics h1(n), h2(n), …, hm(n), but none of them dominates the others
• How can we combine them?
h(n) = max{h (n) h (n) h (n)}h(n) = max{h1(n), h2(n), …, hm(n)}
![Page 58: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/58.jpg)
Memory‐bounded searchMemory bounded search
• The memory usage of A* can still be exorbitanty g• How to make A* more memory‐efficient while maintaining completeness and optimality?
• Iterative deepening A* search• Recursive best‐first search, SMA*
– Forget some subtrees but remember the best f‐value in these subtrees and regenerate them later if necessarythese subtrees and regenerate them later if necessary
• Problems: memory‐bounded strategies can be y gcomplicated to implement, suffer from “thrashing”
![Page 59: Review: Search problem formulationlazebnik/fall10/lec05_search.pdfReview: Tree search • Initializethe fringe using the starting state • While the fringe is not empty – Choose](https://reader036.fdocuments.us/reader036/viewer/2022070805/5f03ae467e708231d40a3eff/html5/thumbnails/59.jpg)
Comparison of search strategies
Algorithm Complete? Optimal?Time
complexitySpace
complexity
BFS Yes If all step costs are equal
O(bd) O(bd)
UCS
DFS
Yes
No
Yes
No
Number of nodes with g(n) ≤ C*
O(bm) O(bm)DFS
IDS
No
Yes If all step costs are equal
No O(b )
O(bd)
O(bm)
O(bd)
Greedy
costs are equal
No NoWorst case: O(bm)Best case: O(bd)
A* Yes Yes Number of nodes with g(n)+h(n) ≤ C*