260 likes | 419 Views
Search: Optimal. Artificial Intelligence CMSC 25000 January, 2002. Agenda. Optimal vs Blind vs Heuristic Search Optimal Search All paths: British Museum procedure Branch & Bound Search Dynamic Programming A* search Problem representation Configuration space. Searches.
E N D
Search: Optimal Artificial Intelligence CMSC 25000 January, 2002
Agenda • Optimal vs Blind vs Heuristic Search • Optimal Search • All paths: British Museum procedure • Branch & Bound Search • Dynamic Programming • A* search • Problem representation • Configuration space
Searches • Blind search: Find ANY path to goal • Know nothing: Randomized seach • Know something about search space: • Most paths reach goal or terminate quickly: DFS • Low branching factor, possible long paths: BFS • Heuristic search: Any path, but find faster • Estimate remaining distance to goal • Best from current node: Hill-climbing • Best from any node: Best first • Best w at this depth: Beam search
Optimal Search • Find BEST path to goal • Find best path EFFICIENTLY • Exhaustive search: • Try all paths: return best • Optimal paths with less work: • Expand shortest paths • Expanded shortest expected paths • Eliminate repeated work - dynamic programming
British Museum Procedure • Explore all paths • Return the shortest • Perform DFS or BFS to traverse WHOLE tree • Expensive!!!! • Depth=d; Branching = b: b^d leaf nodes (paths) • Practical only for toy problems
Efficient Optimal Search • Find best path without exploring all paths • Use knowledge about path lengths • Maintain path & path length • Expand shortest paths first • Halt if partial path length > complete path length • Branch & Bound Search
3 A D 4 7 B 8 9 6 D A E C E E B B F 11 13 11 10 10 12 13 B 15 F 14 G D F 14 16 A C 15 15 Branch and Bound Search S
Branch & Bound Algorithm • Form a 1-element queue of 0 cost=root node • Until first path in queue ends at goal or no paths • Remove 1st path from queue; extend path one step • Reject all paths with loops • Add new paths to queue • Sort all paths by length, shortest first • If goal found=>success; else, failure
Branch & Bound + Underestimates • Improve estimate of complete path length • Add (under)estimate of remaining distance • u(total path dist) = d(partial path)+u(remaining) • Underestimates must ultimately yield shortest • Stop if all u(total path dist) > d(complete path) • Straight-line distance => underestimate • Better estimate => Better search • No missteps • Least info : e(remaining) = 0 - plain B&B
A D 13.4 12.9 A E 19.4 12.9 13 B F 17.7 13 G Branch & Bound w/Underestimates S
Branch & Bound w/UnderestimatesAlgorithm • Form a 1-element queue of 0 cost=root node • Until first path in queue ends at goal or no paths • Remove 1st path from queue; extend path one step • Reject all paths with loops • Add new paths to queue • Sort all paths by total length underestimate, shortest first (d(partial path) + u(remaining)) • If goal found=>success; else, failure
Search with Dynamic Programming • Avoid duplicating work • Dynamic Programming principle: • Shortest path from S to G through I is shortest path from S to I plus shortest path from I to G • No need to consider other routes to or from I
A 3 D 4 B 7 D A 9 E 6 8 X X C E 11 12 B F 11 10 X X G 13 Branch & Bound withDynamic Programming S
Branch & Bound withDynamic Programming • Form a 1-element queue of 0 cost=root node • Until first path in queue ends at goal or no paths • Remove 1st path from queue; extend path one step • Reject all paths with loops • For all paths with same terminal node, keep only shortest • Add new paths to queue • Sort all paths by length, shortest first • If goal found=>success; else, failure
Branch & Bound withDynamic Programming • Avoid searching multiple paths through same intermediate node • Significant savings in effort • 12 nodes vs 21 nodes
A* Search Algorithm • Combines good optimal search ideas • Branch & Bound with dynamic programming and underestimates • Form a 1-element queue of 0 cost=root node • Until first path in queue ends at goal or no paths • Remove 1st path from queue; extend path one step • Reject all paths with loops • For all paths with same terminal node, keep only shortest • Add new paths to queue • Sort all paths by total length underestimate, shortest first (d(partial path) + u(remaining)) • If goal found=>success; else, failure
A E 19.4 12.9 13 B F 17.7 13 G A* Search Example S A D 13.4 12.9
Application: Configuration Space • Problem: Robot navigation • Move robot between two objects without changing orientation • Possible? • Complex search space: boundary tests, etc • First step: Problem transformation • Model robot as point • Model obstacles by combining their perimeter + path of robot around it • “Configuration Space”: simpler search
Navigation as Simple Search • Replace funny robot shape in field of funny shaped obstacles with • Point robot in field of configuration shapes • All movement is: • Start to vertex, vertex to vertex, or vertex to goal • Search: Start, vertexes, goal, & connections • A* search yields efficient least cost path
Summary • Optimal search: • Least cost solution with least work • British Museum procedure • Exhaustive search: report best • Branch & Bound: • Rank options by length; stop when partials>complete • Rank options by underestimate of TOTAL length • Dynamic programming: avoid unnecessary work • A*: B&B + Dynamic Programming + Underest
B&B + DynProg Analysis • Algorithm: • Select best partial path from Q • Test for completion • Add path extensions to Q • Assume that we are using an Expanded “list” to implement Dynamic Prog. (implemented as a hash table – constant access time). Assume we have a graph with N nodes and L links. We call a graph where nodes have O(N) links are dense. Graphs where the nodes have a nearly constant number of links are sparse. For dense graphs L is O(N2). O(N) Paths taken from Q ? O(N) Cost of picking path from Q (& cleanup), using linear scan? O(L) Attempts to add path to Q (many are rejected)? O(1) Cost of adding path extension to front of Q ? O(N2 + L) Total cost ? Lozano-perez, 2000
Search Method Worst Time (Dense) Worst Time (Sparse) Worst Space Guaranteed to find shortest path Branch & Bound A* O(N2) O(N log N) O(N) Yes Cost and Performance Searching a tree with N nodes and L links Searching a tree with branching factor b and depth d L = N= b d+1 Worst case time is proportional to number of nodes visited Worst case space is proportional to maximal length of Q (and Expanded) lozano-perez, 2000