220 likes | 481 Views
Search in Artificial Intelligence. Find the next move in chess, checkers. Scheduling: finding a good class schedule. Theorem proving: given a set of axioms and inference rules, find a proof of a theorem. Planning: find a sequence of actions to achieve a goal for a robot.
E N D
Search in Artificial Intelligence • Find the next move in chess, checkers. • Scheduling: finding a good class schedule. • Theorem proving: given a set of axioms and inference rules, find a proof of a theorem. • Planning: find a sequence of actions to achieve a goal for a robot. • Natural language understanding: find the best parse of a sentence.
Dimensions of Search Problems • In its general form: find a desired object among a set of objects. • Sometimes, you don’t even know if the object exists or not. • In other cases, the goal is to find the best object. • Blind vs. informed search.
Specifying a search problem? • What are states (nodes in graph)? • What are the operators (arcs between nodes)? • Initial state? • Goal test • Metric (e.g., distance to goal) 7 2 3 1 2 3 4 1 6 4 5 6 E.g., Eight Puzzle 8 5 7 8
Search • Types of Search • Blind • Heuristic & optimization • Adversary Search • Analysis • Completeness • Time complexity • Space Complexity • Guaranteed to find best solution? • Guaranteed to find the closest solution?
Search Strategies • Blind Search • Generate & test • Depth first search • Breadth first search • Iterative deepening search • Iterative broadening search • Heuristic search • Optimizing search
Depth First Search • Maintain stack of nodes to visit • Evaluation • Complete? • Time Complexity? • Space Complexity? Not for infinite spaces a O(b^d) b e O(d) g h c d f
Breadth First Search • Maintain queue of nodes to visit • Evaluation • Complete? • Time Complexity? • Space Complexity? Yes a O(b^d) b c O(b^d) g h d e f
Iterative Deepening Search • DFS with limit; incrementally grow limit • Evaluation • Complete? • Time Complexity? • Space Complexity? Yes a b e O(b^d) c f d i O(d) L g h j k
Search Strategies • Blind Search • Heuristic Search • Best-first • Beam • Hill climbing • Simulated annealing • Optimizing Search
Heuristic Search • A heuristic (metric) is: • Function from a state to a real number • Low number means state is close to goal • High number means state is far from the goal Designing a good heuristic is very important! (And hard) More on this in a bit...
Best First Search • Idea • Breadth first but use priority queue instead of a queue • Evaluation • Complete? • Time Complexity? • Space Complexity? a b e No c f d i O(b^d) L g h j k O(b^d)
Beam Search • Idea • Best first but only keep N best items on priority queue • Evaluation • Complete? • Time Complexity? • Space Complexity? a b e No c f d i O(b^d) L g h j k O(b + N)
Hill Climbing • Idea • Always choose best child; no backtracking • Evaluation • Complete? • Time Complexity? • Space Complexity? a b e No - suffers from plateau, local maxima, ridges c f d i O(b^d) but only in pathological cases L g h j k O(b)
Simulated Annealing • Objective: avoid local minima • Technique: • For the most part use hill climbing • Occasionally take non-optimal step • Reduce probability(non-optimal) over time • Comparison to Hill Climbing • Completeness? • Speed? • Space Complexity? temp
Search Strategies • Blind Search • Heuristic Search • Optimizing Search • A* • IDA* • SMA* Objective is to find the very best solution.
A* Search { Underestimates cost of any solution which can reached from node • Idea • Best first search with admissible heuristic • Plus keep checking until all possibilities look worse • Evaluation • Finds optimal solution? • Time Complexity? • Space Complexity? Yes O(b^d) O(b^d)
7 2 3 4 1 6 8 5 Admissible Heuristics • f(x) = g(x) + h(x) • g: cost so far • h: underestimate of remaining costs e 12 8 d a f 10 8 For eight puzzle? 14 20 b 15 c
7 2 3 4 1 6 8 5 Importance of Heuristics • h1 = number of tiles in wrong place • h2 = sum of distances of tiles from correct loc D IDS A*(h1) A*(h2) 2 10 6 6 4 112 13 12 6 680 20 18 8 6384 39 25 10 47127 93 39 12 364404 227 73 14 3473941 539 113 18 3056 363 24 39135 1641
F=21 F=15 Iterative Deepening A* • Like iterative deepening depth first, but... • Depth bound modified to be an f-cost limit • Contour lines bounding search e d a f b c
SMA* • Problem is f-cost bound increases slowly • Must do iterative search again and again • Storing little state between each iteration • Just one number: next highest contour level • SMA* • Uses all available memory to store state • Duplicates minimal work • Optimal in a number of nice ways
Adversary Search • Game playing: want to make the move for which the opponent cannot respond well. a max b e c min f d i L max g h j k -1 min c c c c 1 f f f f -1 1 1 max g 1 h -1 h g -1 g h -1
Alpha-beta Pruning max a b e min c f d i max L g h j k min c c c c f f f f max