220 likes | 241 Views
Search: Basic and Heuristic. Artificial Intelligence CMSC 25000 January 15, 2002. Agenda. Search - Motivation Blind exhaustive search: Depth-first search Breadth-first search Heuristic search: Hill-climbing Best-first Beam search. Why Search?. Not just city route search
E N D
Search: Basic and Heuristic Artificial Intelligence CMSC 25000 January 15, 2002
Agenda • Search - Motivation • Blind exhaustive search: • Depth-first search • Breadth-first search • Heuristic search: • Hill-climbing • Best-first • Beam search
Why Search? • Not just city route search • Many AI problems can be posed as search • Planning: • Vertices: World states; Edges: Actions • Game-playing: • Vertices: Board configurations; Edges: Moves • Speech Recognition: • Vertices: Phonemes; Edges: Phone transitions
Basic Search Algorithm • Form a 1-element queue of 0 cost=root node • Until first path in queue ends at goal or no paths • Remove 1st path from queue; extend path one step • Reject all paths with loops • Add new paths to queue • If goal found=>success; else, failure Paths to extend Order of paths added Position new paths added
Basic Search Problem • Vertices: Cities; Edges: Steps to next, distance • Find route from S(tart) to G(oal) 4 4 A B C 3 S 5 G 4 3 2 4 D E F
Blind Search • Need SOME route from S to G • Assume no information known • Depth-first search, breadth-first search • Convert search problem to search tree • Root=Zero length path at Start • Node=Path: label by terminal node • Child one-step extension of parent path
Search Tree S A D B D A E E B B F C E D F B F D E A C G G C G F G
Depth-first Search • Pick a child of each node visited, go forward • Ignore alternatives until exhaust path w/o goal S A B C E F D G
Depth-first Search Algorithm • Form a 1-element queue of 0 cost=root node • Until first path in queue ends at goal or no paths • Remove 1st path from queue; extend path one step • Reject all paths with loops • Add new paths to FRONT of queue • If goal found=>success; else, failure
Breadth-first Search • Explore all paths to a given depth S D A A E B D B B F C E E D F B F D E A C G
Breadth-first Search Algorithm • Form a 1-element queue of 0 cost=root node • Until first path in queue ends at goal or no paths • Remove 1st path from queue; extend path one step • Reject all paths with loops • Add new paths to BACK of queue • If goal found=>success; else, failure
Search Issues • Branching factor: • Number of children per node • # nodes: depth=d; branching=b: b^d!! • Depth-first search: • Good if: most partial=>complete, not too long • Bad if many (effectively) infinite paths • Breadth-first search: • Good if many (effectively) infinite paths, b<< • Bad if many end at same short depth, b>>
Randomized Search • If REALLY know nothing… • Form a 1-element queue of 0 cost=root node • Until first path in queue ends at goal or no paths • Remove 1st path from queue; extend path one step • Reject all paths with loops • Add new paths to RANDOM parts of queue • If goal found=>success; else, failure
Heuristic Search • A little knowledge is a powerful thing • Order choices to explore better options first • More knowledge => less search • Better search alg?? Better search space • Measure of remaining cost to goal-heuristic • E.g. actual distance => straight-line distance A B C 10.4 6.7 4.0 11.0 S G 3.0 8.9 6.9 D E F
Hill-climbing Search • Select child to expand that is closest to goal S 8.9 A D 10.4 6.9 E 10.4 A B F 3.0 6.7 G
Hill-climbing Search Algorithm • Form a 1-element queue of 0 cost=root node • Until first path in queue ends at goal or no paths • Remove 1st path from queue; extend path one step • Reject all paths with loops • Sort new paths by estimated distance to goal • Add new paths to FRONT of queue • If goal found=>success; else, failure
S 10.4 8.9 D A 8.9 10.4 6.9 6.7 A E B D 6.7 3 4.0 6.9 B F C E A C G Beam Search • Breadth-first search of fixed width - top w • Guarantees limited branching factor, E.g. w=2
Beam Search Algorithm • Form a 1-element queue of 0 cost=root node • Until first path in queue ends at goal or no paths • Extend all paths one step • Reject all paths with loops • Sort all paths in queue by estimated distance to goal • Put top w in queue • If goal found=>success; else, failure
Best-first Search • Expand best open node ANYWHERE in tree • Form a 1-element queue of 0 cost=root node • Until first path in queue ends at goal or no paths • Remove 1st path from queue; extend path one step • Reject all paths with loops • Put in queue • Sort all paths by estimated distance to goal • If goal found=>success; else, failure
Heuristic Search Issues • Parameter-oriented hill climbing • Make one step adjustments to all parameters • E.g. tuning brightness, contrast, r, g, b on TV • Test effect on performance measure • Problems: • Foothill problem: aka local maximum • All one-step changes - worse!, but not global max • Plateau problem: one-step changes, no FOM + • Ridge problem: all one-steps down, but not even local max • Solution (local max): Randomize!!
Summary • Blind search: • Find some path to goal • Depth-first, Breadth-first, Randomized • Heuristically guided search • Use knowledge to find goal FASTER • Hill-climbing • Foothill, plateau, and ridge problems • Randomization escapes local maxima • Beam-search: Bounding branching • Best-first