Search Techniques CS480/580 Fall 2009
Introduction Trees: – Root, parent, child, sibling, leaf node, node, edge – Single path from root to any node Graphs: – Nodes, edges, directed/undirected graph, acyclic graph
Search techniques for Trees Exhaustive search – Breadth-first search: Use a queue to implement Search nodes each level at a time – Depth-first search: Use a stack to implement Search nodes path at a time
Searching Graph Apply the same two techniques But to eliminate infinite looping, mark a node when it is already visited. This way it won’t be explored repeatedly.
Heuristic Search When the search space is very large (millions of nodes), it is not feasible to search the entire space; Instead we use a heuristic search that directs the search based on some heuristics – Evaluation function to rank the nodes to determine the order of search---which is most likely to succeed
Heuristic 1: Hill Climbing First decide on an evaluation function for each node---this depends on the specific application – E.g., In airline routing, if the task is to find a route that can take a passenger from airport X to airport Y, there could be several possible sequence of hops that need to be considered. – Suppose there is no direct path from X-Y, but there are 4 hubs H1, H2, H3, H4, that X has flights to, then we need to determine which is the next hub we want to explore. We need a basis for the decision. – Suppose we consider the distance between X and a hub as the evaluation function so the further a hub takes a passenger away from X, then the closer it is to the destination Y. So evaluation criteria is: choose an alternate that is farthest from X. – This may or may not always result in optimal solution. – Local maxima, local minima---problems – Look at the airline routing in the above reference
Best First Search Similar to BFS and DFS, it is exhaustive. The difference is that the next node to search is based on an evaluation function---in other words whenever we need to choose the next node to search pick the one with the best node value Calls for a priority queue instead of a stack or a FCFS queue Refer to Fig. 4.8 – Discussion in class
Least-cost search Always choose the one that costs less in the next step---that is we always choose the node that can be reached with minimal cost from the current location. For example
A* Algorithm Variant of best first search Assumes: Estimated cost < Actual cost Admissible heuristic function: h(n) ≤ h * (n) where h * (n) is the true cost to the nearest goal.---never overestimate costs Guarantees optimal solution provided admissible heuristics is used ---minimum cost solution --- distance is a cost, travel time is a cost, etc. Here, evaluation function has two parts: cost of getting from start to the Current node; cost of going from current node to goal node or target node. f(Node) = g(Node) + h(Node) Refer to the following slidesslides
Using Search Techniques in problem Solving Puzzle solving, planning, routing, etc. In the case of a board puzzle, each node represents current state of the puzzle; goal node represents the desired board position