150 likes | 250 Views
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 if queue is empty, then return failure node Remove-Front( queue )
E N D
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
*Exponential Growth Time and memory requirements for breadth-first search, assuming a branching factor of10, 100 bytes per node and searching 1000 nodes/second Search
Combinatorial explosion com·bi·na·to·ri·al • 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 statesis easily solved by brute-force search • Fifteen puzzle contains 1013 states and cannot be solved by brute-force techniques on current machines 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 evaluation 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