1 Search Problems (Where we see problems as the exploration of alternatives) R&N: Chap. 3, Sect. 3.1–

Slides:



Advertisements
Similar presentations
Solving problems by searching
Advertisements

Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2007.
Artificial Intelligence Problem Solving Eriq Muhammad Adams
Solving Problem by Searching Chapter 3. Outline Problem-solving agents Problem formulation Example problems Basic search algorithms – blind search Heuristic.
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.
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
Search: Representation and General Search Procedure Jim Little UBC CS 322 – Search 1 September 10, 2014 Textbook § 3.0 –
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.
Search Problems Russell and Norvig: Chapter 3, Sections 3.1 – 3.3 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude.
CPSC 322, Lecture 4Slide 1 Search: Intro Computer Science cpsc322, Lecture 4 (Textbook Chpt ) January, 12, 2009.
Search: Representation and General Search Procedure CPSC 322 – Search 1 January 12, 2011 Textbook § 3.0 –
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2004.
Artificial Intelligence
1 Search Problems (Where reasoning consists of exploring alternatives) R&N: Chap. 3, Sect. 3.1–
November 10, 2009Introduction to Cognitive Science Lecture 17: Game-Playing Algorithms 1 Decision Trees Many classes of problems can be formalized as search.
Search Problems Russell and Norvig: Chapter 3, Sections 3.1 – 3.3.
Solving problems by searching
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
Solving problems by searching This Lecture Read Chapters 3.1 to 3.4 Next Lecture Read Chapter 3.5 to 3.7 (Please read lecture topic material before and.
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 Lecture 9. Outline Search in State Space State Space Graphs Decision Trees Backtracking in Decision Trees.
Computer Science CPSC 322 Lecture 4 Search: Intro (textbook Ch: ) 1.
1 Solving problems by searching This Lecture Chapters 3.1 to 3.4 Next Lecture Chapter 3.5 to 3.7 (Please read lecture topic material before and after each.
CS 440 / ECE 448 Introduction to Artificial Intelligence Spring 2010 Lecture #3 Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam.
Dr.Abeer Mahmoud ARTIFICIAL INTELLIGENCE (CS 461D) Dr. Abeer Mahmoud Computer science Department Princess Nora University Faculty of Computer & Information.
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.
1 Solving problems by searching 171, Class 2 Chapter 3.
Artificial Intelligence
1 CS B551: Elements of Artificial Intelligence Instructor: Kris Hauser
Artificial Intelligence Lecture No. 6 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Blind Searches - Introduction.
Introduction to State Space Search
Search in State Spaces Problem solving as search Search consists of –state space –operators –start state –goal states A Search Tree is an efficient way.
February 11, 2016Introduction to Artificial Intelligence Lecture 6: Search in State Spaces II 1 State-Space Graphs There are various methods for searching.
G5AIAI Introduction to AI
1 Solving problems by searching Chapter 3. 2 Outline Problem types Example problems Assumptions in Basic Search State Implementation Tree search Example.
1 CS B551: Elements of Artificial Intelligence Instructor: Kris Hauser
Lecture 2: Problem Solving using State Space Representation CS 271: Fall, 2008.
Search Problems Russell and Norvig: Chapter 3, Sections 3.1 – 3.3 CS121 – Winter 2003.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Solving problems by searching Chapter 3. Types of agents Reflex agent Consider how the world IS Choose action based on current percept Do not consider.
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Solving problems by searching
Constraint satisfaction
ECE 448 Lecture 4: Search Intro
Introduction to Artificial Intelligence
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Artificial Intelligence Lecture No. 6
Problem Solving by Searching
Chapter 5. Optimal Matchings
Artificial Intelligence
Solving problems by searching
Problem Solving and Searching
Artificial Intelligence
Problem Solving and Searching
Haskell Tips You can turn any function that takes two inputs into an infix operator: mod 7 3 is the same as 7 `mod` 3 takeWhile returns all initial.
CO Games Development 1 Week 8 Depth-first search, Combinatorial Explosion, Heuristics, Hill-Climbing Gareth Bellaby.
Backtracking and Branch-and-Bound
Russell and Norvig: Chapter 3, Sections 3.1 – 3.3
Solving problems by searching
Solving problems by searching
Solving problems by searching
Instructor: Kris Hauser
Solving Problems by Searching
CS440/ECE 448 Lecture 4: Search Intro
Unit II Game Playing.
Solving problems by searching
Presentation transcript:

1 Search Problems (Where we see problems as the exploration of alternatives) R&N: Chap. 3, Sect. 3.1–

2 Example: 8-Puzzle Initial stateGoal state Search is about the exploration of alternatives

3 Exploratory search is an old idea: The Labyrinth and the Ariadne Thread According to Greek mythology, Theseus came to Crete to slay the Minotaur, a monster who lived in a Labyrinth. Ariadne gave Theseus a ball of yarn which he unwound as he entered the Labyrinth. After killing the Minotaur, Theseus traced the thread back to the entrance of the Labyrinth, rejoined Ariadne, and successfully escaped Crete

4 Since the dawn of civilization, puzzles and games that require the exploration of alternative paths have fascinated mankind and have been considered a challenge for human intelligence  Chess originated in Persia and India about 4000 years ago  Checkers appeared as early as 1600 B.C in Egyptian paintings  Go originated in China over 3000 years ago

5

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

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

8 But no one ever won the prize !!

9 8-Puzzle: State Space

10 8-Puzzle: Successor Function

11 Stating a Problem as a Search Problem  State space S  Successor function: x  S  SUCCESSORS (x)  2 S  Arc cost  Initial state s 0  Goal test: x  S  GOAL? (x) =T or F S 1 3 2

12 State Graph  A directed graph defined as follows: Each state is represented by a distinct node An arc exists from a node s to a node s’ if s’  SUCCESSORS (s)  The state graph may contain more than one connected component

13

14 Solution to the Search Problem  A solution is a path connecting the initial node to a goal node (any one)

15

16 Solution to the Search Problem  A solution is a path connecting the initial to a goal node (any one)  The cost of a path is the sum of the edge costs along this path  An optimal solution is a solution path of minimum cost  There might be no solution !

17

18 How big is the state space of the (n 2 -1)-puzzle?  8-puzzle  9! = 362,880 states  15-puzzle  16! ~ 1.3 x states  24-puzzle  25! ~ states But for even n (4-puzzle,15-puzzle, 35- puzzle, etc), only half of these states are reachable from any given state

19  Wlg, let the goal be:  Let n i be the number of tiles j < i that appear after tile i (from left to right and top to bottom)  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

20  Proposition: for n-puzzle with even n, (N mod 2) is invariant under any legal move of the empty tile  Proof: Any horizontal move of the empty tile leaves N unchanged A vertical move of the empty tile changes N by an even increment s = s’ = N(s’) = N(s)

21  Proposition: for n-puzzle with even n, (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

22 So, the second state is not reachable from the first, and Sam Loyd took no risk with his money... N = 4N = 5

23 This is not necessarily so if n is odd Example: N= =18 N= =21

24 What is the Actual State Space? a)The set of all states? [e.g., a set of 16! states for the 15-puzzle] b)The set of all states from which a given goal state is reachable? [e.g., a set of 16!/2 states for the 15-puzzle] c)The set of all states reachable from a given initial state? In general, the answer is a)

25 What is the Actual State Space? a)The set of all states? [e.g., a set of 16! states for the 15-puzzle] b)The set of all states from which a given goal state is reachable? [e.g., a set of 16!/2 states for the 15-puzzle] c)The set of all states reachable from a given initial state? In general, the answer is a) But a fast test determining whether a state is reachable from another is very useful, as search-based problem solvers are often very inefficient when a problem has no solution.

26 Stating a Problem as a Search Problem  State space S  Successor function: x  S  SUCCESSORS (x)  2 S  Arc cost  Initial state s 0  Goal test: x  S  GOAL? (x) =T or F  A solution is a path joining the initial to a goal node S 1 3 2

27 Searching the State Space  Often it is not feasible to build a complete representation of the state graph

28 8-puzzle  362,880 states 15-puzzle  1.3 x states 24-puzzle  states 100 millions states/sec sec < 4 hours > 10 9 years 8-, 15-, 24-Puzzles

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

30 Searching the State Space

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 Searching the State Space Search tree

36 Simple Problem-Solving-Agent Algorithm 1.s 0  sense/read initial state 2.GOAL?  select/read goal test 3.Succ  select/read successor function 4.solution  search(s 0, GOAL?, Succ) 5.perform(solution)

37 State Space  Each state is an abstract representation of a collection of possible worlds sharing some crucial properties and differing on non-important details only E.g.: In assembly planning, a state does not define exactly the absolute position of each part  The state space is discrete. It may be finite, or infinite

38 Successor Function  It implicitly represents all the actions that are feasible in each state

39 Successor Function  It implicitly represents all the actions that are feasible in each state  Only the results of the actions (the successor states) and their costs are returned by the function  The successor function is a “black box”: its content is unknown E.g., in assembly planning, the function does not say if it only allows two sub-assemblies to be merged or if it makes assumptions about subassembly stability

40 Path Cost  An arc cost is a positive number measuring the “cost” of performing the action corresponding to the arc, e.g.: 1 in the 8-puzzle example expected time to merge two sub-assemblies  We will assume that for any given problem the cost c of an arc always verifies: c  ε  0, where ε is a constant

41 Path Cost  An arc cost is a positive number measuring the “cost” of performing the action corresponding to the arc, e.g.: 1 in the 8-puzzle example expected time to merge two sub-assemblies  We will assume that for any given problem the cost c of an arc always verifies: c  ε  0, where ε is a constant [This condition guarantees that, if path becomes arbitrarily long, its cost also becomes arbitrarily large] Why is this needed?

42  It may be explicitly described:  or partially described:  or defined by a condition, e.g., the sum of every row, of every column, and of every diagonals equals 30 Goal State aa aa aa (“a” stands for “any”)

43 Other examples

44 8-Queens Problem Place 8 queens in a chessboard so that no two queens are in the same row, column, or diagonal. A solutionNot a solution

45 Formulation #1  States: all arrangements of 0, 1, 2,..., or 8 queens on the board  Initial state: 0 queen on the board  Successor function: each of the successors is obtained by adding one queen in an empty square  Arc cost: irrelevant  Goal test: 8 queens are on the board, with no two of them attacking each other  64 x 63 x... x 53 ~ 3 x states

46 Formulation #2  States: all arrangements of k = 0, 1, 2,..., or 8 queens in the k leftmost columns with no two queens attacking each other  Initial state: 0 queen on the board  Successor function: each successor is obtained by adding one queen in any square that is not attacked by any queen already in the board, in the leftmost empty column  Arc cost: irrelevant  Goal test: 8 queens are on the board  2,057 states

47 n-Queens Problem  A solution is a goal node, not a path to this node (typical of design problem)  Number of states in state space: 8-queens  2, queens   But techniques exist to solve n-queens problems efficiently for large values of n They exploit the fact that there are many solutions well distributed in the state space

48 Path Planning What is the state space ?

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

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

51 Formulation #2 sweep-line

52 Formulation #2

53 States

54 Successor Function

55 Solution Path A path-smoothing post-processing step is usually needed to shorten the path further

56 Formulation #3 Cost of one step: length of segment

57 Formulation #3 Cost of one step: length of segment Visibility graph

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

59 Assembly (Sequence) Planning

60 Possible Formulation  States: All decompositions of the assembly into subassemblies (subsets of parts in their relative placements in the assembly)  Initial state: All subassemblies are made of a single part  Goal state: Un-decomposed assembly  Successor function: Each successor of a state is obtained by merging two subassemblies (the successor function must check if the merging is feasible: collision, stability, grasping,...)  Arc cost: 1 or time to carry the merging

61 A Portion of State Space

62 Assumptions in Basic Search  The world is static  The world is discretizable  The world is observable  The actions are deterministic But many of these assumptions can be removed, and search still remains an important problem-solving tool

63 Vacuum Cleaner Problem  A vacuum robot lives in a two-room environment  States: The robot is in one of the two rooms, and each room may or may not contain dirt  8 states  Successor function: the successors of a state correspond to trying 3 actions: Right, Left, Suck.  Initial state: Unknown (not observable)  Goal state: No dust in the rooms

64 Re-Formulation with “Belief States”  Belief states: sets of states  2 8 =256 belief states  Initial belief state: set of 8 states  Successor function: the successors of a belief state correspond to trying Right, Left, Suck on all states in the belief state.  Goal belief state: any set of states with none having dust in any of the rooms

65 Left Right Suck

66 Search and AI  Search methods are ubiquitous in AI systems. They often are the backbones of both core and peripheral modules  An autonomous robot uses search methods: to decide which actions to take and which sensing operations to perform, to quickly anticipate and prevent collision, to plan trajectories, to interpret large numerical datasets provided by sensors into compact symbolic representations, to diagnose why something did not happen as expected, etc...

67 Class Exercise Formulate “Towers of Hanoi” as a search problem.