1 CS B551: Elements of Artificial Intelligence Instructor: Kris Hauser

Slides:



Advertisements
Similar presentations
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2007.
Advertisements

January 26, 2003AI: Chapter 3: Solving Problems by Searching 1 Artificial Intelligence Chapter 3: Solving Problems by Searching Michael Scherger Department.
Artificial Intelligence Problem Solving Eriq Muhammad Adams
Lecture 3: Uninformed Search
Problem Solving and Search Andrea Danyluk September 9, 2013.
Problem Solving Agents A problem solving agent is one which decides what actions and states to consider in completing a goal Examples: Finding the shortest.
1 Lecture 3 Uninformed Search. 2 Uninformed search strategies Uninformed: While searching you have no clue whether one non-goal state is better than any.
Blind Search by Prof. Jean-Claude Latombe
Uninformed (also called blind) search algorithms) This Lecture Chapter Next Lecture Chapter (Please read lecture topic material before.
CS 480 Lec 3 Sept 11, 09 Goals: Chapter 3 (uninformed search) project # 1 and # 2 Chapter 4 (heuristic search)
Blind Search1 Solving problems by searching Chapter 3.
Search Strategies Reading: Russell’s Chapter 3 1.
May 12, 2013Problem Solving - Search Symbolic AI: Problem Solving E. Trentin, DIISM.
1 Blind (Uninformed) Search (Where we systematically explore alternatives) R&N: Chap. 3, Sect. 3.3–5.
Solving Problem by Searching Chapter 3. Outline Problem-solving agents Problem formulation Example problems Basic search algorithms – blind search Heuristic.
Implementation and Evaluation of Search Methods. Use a stack data structure. 1. Push root node of tree on the stack. 2. Pop the top node off the stack.
Touring problems Start from Arad, visit each city at least once. What is the state-space formulation? Start from Arad, visit each city exactly once. What.
Artificial Intelligence for Games Uninformed search Patrick Olivier
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
Problem Solving and Search in AI Part I Search and Intelligence Search is one of the most powerful approaches to problem solving in AI Search is a universal.
CS 380: Artificial Intelligence Lecture #3 William Regli.
Review: Search problem formulation
Artificial Intelligence
Searching the search space graph
1 Search Problems (Where reasoning consists of exploring alternatives) R&N: Chap. 3, Sect. 3.1–
Search I Tuomas Sandholm Carnegie Mellon University Computer Science Department [Read Russell & Norvig Chapter 3]
Artificial Intelligence Chapter 3: Solving Problems by Searching
1 Solving Problems by Searching. 2 Terminology State State Space Initial State Goal Test Action Step Cost Path Cost State Change Function State-Space.
1 Lecture 3 Uninformed Search. 2 Complexity Recap (app.A) We often want to characterize algorithms independent of their implementation. “This algorithm.
Solving problems by searching
1 Lecture 3 Uninformed Search
1 Midterm Review cmsc421 Fall Outline Review the material covered by the midterm Questions?
Solving Problems by Searching
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
1 Problem Solving and Searching CS 171/271 (Chapter 3) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Solving Problems by Searching CPS Outline Problem-solving agents Example problems Basic search algorithms.
Problem Solving and Search Andrea Danyluk September 11, 2013.
CS 440 / ECE 448 Introduction to Artificial Intelligence Spring 2010 Lecture #3 Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam.
Search Tamara Berg CS 560 Artificial Intelligence Many slides throughout the course adapted from Dan Klein, Stuart Russell, Andrew Moore, Svetlana Lazebnik,
Artificial Intelligence
1 Solving Problems by Searching (Blindly) R&N: Chap. 3 (many of these slides borrowed from Stanford’s AI Class)
AI in game (II) 권태경 Fall, outline Problem-solving agent Search.
Lecture 3: Uninformed Search
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
SOLVING PROBLEMS BY SEARCHING Chapter 3 August 2008 Blind Search 1.
A General Introduction to Artificial Intelligence.
Problem solving by search Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;
Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.
Goal-based Problem Solving Goal formation Based upon the current situation and performance measures. Result is moving into a desirable state (goal state).
1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further.
Uninformed search strategies A search strategy is defined by picking the order of node expansion Uninformed search strategies use only the information.
Problem Solving as Search. Problem Types Deterministic, fully observable  single-state problem Non-observable  conformant problem Nondeterministic and/or.
Implementation: General Tree Search
Solving problems by searching A I C h a p t e r 3.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.5) Sept, 13, 2013.
Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 CS121 – Winter 2003.
Search Part I Introduction Solutions and Performance Uninformed Search Strategies Avoiding Repeated States Partial Information Summary.
Brian Williams, Fall 041 Analysis of Uninformed Search Methods Brian C. Williams Sep 21 st, 2004 Slides adapted from: Tomas Lozano Perez,
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Artificial Intelligence Solving problems by searching.
1 Search Problems (Where we see problems as the exploration of alternatives) R&N: Chap. 3, Sect. 3.1–
Constraint satisfaction
Artificial Intelligence Solving problems by searching
Russell and Norvig: Chapter 3, Sections 3.4 – 3.6
Instructor: Kris Hauser
Solving Problems by Searching
Presentation transcript:

1 CS B551: Elements of Artificial Intelligence Instructor: Kris Hauser

2 Recap  Agent Frameworks  Problem Solving with Search

3 Agenda   Search problems   Searching, data structures, and algorithms   Breadth-first search   Depth-first search   Uniform-cost search

4 Search problems

5 Defining a Search Problem  State space S  Successor function: x  S  SUCC (x)  2 S  Initial state s 0  Goal test: x  S  GOAL? (x) =T or F  Arc cost S

6 State Graph  Each state is represented by a distinct node  An arc (or edge) connects a node s to a node s’ if s’  SUCC (s)  An arc (or edge) connects a node s to a node s’ if s’  SUCC (s)  The state graph may contain more than one connected component

7 8-Queens Problem  State repr. 1 Any placement of 0-8 queensAny placement of 0-8 queens  State repr. 2 Any non- conflicting placement of 0-8 queensAny non- conflicting placement of 0-8 queens

8 Representation 1  State: any placement of 0-8 queens  Initial state: 0 queens  Successor function: Place queen in empty squarePlace queen in empty square  Goal test: Non-conflicting placement of 8 queensNon-conflicting placement of 8 queens  # of states ~ 64x63x…x57 ~ 3x10 14

9 Representation 2  State: any placement of non-conflicting 0-8 queens in columns starting from left  Initial state: 0 queens  Successor function: A queen placed in leftmost empty column such that it causes no conflictsA queen placed in leftmost empty column such that it causes no conflicts  Goal test: Any state with 8 queensAny state with 8 queens  # of states = 2057

10 Path Planning What is the state space ?

11 Formulation #1 Cost of one horizontal/vertical step = 1 Cost of one diagonal step =  2

12 Optimal Solution This path is the shortest in the discretized state space, but not in the original continuous space

13 Formulation #2 Cost of one step: length of segment

14 Formulation #2 Cost of one step: length of segment Visibility graph

15 Solution Path The shortest path in this state space is also the shortest in the original continuous space

16 Example: 8-Puzzle Initial stateGoal state State: Any arrangement of 8 numbered tiles and an empty tile on a 3x3 board

17 15-Puzzle Introduced (?) in 1878 by Sam Loyd, who dubbed himself “America’s greatest puzzle-expert”

18 15-Puzzle Sam Loyd offered $1,000 of his own money to the first person who would solve the following problem: ?

19 But no one ever won the prize !!

20 How big is the state space of the (n 2 -1)-puzzle?  8-puzzle  ?? states

21 How big is the state space of the (n 2 -1)-puzzle?  8-puzzle  9! = 362,880 states  15-puzzle  16! ~ 2.09 x states  24-puzzle  25! ~ states But only half of these states are reachable from any given state (but you may not know that in advance)

22  Wlg, let the goal be:  A tile j appears after a tile i if either j appears on the same row as i to the right of i, or on another row below the row of i.  For every i = 1, 2,..., 15, let n i be the number of tiles j < i that appear after tile i (permutation inversions)  N = n 2 + n 3 +  + n 15 + row number of empty tile Permutation Inversions n 2 = 0n 3 = 0n 4 = 0 n 5 = 0n 6 = 0n 7 = 1 n 8 = 1n 9 = 1n 10 = 4 n 11 = 0n 12 = 0n 13 = 0 n 14 = 0n 15 = 0  N = 7 + 4

23  Proposition: (N mod 2) is invariant under any legal move of the empty tile  Proof: Any horizontal move of the empty tile leaves N unchangedAny horizontal move of the empty tile leaves N unchanged A vertical move of the empty tile changes N by an even increment (  1  1  1  1)A vertical move of the empty tile changes N by an even increment (  1  1  1  1) s = s’ = N(s’) = N(s)

24  Proposition: (N mod 2) is invariant under any legal move of the empty tile   For a goal state g to be reachable from a state s, a necessary condition is that N(g) and N(s) have the same parity  It can be shown that this is also a sufficient condition   The state graph consists of two connected components of equal size

25 Searching the State Space  It is often not feasible (or too expensive) to build a complete representation of the state graph

26 8-puzzle  362,880 states 15-puzzle  2.09 x states 24-puzzle  states 100 millions states/sec sec ~ 55 hours > 10 9 years 8-, 15-, 24-Puzzles

27 Searching

28 Searching the State Space  Often it is not feasible (or too expensive) to build a complete representation of the state graph  A problem solver must construct a solution by exploring a small portion of the graph

29 Searching the State Space Search tree

30 Searching the State Space Search tree

31 Searching the State Space Search tree

32 Searching the State Space Search tree

33 Searching the State Space Search tree

34 Searching the State Space Search tree

35 Search Nodes and States If states are allowed to be revisited, the search tree may be infinite even when the state space is finite If states are allowed to be revisited, the search tree may be infinite even when the state space is finite

36 Data Structure of a Node PARENT-NODE STATE Depth of a node N = length of path from root to N (depth of the root = 0) BOOKKEEPING5Path-Cost 5Depth RightAction Expanded yes... CHILDREN

37 Node expansion The expansion of a node N of the search tree consists of: 1)Evaluating the successor function on STATE (N) 2)Generating a child of N for each state returned by the function node generation  node expansion N

38 Fringe of Search Tree  The fringe is the set of all search nodes that haven’t been expanded yet

39 Is it identical to the set of leaves?

40 Search Strategy  The fringe is the set of all search nodes that haven’t been expanded yet  The fringe is implemented as a priority queue FRINGE INSERT(node,FRINGE)INSERT(node,FRINGE) REMOVE(FRINGE)REMOVE(FRINGE)  The ordering of the nodes in FRINGE defines the search strategy

41 Search Algorithm #1 SEARCH#1 1. If GOAL?(initial-state) then return initial-state 2. INSERT(initial-node,FRINGE) 3. Repeat: a.If empty(FRINGE) then return failure b.N  REMOVE(FRINGE) c.s  STATE(N) d.For every state s’ in SUCCESSORS(s) i. Create a new node N’ as a child of N ii. If GOAL?(s’) then return path or goal state iii. INSERT(N’,FRINGE) Expansion of N

42 Performance Measures  Completeness A search algorithm is complete if it finds a solution whenever one exists [What about the case when no solution exists?]  Optimality A search algorithm is optimal if it returns a minimum-cost path whenever a solution exists  Complexity It measures the time and amount of memory required by the algorithm

43 Blind Search Strategies

44 Blind Strategies  Breadth-first BidirectionalBidirectional  Depth-first Depth-limitedDepth-limited Iterative deepeningIterative deepening  Uniform-Cost (variant of breadth-first) Arc cost = 1 Arc cost = c(action)    0

45 Breadth-First Strategy New nodes are inserted at the end of FRINGE New nodes are inserted at the end of FRINGE FRINGE = (1)

46 Breadth-First Strategy New nodes are inserted at the end of FRINGE New nodes are inserted at the end of FRINGE FRINGE = (2, 3)

47 Breadth-First Strategy New nodes are inserted at the end of FRINGE New nodes are inserted at the end of FRINGE FRINGE = (3, 4, 5)

48 Breadth-First Strategy New nodes are inserted at the end of FRINGE New nodes are inserted at the end of FRINGE FRINGE = (4, 5, 6, 7)

49 Important Parameters 1) Maximum number of successors of any state  branching factor b of the search tree 2) Minimal length (≠ cost) of a path between the initial and a goal state  depth d of the shallowest goal node in the search tree

50 Evaluation  b: branching factor  d: depth of shallowest goal node  Breadth-first search is: Complete? Not complete?Complete? Not complete? Optimal? Not optimal?Optimal? Not optimal?

51 Evaluation  b: branching factor  d: depth of shallowest goal node  Breadth-first search is: CompleteComplete Optimal if step cost is 1Optimal if step cost is 1  Number of nodes generated: ???

52 Evaluation  b: branching factor  d: depth of shallowest goal node  Breadth-first search is: CompleteComplete Optimal if step cost is 1Optimal if step cost is 1  Number of nodes generated: 1 + b + b 2 + … + b d = ???

53 Evaluation  b: branching factor  d: depth of shallowest goal node  Breadth-first search is: CompleteComplete Optimal if step cost is 1Optimal if step cost is 1  Number of nodes generated: 1 + b + b 2 + … + b d = (b d+1 -1)/(b-1) = O(b d )   Time and space complexity is O(b d )

54 Time and Memory Requirements d # Nodes TimeMemory msec 11 Kbytes 411,111 1 msec 1 Mbyte 6 ~ sec 100 Mb 8 ~ sec 10 Gbytes 10 ~ hours 1 Tbyte 12 ~ days 100 Tbytes 14 ~ years 10,000 Tbytes Assumptions: b = 10; 1,000,000 nodes/sec; 100bytes/node

55 Time and Memory Requirements d # Nodes TimeMemory msec 11 Kbytes 411,111 1 msec 1 Mbyte 6 ~ sec 100 Mb 8 ~ sec 10 Gbytes 10 ~ hours 1 Tbyte 12 ~ days 100 Tbytes 14 ~ years 10,000 Tbytes Assumptions: b = 10; 1,000,000 nodes/sec; 100bytes/node

56 Remark If a problem has no solution, breadth-first may run for ever (if the state space is infinite or states can be revisited arbitrary many times) ?

57 Bidirectional Strategy 2 fringe queues: FRINGE1 and FRINGE2 s Time and space complexity is O(b d/2 )  O(b d ) if both trees have the same branching factor b Question: What happens if the branching factor is different in each direction?

58 Depth-First Strategy New nodes are inserted at the front of FRINGE New nodes are inserted at the front of FRINGE FRINGE = (1)

59 Depth-First Strategy New nodes are inserted at the front of FRINGE New nodes are inserted at the front of FRINGE FRINGE = (2, 3)

60 Depth-First Strategy New nodes are inserted at the front of FRINGE New nodes are inserted at the front of FRINGE FRINGE = (4, 5, 3)

61 Depth-First Strategy New nodes are inserted at the front of FRINGE New nodes are inserted at the front of FRINGE

62 Depth-First Strategy New nodes are inserted at the front of FRINGE New nodes are inserted at the front of FRINGE

63 Depth-First Strategy New nodes are inserted at the front of FRINGE New nodes are inserted at the front of FRINGE

64 Depth-First Strategy New nodes are inserted at the front of FRINGE New nodes are inserted at the front of FRINGE

65 Depth-First Strategy New nodes are inserted at the front of FRINGE New nodes are inserted at the front of FRINGE

66 Depth-First Strategy New nodes are inserted at the front of FRINGE New nodes are inserted at the front of FRINGE

67 Depth-First Strategy New nodes are inserted at the front of FRINGE New nodes are inserted at the front of FRINGE

68 Depth-First Strategy New nodes are inserted at the front of FRINGE New nodes are inserted at the front of FRINGE

69 Evaluation  b: branching factor  d: depth of shallowest goal node  m: maximal depth of a leaf node  Depth-first search is:  Complete?  Optimal?

70 Evaluation  b: branching factor  d: depth of shallowest goal node  m: maximal depth of a leaf node  Depth-first search is:  Complete only for finite search tree  Not optimal  Number of nodes generated (worst case): 1 + b + b 2 + … + b m = O(b m )  Time complexity is O(b m )  Space complexity is O(bm) [or O(m)] [Reminder: Breadth-first requires O(b d ) time and space]

71 Depth-Limited Search  Depth-first with depth cutoff k (depth at which nodes are not expanded)  Three possible outcomes: SolutionSolution Failure (no solution)Failure (no solution) Cutoff (no solution within cutoff)Cutoff (no solution within cutoff)

72 Iterative Deepening Search Provides the best of both breadth-first and depth-first search Provides the best of both breadth-first and depth-first search Main idea: IDS For k = 0, 1, 2, … do: Perform depth-first search with depth cutoff k (i.e., only generate nodes with depth  k) Totally horrifying !

73 Iterative Deepening

74 Iterative Deepening

75 Iterative Deepening

76 Performance  Iterative deepening search is: CompleteComplete Optimal if step cost =1Optimal if step cost =1  Time complexity is: (d+1)(1) + db + (d-1)b 2 + … + (1) b d = O(b d )  Space complexity is: O(bd) or O(d)

77 Calculation db + (d-1)b 2 + … + (1) b d = b d + 2b d-1 + 3b d-2 +… + db = (1 + 2b b -2 + … + db -d )  b d  (  i=1,…,  ib (1-i) )  b d = b d ( b/(b-1) ) 2

78 d = 5 and b = 2 BFID 1 1 x 6 = x 5 = x 4 = x 3 = x 2 = x 1 = /63 ~ 2 Number of Generated Nodes (Breadth-First & Iterative Deepening)

79 Number of Generated Nodes (Breadth-First & Iterative Deepening) d = 5 and b = 10 BFID ,0003,000 10,00020, ,000100, ,111123, ,456/111,111 ~ 1.111

80 Recap  BFS: Complete, optimal O(b d ) time and spaceO(b d ) time and space  DFS: Not complete nor optimal O(bd) space, unbounded timeO(bd) space, unbounded time  ID: Complete, optimal O(bd) space, O(b d ) timeO(bd) space, O(b d ) time

81 Homework  Readings: R&N Ch  HW1 due on 9/22