1 CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupar t CSC384: Lecture 10 Last time • A* Today • complete A*, iterative deepening Announcements: • Assignment Solution will be posted later on today. • This Friday’s office hours will be moved to Thursday 10:00-12:00 Pratt 398 (my office).
25
Embed
1 CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart CSC384: Lecture 10 Last time A* Today complete A*, iterative deepening Announcements:
3 CSC 384 Lecture Slides (c) , C. Boutilier and P. Poupart Properties of A* Recap—Optimality Will A* always find cheapest path? If h(n) does not underestimate the true cost of getting to the goal then A* won’t always find the cheapest path.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
CSC384: Lecture 10Last time
• A* Today
• complete A*, iterative deepeningAnnouncements:
• Assignment Solution will be posted later on today.• This Friday’s office hours will be moved to Thursday 10:00-
12:00 Pratt 398 (my office).
2CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Midterm. Will cover all material up to the end of Iterative
deepening (which we will finish today or perhaps next time).1. DCL, semantics, interpretations, no questions on
counting number of interpretations!2. Top down, bottom up proofs.3. Search, DFD, BrFS, LCFS, A*, ID search
3CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Properties of A* Recap—Optimality
Will A* always find cheapest path?If h(n) does not underestimate the true cost of getting to the goal then A* won’t always find the cheapest path.
4CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Paths Explored by A*: mo to slbmo
alls
ws
ch2 5
2
12/2
3/5
3/4
1/6
Red paths: expanded; h-value/f-valueBlack paths: added to frontier, but not expanded
sec
2ls
1eif
1
0/8
slb rp1
1
1ase bp nyse31
Prune using MPC(to keep slide simple)
Goal
2/4
5CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Paths Explored by A*: mo to slbmo
alls
ws
ch2 5
2
12/2
17/5
3/4
2/4
1/6
Red paths: expanded; h-value/f-valueBlack paths: added to frontier, but not expanded
sec
ls
eif
0/10
slb rp1
1
1ase bp nyse31
GoalCheapestGoal
2
6CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Admissible HeuristicsIf h(n) never overestimates the true cost-to-goal from n
(h(n) ≤ mincost(n,g)) then h is called admissible and the following holds.
• A* will find least-cost path (assuming arcs costs > 0)Special case: let h(n) = 0 for all n
• since f(n) = h(n) + g(n) = g(n): reduces to LCFS• an admissible, but uninformative heuristic
In general, the more “informative” h(n) is, the better A* will perform (more “direct” search)
• Exercise: Prove that if h(n) = mincost(n,g) – that is, h(n) is perfect – A* can find optimal path directly (no backtracking). However we must be careful that we don’t alternate between a large number of distinct optimal paths.
7CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Optimality of A* (Proof)Let h be admissible, and let their exist a path to the goal. Then A* terminates only when it expands a goal node to which it has found an optimal path.
• First, at any time prior to A* terminating the frontier contains a prefix of an optimal path s=n0,n1,…,n* (a goal node): s=n0,n1,…nk
At the start s=n0 is on the frontier (k=0)If at some stage n0,n1,…nk is on the frontier, then at the next step either nk was not expanded, in which case this path is still on the frontier, or nk was expanded in which case one of nk’s neighbors must be nk+1. That is, now the prefix s=n0,n1,…nk,nk+1 is on the frontier.
8CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Optimality of A* (Proof)Second, for any node ni on this optimal path we must have f(ni) ≤ cost of an optimal solution.
f(ni) = g(ni) + h(ni).
• g(ni) = optimal cost of getting to ni since the path n0,…,ni-1,ni must be an optimal path to ni (it is a prefix of an optimal path to the goal).
• h(ni) ≤ cost of getting to the goal from ni.
9CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Optimality of A* (Proof)Hence any node expanded by A* must have f-value ≤ cost of an optimal solution, else A* would have chosen nk instead!
• Thus when A* terminates by expanding a goal node, ng it must be the case that f(ng) ≤ cost of an optimal solution. But since f(ng) = g(ng) + h(ng) = g(ng) + 0, and g(ng) is the cost of a solution (the one to ng), we must have f(ng) = g(ng) ≤ cost of an optimal solution.
That is, g(ng) = cost of an optimal solution, and A* terminates by finding an optimal solution.
10CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Optimality of A*
s n1* n2* n3* x
s n1 n2 n3 x
p*
p
nodes on optimal path to goal havef-values bounded by optimal solution cost
eventually f-values of nodes on non-optimalpath must exceed optimal solution cost
11CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Multiple Path Checking in A*MPC: If you find a path to node n that you’ve already expanded, don’t expand it again
• was OK for BFS and LCFS, since first path expanded to any node n was assured to be shortest/cheapest
• In A*, you can be misled by heuristic that takes you all the way to node n along an “expensive path” (though it can’t take you all the way to goal if admissible)
s n’ n xp*(n)
p(n)c(p*) < c(p), but f(p*) > f(p)
12CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Multiple Path Checking in A*
In example, p expanded before p*, and MPC ignores cheaper path p* to node n
• MPC can destroy optimality of A*But this can only happen if:
• some n’ on p* is on frontier, with fp*(n’) > fp(n)But gp*(n’) + dist(n’,n) < gp(n) fp*(n’) = gp*(n’) + h(n’) > gp(n) + h(n) = fp(n)
18CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
What Price do We Pay? Intuitively, most of the time is spend searching the last level. So
multiple searches of the previous levels does not matter much.For branching factor b, a tree with d levels will have nodes
of which bd are at level d.
So the proportion of nodes in the whole tree that are level d is
I.e., for b = 2, about 1/2 of the nodes are at the last level. for b = 3, about 2/3 of the nodes are at the last level. for b = 4, about 3/4 of the nodes are at the last level.
Hence, iterative deeping is worst for binary trees and gets better as the branching factor increases.
111
bbd
bbbb
bbb
d
dd
d
d 1111
)1(1
1
1
19CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Benefit of IDS We pay a time overhead (compared to BFS) for
exponential space savings!More analysis can show that the overhead factor for IDS
vs BFS is about b/(b-1)• if b = 2, overhead factor is about 2 (2 times as long as BFS)• if b = 4, overhead factor is 4/3 = 1.3• overhead factor decreases with b!
Iterative Deepening can be used with A*: IDA*• basically, do DFS, but let “depth bound” be maximum f-value
you consider, and increase f-value-bound gradually (there are subtle issues wrt how fast one can increase the f-bound and retain optimality).
Also analysis is wrt search trees. If graph has many multiple paths and BrFS does MPC, IDS can behave much worse in comparison.
20CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Implicit Search GraphsMost search problems are not specified with explicit search graphs; nbr predicate “creates” neighboring states on the fly
• Each board position a state• 9! = 362880 states• each state has 2, 3, or 4 nbrs• nbrs correspond to possible moves• nbr predicate: returns list of states reachable
State Representation? Neighbor implementation? Possible Heuristics?
1 2 3
54
7 68
21CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Other Issues
Suppose list of neighbors is too large:• to add to frontier? to calculate all heuristic values?• What might one do? How could you use heuristic info
to limit your attention?• One possibility: generate neighbors in heuristic order
(only a subset of nbrs ever put on frontier)• can destroy optimality unless more nbrs added when
backtrackingOther things we can do to increase efficiency?
• control the direction of search
22CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Backward Search
Backward branching factor is the (avg) set of moves that can be made to a specific node
• if I have the inverse nbr relation available, I can search in the graph backwards from the goal to the start state
Advantage: if backward BF b- less than forward BF b+, then search algth’m (any type) benefits
• lower time and space complexity since optimal path length still the same
• however, heuristic methods need a backwards heuristic
23CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Bidirectional SearchSearch simultaneously in both directions
• if two frontiers intersect, you can “join” forward and backward paths to node in intersection to get a sol’n
• contrast # expansions for b-d BrFS vs. normal BrFS
s
g g
s
24CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Bidirectional Search
Suppose we do BrFS• length of sol’n (shortest path) is k• branching factor (frwd/bkwd) is b
Each component of the bidirectional search expands O(bk/2) nodes
Normal BrFS expands O(bk) nodesBidirectional is exponential, but offers exponential savings
Issues: need bkwd dynamics, need to test intersection, must choose search alg. carefully
25CSC 384 Lecture Slides (c) 2002-2003, C. Boutilier and P. Poupart
Island Search
Suppose you know that any (good) path to goal must pass through island states i1, i2, … ik
• e.g., must pass through specific tunnels to deliver pkg
Complexity can be cut significantly by searching for path from s to i1, i1 to i2, …, ik-1 to ik, ik to g
• what is potential savings (say) for BrFS using this strategy if avg subpath between islands has length m?