Presentation is loading. Please wait.

Presentation is loading. Please wait.

Problem Solving by Searching

Similar presentations


Presentation on theme: "Problem Solving by Searching"— Presentation transcript:

1 Problem Solving by Searching
CSC361 AI CSC361: Problem Solving & Search

2 Search Strategies: Classification
Search Strategies can be Uninformed Search Strategy Informed Search Strategy Uninformed search strategies use only the information available in the problem definition. Informed search strategies use other domain specific information. AI CSC361: Problem Solving & Search

3 Informed Search Strategies
Informed search strategies employ problem specific knowledge to make a choice of which node to select next.  This knowledge is formulated in the form of a function f(x). Best-first search Uniform Cost Search Greedy best-first search A* search AO* AI CSC361: Problem Solving & Search

4 AI CSC361: Problem Solving & Search
Best First Search Idea: Select the best node to goal check and expand. Which is the best node?  An evaluation function f(n) tell us which node is the best. The value returned by f(n) gives an estimate of the ‘desirability’ of node n. Or its closeness to the goal state. So the nodes in the Open List are ordered according to the values returned by f(n) and first node selected. AI CSC361: Problem Solving & Search

5 AI CSC361: Problem Solving & Search
Best First Search: UCS Example of Best First Search: Uniform Cost Search, Greedy Search, A*. UCS: its evaluation function is the total path cost incurred up to a node n. f(n) = g(n) = cost from start state to n. Drawback: g(n) does not direct search towards the goal, because it considers the cost incurred in the past not the cost that will be incurred in the future. AI CSC361: Problem Solving & Search

6 AI CSC361: Problem Solving & Search

7 Best First Search: Greedy Search
Evaluation function f(n) = h(n) (a heuristic function) h(n) gives estimate of cost from n to goal e.g., hSLD(n) = straight-line distance from n to Bucharest Greedy search expands the node that appears to be closest to the goal AI CSC361: Problem Solving & Search

8 AI CSC361: Problem Solving & Search
ARAD SIBIU TIMSOURA ZIRIND 253 329 374 ARAD 366 AI CSC361: Problem Solving & Search

9 AI CSC361: Problem Solving & Search

10 AI CSC361: Problem Solving & Search
Greedy Search Complete? No – can get stuck in loops, e.g., Iasi  Neamt  Iasi  Neamt  Time? O(bm), but a good heuristic can give dramatic improvement Space? O(bm) -- keeps all nodes in memory Optimal? No AI CSC361: Problem Solving & Search

11 AI CSC361: Problem Solving & Search
A* Search Idea: Considers cost to reach node n from start state and cost to reach goal from n. Evaluation function f(n) = g(n) + h(n) g(n) = cost so far to reach n h(n) = estimated cost from n to goal f(n) = estimated total cost of path through n to goal AI CSC361: Problem Solving & Search

12 AI CSC361: Problem Solving & Search
2 3 4 AI CSC361: Problem Solving & Search

13 AI CSC361: Problem Solving & Search
5 6 AI CSC361: Problem Solving & Search

14 AI CSC361: Problem Solving & Search
A* Search Complete? Yes Time? O(bd) .. Exponential Space? Keeps all nodes in memory Optimal? Yes  provided that h(n) is admissible and consistent. AI CSC361: Problem Solving & Search

15 AI CSC361: Problem Solving & Search
Admissible Heuristic A heuristic h(n) is admissible if for every node n, h(n) ≤ h*(n), where h*(n) is the true cost to reach the goal state from n. An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic Example: hSLD(n) (never overestimates the actual road distance) Theorem: If h(n) is admissible, A* using TREE-SEARCH is optimal AI CSC361: Problem Solving & Search

16 AI CSC361: Problem Solving & Search
Admissible Heuristic For the 8-puzzle: h1(n) = No. of misplaced tiles  h1(S)= 8 h2(n) = sum of distances of tiles from their goal position  h2(S) = = 18 AI CSC361: Problem Solving & Search

17 AI CSC361: Problem Solving & Search
Consistent Heuristic 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) f(n) is non-decreasing along any path Theorem: If h(n) is consistent, A* using GRAPH-SEARCH is optimal AI CSC361: Problem Solving & Search

18 AI CSC361: Problem Solving & Search
Dominance If h2(n) ≥ h1(n) for all n (both admissible) then h2 dominates h1 h2 is better for search Typical search costs (average number of nodes expanded): d=12 IDS = 3,644,035 nodes A*(h1) = 227 nodes A*(h2) = 73 nodes d=24 IDS = too many nodes A*(h1) = 39,135 nodes A*(h2) = 1,641 nodes AI CSC361: Problem Solving & Search

19 AI CSC361: Problem Solving & Search
AND-OR Search Graphs OR Graphs: The state-space graphs dealt with previously were OR graphs; from any state one-of the applicable actions is chosen to reach the goal. STATE 1 OR Node AI CSC361: Problem Solving & Search

20 AI CSC361: Problem Solving & Search
AND-OR Search Graphs AND-OR Graphs: In AND-OR graphs, from a state not one but all the paths may have to be pursued to reach the goal state. STATE 1 AND Node AI CSC361: Problem Solving & Search

21 AI CSC361: Problem Solving & Search
AND-OR Search Graphs How do AND-OR graphs arise? AND-OR graphs arise when it is advantageous to decompose a state into its components which are independent of each other. Example: Integration (See the handout) Example: Rewriting problem – found in syntax analysis. AI CSC361: Problem Solving & Search

22 AI CSC361: Problem Solving & Search
AND-OR Search Graphs Example: Rewriting Problem: Start State: (C, B, Z) Operators/actions: R1: C  (D, L) R2: C (B, M) R3: B (M, M) R4: Z  (B, B, M) Goal State: any state consisting only of M’s AI CSC361: Problem Solving & Search

23 AI CSC361: Problem Solving & Search
AO* How are AND-OR graphs searched with a best-first strategy? A* algorithm is not suitable Should we choose C to expand next? No, because total cost along C would be =9; Along B, 5+1=6 B is the best choice. A B C D h = 5 h = 3 h = 4 1 AI CSC361: Problem Solving & Search

24 AI CSC361: Problem Solving & Search
AO* Algorithm General search for AND-OR graphs: Initialize: {D1,..,Dn}  decompose initial state into independent components Di, if possible. Loop until {Di} is Empty Select: Select current path D* from {Di} according to some strategy and a node in D*. Goal Check: Do all leaves in the current path D* satisfy goal_test()? If Yes, return solution. AI CSC361: Problem Solving & Search

25 AI CSC361: Problem Solving & Search
AO* Algorithm Expand: Expand node selected from D*. Decompose each state generated and add the components to {Di}. End. AI CSC361: Problem Solving & Search

26 Local Search Algorithms
AI CSC361: Problem Solving & Search

27 Local Search Algorithms
What type of problems can these algorithms be used to solve? Many problems (e.g. 8-queens, VLSI layout, ..) have the property that the state description of a goal itself contains all the information needed for a solution – the path by which the solution is reached is does not matter. These algorithms keep a single state and try to improve it. AI CSC361: Problem Solving & Search

28 Local Search Algorithms
Put n queens on an n × n board with no two queens on the same row, column, or diagonal AI CSC361: Problem Solving & Search

29 Local Search Algorithms
Generate-and-Test (the basic algorithm) Hill-Climbing Simple-Hill-Climbing Steepest-Ascent-Hill-Climbing Simulated Annealing Genetic Algorthms AI CSC361: Problem Solving & Search

30 Generate-and-Test Algorithm
Generate a possible solution state. (Randomly or by improving the current state) Test if it is a solution state by comparing with the goal state. If the solution state has been found quit else go to step 1. AI CSC361: Problem Solving & Search

31 Hill-Climbing Algorithm
"Like climbing Everest in thick fog with amnesia“ AI CSC361: Problem Solving & Search

32 Hill-Climbing Algorithm
Problem: Algorithm depends on initial state, can get stuck in local maxima. AI CSC361: Problem Solving & Search

33 Hill-Climbing: 8-Queens
h (n) = number of pairs of queens that are attacking each other, either directly or indirectly h (n) = 17 for this state AI CSC361: Problem Solving & Search

34 Hill-Climbing: 8-Queens
h (n) = 1 for this state AI CSC361: Problem Solving & Search

35 AI CSC361: Problem Solving & Search
Hill-Climbing Problems with Hill-Climbing: Local Maxima Plateaus Ridges AI CSC361: Problem Solving & Search

36 AI CSC361: Problem Solving & Search
Summary Informed search algorithms Local search algorithms AI CSC361: Problem Solving & Search


Download ppt "Problem Solving by Searching"

Similar presentations


Ads by Google