Presentation is loading. Please wait.

Presentation is loading. Please wait.

Searching for Solutions

Similar presentations


Presentation on theme: "Searching for Solutions"— Presentation transcript:

1 Searching for Solutions
Artificial Intelligence CMSC 25000 January 17, 2008

2 Agenda Search – Review Heuristic search: Efficient, optimal search:
Problem-solving agents Rigorous problem definitions Heuristic search: Hill-climbing, beam, best-first search Efficient, optimal search: A*, admissible heuristics Search analysis Computational cost, limitations

3 Problem-Solving Agents
Goal-based agents Identify goal, sequence of actions that satisfy Goal: set of satisfying world states Precise specification of what to achieve Problem formulation: Identify states and actions to consider in achieving goal Given a set of actions, consider sequence of actions leading to a state with some value Search: Process of looking for sequence Problem -> action sequence solution

4 Formal Problem Definitions
Key components: Initial state: E.g. First location Available actions: Successor function: reachable states Goal test: Conditions for goal satisfaction Path cost: Cost of sequence from initial state to reachable state Solution: Path from initial state to goal Optimal if lowest cost

5 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 10.4 B C 6.7 4.0 S 11.0 G 3.0 8.9 6.9 D E F

6 Hill-climbing Search Select child to expand that is closest to goal S
8.9 A D 10.4 6.9 10.4 E A B 3.0 F 6.7 G

7 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

8 Beam Search Breadth-first search of fixed width - top w
Guarantees limited branching factor, E.g. w=2 S A D 10.4 8.9 B D A E 6.7 8.9 10.4 6.9 C E B F 4.0 6.9 6.7 3 A C G

9 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

10 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

11 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!!

12 Optimal Search Find BEST path to goal Exhaustive search:
Find best path EFFICIENTLY Exhaustive search: Try all paths: return best Optimal paths with less work: Expand shortest paths Expand shortest expected paths Eliminate repeated work - dynamic programming

13 Efficient Optimal Search
Find best path without exploring all paths Use knowledge about path lengths Maintain path & path length Expand shortest paths first Halt if partial path length > complete path length

14 Underestimates Improve estimate of complete path length
Add (under)estimate of remaining distance f(total path) = g(partial path)+h(remaining) Underestimates must ultimately yield shortest Stop if all f(total path) > g(complete path) Straight-line distance => underestimate Better estimate => Better search No missteps

15 Search with Dynamic Programming
Avoid duplicating work Dynamic Programming principle: Shortest path from S to G through I is shortest path from S to I plus shortest path from I to G No need to consider other routes to or from I

16 Optimality of A* (proof)
Suppose some suboptimal goal G2 has been generated and is in the fringe. Let n be an unexpanded node in the fringe such that n is on a shortest path to an optimal goal G. f(G2) = g(G2) since h(G2) = 0 g(G2) > g(G) since G2 is suboptimal f(G) = g(G) since h(G) = 0 f(G2) > f(G) from above

17 Optimality of A* (proof)
Suppose some suboptimal goal G2 has been generated and is in the fringe. Let n be an unexpanded node in the fringe such that n is on a shortest path to an optimal goal G. f(G2) > f(G) from above h(n) ≤ h*(n) since h is admissible g(n) + h(n) ≤ g(n) + h*(n) f(n) ≤ f(G) Hence f(G2) > f(n), and A* will never select G2 for expansion

18 Consistent heuristics
A heuristic is consistent if for every node n, every successor n' of n generated by any action a, h(n) ≤ c(n,a,n') + h(n') If h is consistent, we have f(n') = g(n') + h(n') = g(n) + c(n,a,n') + h(n') ≥ g(n) + h(n) = f(n) i.e., f(n) is non-decreasing along any path. Theorem: If h(n) is consistent, A* using GRAPH-SEARCH is optimal

19 A* Search Algorithm Combines good optimal search ideas
Dynamic programming and underestimates 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 For all paths with same terminal node, keep only shortest Add new paths to queue Sort all paths by total length underestimate, shortest first (g(partial path) + h(remaining)) If goal found=>success; else, failure

20

21

22

23

24 A* Search Example S A D 13.4 12.9 A E 19.4 12.9 B F 17.7 13 G 13

25 Heuristics A* search: only as good as the heuristic
Heuristic requirements: Admissible: UNDERESTIMATE true remaining cost to goal Consistent: h(n) <= c(n,a,n') + h(n')

26 Constructing Heuristics
Relaxation: State problem Remove one or more constraints What is the cost then? Example: 8-square: Move A to B if 1) A &B horizontally or vertically adjacent, and 2) B is empty Ignore 1) -> Manhattan distance Ignore 1) & 2): # of misplaced squares


Download ppt "Searching for Solutions"

Similar presentations


Ads by Google