650 likes | 1.84k Views
Uniform-Cost Search. Edges have different costs Instead of expanding nodes in order of their depth from root expand in order of cost from root At each step, expand a node whose cost g(n) is lowest where g(n) is sum of costs of edges from root to node n Nodes are stored in a priority queue
E N D
Uniform-Cost Search • Edges have different costs • Instead of expanding nodes in order of their depth from root expand in order of cost from root • At each step, expand a node whose cost g(n) is lowest where g(n) is sum of costs of edges from root to node n • Nodes are stored in a priority queue • Worst case time complexity: • O (bc/m)where c is the cost of an optimal solution and m is the minimum edge cost Problem: Memory- similar to breadth first Search
A Z75T118S140 T118S140O146 S140O146L229 O146L229R230 F239O291 L229R230F239O291 R230 F239O291M299 Search
Depth-First Search • Remedies space limitation of breadth first by always generating a child of the deepest unexpanded node. Search
Implementation • Maintain a list of unexpanded nodes treated as a LIFO stack (as opposed to FIFO for breadth first) • Usually implemented recursively- with the recursion stack taking the place of an explicit node stack • Time complexity is O (bd)-Practically DF is time limited and BF is space limited • Disadvantage: does not terminate if tree infinite or cycles in graph • Solution: cutoff depth (d) • d small? • d large? Search
Depth First Iterative Deepening Combines best features of DF and BF Successive depth-first searches are conducted – each with depth bounds increasing by 1 Performs a depth first to depth 1 then starts over executing a complete depth first to depth 2 and continues to run depth first searches to successive greater depths until a solution is found. Search Optimal in terms of time and space (O(bd))among all brute force algorithms on a tree.
Iterative Deepening Search • Complete? Yes • Optimal? Yes, if step cost = 1 Search
Bidirectional Search • Requires an explicit goal state • Simultaneously search forward from initial state and backwards from the goal state until the two meet • Concatenate the path from initial state to the inverse of the path from the goal state to form a complete solution • Use two queues to implement- for the halves Guarantees optimal solution Time complexity is O (bd/2) since the search only proceeds to half solution depth. Space complexity is also O (bd/2)as at least one of the searches has to be breadth first to find a common state Search
Exponential Growth Time and memory requirements for breadth-first search, assuming a branching factor of 10, 100 bytes per node and searching 1000 nodes/second Search
Combinatorial explosion • The problem with brute–force search algorithms is that their time complexity grows with problem size- combinatorial explosion • The size of the problems that can be solved with these methods is limited • Eight puzzle with 105 is easily solved by brute- force search • Fifteen puzzle contains 1013 states and cannot be solved by brute-force techniques on current machines Search
Implementation of Search Algorithms Function GENERAL-SEARCH (problem, queing-fn) returns a solution or failure queue MAKE-QUEUE (MAKE-NODE(INITIAL-STATE[problem])) loop do ifqueueis empty, then return failure node Remove-Front(queue) if GOAL-TEST [problem] applied to STATE(node) succeeds then return node else queueQUEING-FN(queue,EXPAND(node,operators[problem])) end Search
Heuristic Search To solve larger problems we need to add domain specific knowledge to improve efficiency Heuristic General: Any advice that is often effective but not guaranteed to work in every case. Heuristics are only approximately correct. Their purpose is to minimize search on average. Technical AI: Heuristic evaluation function used- h(n) cost estimate from node n to goal In a single agent path finding problem a heuristic function estimates the cost of an optimal path between a pair of states- example: Euclidean or airline distance is an estimate of distance between two cities. In the tiles problem it may be the number of moves needed to put a tile in its goal position Properties of valuation function: gives an estimate not actual cost inexpensive to compute more natural to be a lower bound on actual cost- referred to as admissibility- guarantees finding the optimal solution first, Monotonicity along the path from root the cost never decreases Search
estimate of total cost along path through n estimate of cost to reach goal from n actual cost to reach n Best-First Search When nodes are ordered so that the one with the best evaluation is expanded first the resulting search strategy is called best first search. • An algorithm is a best-first search algorithm if it aims at minimizing the total cost of a path from start to goal. f(n) = g(n) + h(n) Search
estimate of cost to reach goal from n- straight line distance to a city actual (unknown) cost to reach goal from n- highway distance • A heuristic is (globally) optimistic or admissible if the estimated cost of reaching a goal is always less than the actual cost. h(n) ≤ h*(n) • A heuristic is monotonic(locally optimistic) if the estimated cost of reaching any node is always less than the actual cost. h(n1)–h(n2)≤ h*(n1)–h*(n2) Search
8-puzzle: Manhattan distance • Sydney to Melb.: straight-line distance • Chess: Weighted sum of chessmen values Search
Greedy best-first search • Evaluation function f(n) = h(n)(heuristic) = estimate of cost from n to goal • hSLD(n)= straight-line distance from n to goal • Greedy best-first search expands the node thatappearsto be closest to goal Search
Greedy best-first search Search
Greedy best-first search Search
Greedy best-first search Search
Greedy best-first search Search
greedy best-first search • Complete?No – loops • Time?O(bm)- a good heuristic can make great improvement • Space?O(bm)- keeps all nodes in memory • Optimal? No Search