1 CS 385 Fall 2006 Chapter 3 Structures and Strategies for State Space Search.

Slides:



Advertisements
Similar presentations
Artificial Intelligence (AI)
Advertisements

State Space Representation and Search
CSC411Artificial Intelligence 1 Chapter 3 Structures and Strategies For Space State Search Contents Graph Theory Strategies for Space State Search Using.
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2007.
Part2 AI as Representation and Search
KU NLP Artificial Intelligence1 Ch 3. Structures and Strategies for State Space Search q Introduction q Graph Theory  Structures for state space search.
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.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
CS 484 – Artificial Intelligence1 Announcements Department Picnic: today, after class Lab 0 due today Homework 2 due Tuesday, 9/18 Lab 1 due Thursday,
Structures and Strategies For Space State Search
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
CS 206 Introduction to Computer Science II 11 / 07 / 2008 Instructor: Michael Eckmann.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
Uninformed Search Jim Little UBC CS 322 – Search 2 September 12, 2014
State Space Search 2 Chapter 3 Three Algorithms. Backtracking Suppose We are searching depth-first No further progress is possible (i.e., we can only.
Search: Representation and General Search Procedure Jim Little UBC CS 322 – Search 1 September 10, 2014 Textbook § 3.0 –
Search: Representation and General Search Procedure CPSC 322 – Search 1 January 12, 2011 Textbook § 3.0 –
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2004.
State-Space Searches. State spaces A state space consists of –A (possibly infinite) set of states The start state represents the initial problem Each.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Structures and Strategies for State Space Search
Structures and Strategies for State Space Search
Graph COMP171 Fall Graph / Slide 2 Graphs * Extremely useful tool in modeling problems * Consist of: n Vertices n Edges D E A C F B Vertex Edge.
1 Structures and Strategies for State Space Search 3 3.0Introduction 3.1Graph Theory 3.2Strategies for State Space Search 3.3Using the State Space to Represent.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
Blind Search-Part 2 Ref: Chapter 2. Search Trees The search for a solution can be described by a tree - each node represents one state. The path from.
© 2006 Pearson Addison-Wesley. All rights reserved14 B-1 Chapter 14 (continued) Graphs.
Using Search in Problem Solving
1 Structures and Strategies for State Space Search 3 3.0Introduction 3.1Graph Theory 3.2Strategies for State Space Search 3.3Using the State Space to Represent.
Structures and Strategies For Space State Search
1 Structures and Strategies for State Space Search 3 3.0Introduction 3.1Graph Theory 3.2Strategies for State Space Search 3.3Using the State Space to Represent.
State-Space Searches. 2 State spaces A state space consists of –A (possibly infinite) set of states The start state represents the initial problem Each.
State-Space Searches.
3.0 State Space Representation of Problems 3.1 Graphs 3.2 Formulating Search Problems 3.3 The 8-Puzzle as an example 3.4 State Space Representation using.
Artificial Intelligence Introduction (2). What is Artificial Intelligence ?  making computers that think?  the automation of activities we associate.
Formal Description of a Problem In AI, we will formally define a problem as –a space of all possible configurations where each configuration is called.
Artificial Intelligence LECTURE 3 ARTIFICIAL INTELLIGENCE LECTURES BY ENGR. QAZI ZIA 1.
KU NLP Structures and Strategies for State Space Search Depth-First and Breadth-First Search q A search algorithm must determine the order in which.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l inference l all learning.
Knowledge Representation CPTR 314. The need of a Good Representation  The representation that is used to represent a problem is very important  The.
Chapter 2 Problems, Problem Spaces, and Search?
BackTracking CS335. N-Queens The object is to place queens on a chess board in such as way as no queen can capture another one in a single move –Recall.
CS 415 – A.I. Slide Set 5. Chapter 3 Structures and Strategies for State Space Search – Predicate Calculus: provides a means of describing objects and.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
Chapter 2 Problems, Problem Spaces, and Search?
Formal Description of a Problem In AI, we will formally define a problem as –a space of all possible configurations where each configuration is called.
Lecture 3: Uninformed Search
CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
1 Directed Graphs Chapter 8. 2 Objectives You will be able to: Say what a directed graph is. Describe two ways to represent a directed graph: Adjacency.
Knowledge Search CPTR 314.
Search Techniques CS480/580 Fall Introduction Trees: – Root, parent, child, sibling, leaf node, node, edge – Single path from root to any node Graphs:
George F Luger ARTIFICIAL INTELLIGENCE 5th edition Structures and Strategies for Complex Problem Solving Structures and Strategies For Space State Search.
STRUCTURES AND STRATEGIES FOR STATE SPACE SEARCH 3 3.0Introduction 3.1Graph Theory 3.2Strategies for State Space Search 3.3Using the State Space to Represent.
STRUCTURES AND STRATEGIES FOR STATE SPACE SEARCH 3 3.0Introduction 3.1Graph Theory 3.2Strategies for State Space Search 3.3Using the State Space to Represent.
State space search Represented by a four-tuple [N,A,S,GD], where: N is the problem space A is the set of arcs (or links) between nodes. These correspond.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.5) Sept, 13, 2013.
STRUCTURES AND STRATEGIES FOR STATE SPACE SEARCH.
Biointelligence Lab School of Computer Sci. & Eng. Seoul National University Artificial Intelligence Chapter 8 Uninformed Search.
Chap 4: Searching Techniques Artificial Intelligence Dr.Hassan Al-Tarawneh.
A Historical Example One of the most famous problems in graph theory is the bridges of Konigsberg Can you cross every bridge exactly once and come back.
BackTracking CS255.
Chap 4: Searching Techniques Artificial Intelligence Dr.Hassan Al-Tarawneh.
Blay Whitby 2003 Search Blay Whitby 2003
Chap 4: Searching Techniques
State-Space Searches.
State-Space Searches.
Chapter 2 Problems, Problem Spaces, and Search?
State-Space Searches.
Presentation transcript:

1 CS 385 Fall 2006 Chapter 3 Structures and Strategies for State Space Search

2 Where are we? Predicate calculus: –a way to describe objects and relationships Inference rules: –a way to infer new knowledge, defining a state space that is searched to find a solution to a problem Strategy –generate all possible elements of the state space and see if your answer is there –works for tic-tac-toe –doesn't work for chess Goal: intelligent ways to search a state space Tool: state space graphs.

3 Famous example: Konigsburg bridge problem Is there a walk that crosses each bridge exactly once? Can we represent this in a better way?

4 Graph of the Königsberg bridge system: Predicate calculus representation: connect(i1,i2, b1)....

5 Euler's Proof A node is odd or even depending on the number of arcs leading into it Odd degree nodes can only be at the beginning of the path A walk must contain 0 or 2 odd nodes (why?) Is there a path? Does predicate calculus suffice for this argument? No, no notion of odd/even We need graph theory to do more with this.

6 What are N, A, S, and GD for tic-tac-toe? N could be all possible configurations of 0s and 1s or just reachable ones. A: allowable moves between boards S: empty board, GD winning boards

7 The 8 Puzzle N = 3 x 3 configurations of tiles 1-8 and 1 blank Start state: Goal state: Arcs: move the blank up/down/left/right

8 Figure 3.6: State space of the 8-puzzle generated by “move blank” operations. Is this like tic-tac toe? No, you might go around in circles

9 Traveling Salesperson N= cities A = paths between cities with weights (mileage, time, cost) S = home GD = home Path: visit each exactly once Goal: minimize something

10 Figure 3.8: Search of the traveling salesperson problem. Each arc is marked with the total weight of all paths from the start node (A) to its endpoint.

11 Traveling Salesperson How many potential paths? Can we solve this for 50 states? Of great interest to people who like algorithms because it gets large so fast. Exhaustive search out of the question

12 Figure 3.9:The traveling salesperson problem with the nearest neighbor path in bold. Note that this path (A, E, D, B, C, A), at a cost of 550, is not the shortest. The comparatively high cost of arc (C, A) defeated the heuristic.

13 Data- versus Goal-Driven for Finding a Route from Aurora to LA Where you start. E.g. routes from Aurora to LA Data driven (forward chaining) From Aurora one can get to x, y, z... From x one can get to.. From y one can get to... Keep checking to see if LA ends up in one of the destinations Goal driven (backward chaining) One can get to LA from x, y, z... One can get to x from.. One can get to y from Keep checking to see if Aurora ends up in one of the sources

14 Better examples Lineage: am I related to Reverend Thomas Carter? Which is better, data or goal driven? Could I prune extraneous paths? Is this the same as "Am I related to Thomas Jefferson"?

15 Medical Diagnosis "Do I have strep throat" vs. "What disease do I have" strep symptoms vs. lots of symptoms take a culture vs. run a spectrum of tests Which is data-driven/forward chaining? Which is goal-driven/backward chaining?

16 Backtracking A technique for systematically trying all paths through a state space. Begin at start and pursue a path until goal or dead end If dead end, backtrack to most recent node with unexamined siblings E.g. is 6 in this tree? 1 Possible trials:       How do we pick the "best" path?

17 Function backtrack algorithm (general, no examination order specified) CS: current state SL: states in current path NSL states awaiting evaluation DE: dead ends typo in book, p should be ≠

18 A trace of backtrack on the graph of figure 3.12

19 A trace of backtrack on the graph of figure 3.12

20 A trace of backtrack on the graph of figure 3.12

21 A trace of backtrack on the graph of figure 3.12

22 Observations No order is specified for adding nodes to NSL (opportunity for intelligence) SL gives us the path to the current solution (hence to the goal at the end) When C is the current state, F is not added to NSL (because it is in DE)

23 How used on a maze? ifgoal return success else try north try east try south try west backtrack Track: where you are where you can go from each state where you came from visited states

24 Function breadth_first search algorithm X is CS in backtrack, closed = DE + SL

25 breadth_first_search on Figure 3.13 openclosed [A] [ ] [B C D][A] [C D E F][B A] [D E F G H][C B A] [E F G H I J][D C B A] [F G H I J K L][E D C B A] [G H I J K L M][F E D C B A] [H I J K L M N][G F E D B C A] [I J K L M N O P][F T L S K E B A] [J K L M N O P Q][M F T L S K E B A] [K L M N O P Q R][J M F T L S K E B A]

26 Observations Cleaner But no path to start state Solution: associate the parent with each node. E.g. [B, C, D] → [(B,A), (C,A), (D,A)] [C, D, E, F] → [(C,A), (D,A), (B,A), (F, B)] Is the first algorithm ever better?

27 depth_first_search on Figure 3.13 Put new nodes at the beginning of the open list. openclosed [A] [ ] [B C D][A] [E F C D][B A] [K L F C D][E B A] [S L F C D][K E B A] [L F C D][S K E B A] [T F C D][L S K E B A] [F C D][T L S K E B A] [M C D][F T L S K E B A] [C D][M F T L S K E B A] [G H D][C M F T L S K E B A]

28 Comparison BFS finds the shortest path DFS gets quickly into a deep search space good if you know the solution is "far away" wrong path: inefficient DFS with iterative deepening use a depth bound retreat at the bound no luck: increase the bound Later: use knowledge about the problem to order nodes on the open list

29 Using State Space to Represent Predicate Calculus node: state of the problem arc: inference search: to decide if an assertion is implied by others q → pp r → p   v → q q r u s → r     t → r v t s s → u s, t Determining truth: path from boxed nodes to proposition Data-driven: start with boxed; goal-driven: start with goal. DFS or BFS?

30 Is p true? BFS openclosed [t s][] [s r][t] [r u][s t] [u p][r s t] [p][u r s t] p   q r u     v t s

31 Is p true? DFS openclosed [t s][] [r s][t] [p u][r t] p   q r u     v t s

32 And/Or Graphs in the graph above t  s →r: r t s To express t  s →r, connect incoming arcs r t s

33 Example a b c a  b → d a  c → e b  d → f f → g a  e → h Graph?

34 Example a b c a  b → d a  c → e b  d → f f → g a  e → h

35 Search for h: Goal-directed: h: try to prove a and e a is true e is true if c and a a is true c is true ← e is true ← h is true Data-directed: a, b, c are true a and b → d a and c → e a and e → h

36 Symbolic Integration MACSYMA Symbolic algebra, including integration How do you think this works? Decomposition using and/or graphs ∫f + g decomposes to ∫f and ∫g More complicated expressions decompose into possible transformations Graph is generated on the fly Goal-directed How is it searched? BFS? DFS?

37 Figure 3.24:

38 And/Or for Financial Advisor?

39 Figure 3.26:And/or graph for the financial advisor

40 Five rules for a simple subset of English grammar (rewrite rules): Does 1 look like AND? Do 2 and 3 this look like OR? Construct the graph

41 Figure 3.27:And/or graph for the grammar of Example How do we use this? A sentence is well-formed if it consists of terminal symbols and there is a series of substitutions that reduce it to the sentence symbol

42 Figure 3.28:Parse tree for “The dog bites the man.” Note that this is a subtree Figure 3.26.

43 Parse "the dog bites the man" 7: art ↔ the gives art dog bites the man 7: art ↔ the gives art dog bites art man 8: n ↔ mangivesart dog bites art n* 3: np ↔ art ngivesart dog bites np** 9: n ↔ doggivesart n bites np 3: np↔ art ngivesnp bites np 11: v ↔ bitesgivesnp v bites 5: vp ↔ v np givesnp vp 1: sentence ↔ np vp... * Why isn't dog rewritten first? ** Why didn't 11 fire instead: v ↔ bitesgivesart n v the man

44 Parse "dog the man" 7: art ↔ the gives dog art man 8: n ↔ mangivesdog art man 9: n ↔ doggivesn art n There are no rules that rewrite this How does the C++ compiler work? Can you write a grammer for C++? program ↔ declarations body...

45 Figure 3.29: