Upload
maryann-short
View
245
Download
3
Embed Size (px)
Citation preview
ICS-171:Notes 4: 1
Notes 4: Optimal Search
ICS 171 Summer 1999
ICS-171:Notes 4: 2
Summary
• Optimal search strategies
– path costs
• examples
– now we want to search for the minimum cost path to goal G
– optimality
– exhaustive search
– uniform-cost search
ICS-171:Notes 4: 3
Searching for the Minimum Cost Path
• Previously we only cared about finding a path to any goal G
• Now we want the minimum cost path to a goal G
– Cost of a path = sum of individual transitions along path
– “best” = minimum cost path
– Note: 2 different types of cost
• 1. cost of traversing the path to goal (“path-cost”/online cost)
– cost from start S to node
– cost from node to goal G
• 2.. the space and time complexity of the search algorithm (“search-cost”/offline cost)
– Path-cost = sum of individual node-to-node costs
• individual costs assumed positive
– otherwise an algorithm could “cycle” forever adding loops
ICS-171:Notes 4: 4
Examples of Path-Cost
• Navigation
– path-cost = distance to node in miles OR the time to travel on foot or by car OR number of cities visited - ALL DIFFERENT
• minimum => minimum time, least fuel
• VLSI Design
– path-cost = length of wires between chips
• minimum => least clock/signal delay
• 8-Puzzle
– path-cost = number of pieces moved
• minimum => least time to solve the puzzle
ICS-171:Notes 4: 5
Example of Path Costs
S G
A B
D E
C
F
2
1
2
5
4
2 43
5
Optimal (minimum cost) path is S-A-D-E-F-G
ICS-171:Notes 4: 6
Completeness and Optimality
• A search procedure is complete if
– it is guaranteed to find a goal state, if one exists
• e.g., DFS is not complete in general (if repeated states exist)
• but BFS is complete
• A search procedure is optimal if
– it is guaranteed to find the minimum cost path, if multiple paths to a goal state exist
• e.g., DFS and BFS are not optimal
Note that optimal => complete, but not vice-versa
ICS-171:Notes 4: 7
Search Method 6: Exhaustive Search
• Basic idea
– find all possible paths to goal states
– choose the best one (best = minimum path-cost)
• For example,
– use BFS, modified so that it continues until all goal states are found
• but BFS scales as O(b d)!
• Conclusion
– it is certainly complete and optimal
– but exhaustive search is impractical except for very small problems
ICS-171:Notes 4: 8
The Shortest Path Principle
• We are searching for the minimum cost path to GSuppose the minimum (optimal) path to a goal state G has cost c
• Shortest Path Principle:
– we can ignore any open nodes in the search tree which have path-costs greater than or equal to c
• why ?
• because we already have a solution with path-cost c, and expanding these nodes can only increase their costs further
– but, we must still explore all other open nodes with path-cost <c
• why?
• they could produce a path to goal with path-cost < c
• We can do this simply by ordering nodes in Q according to path-cost to each node
ICS-171:Notes 4: 9
Search Method 7: Uniform Cost Search
Initialize: Let Q = {S}While Q is not empty
pull Q1, the first element in Qif Q1 is a goal report(success) and quitelse
child_nodes = expand(Q1)<eliminate child_nodes which represent loops>put remaining child_nodes in Qsort Q according to path-cost to each node
end Continue
•Uniform Cost Search
•orders the nodes on the Q according to path cost from S
•always expands the node with minimum path cost from S
ICS-171:Notes 4: 10
Example of Uniform Cost in action
S
A D2 5
ICS-171:Notes 4: 11
Example of Uniform Cost in action
S
A D
BD
C E
E
B F
G
2 5
3
8
4
6
11 10
13
7
D 10 F14
E
B F
G
7
12 11
14
14
C 15
ICS-171:Notes 4: 12
Properties of Uniform Cost Search
• Complete?
– yes
• Optimal?
– assume that all costs are greater than 0
– when we go to expand a node, we test for goal state
• if it is a goal state then, it is selected (say with path cost c)
• if selected, is this path the lowest cost path to a goal?
– all other currently open paths have higher cost (by definition)
– since all costs >0, all of them must have path costs >c (to goal)
– => the selected path is the optimal one
– this is basically Dijkstra’s algorithm (ICS 161) applied to search trees
• Complexity?
– worst O(b^d) in both space and time
– in practice, run out of space usually before you run out of time
ICS-171:Notes 4: 13
Summary
• Path Cost– in practice we often want the best path to a goal state, e.g., the
minimum cost path
• Optimality– a search algorithm which is guaranteed to find the best path to goal
• Uniform Cost Search– this is optimal – but it can have exponential complexity (especially memory) in practice
• Reading: Chapter 3, page 70 to 82
• All of the search techniques so far are “blind” in that they do not look at how far away the goal may be: next we will look at informed or heuristic search, which directly tries to minimize the distance to the goal.