search problems
play

Search Problems Declarative knowledge Agent Perception creates - PDF document

Search Problems Declarative knowledge Agent Perception creates alternatives: Robotics (Where reasoning consists of Which pieces of Reasoning knowledge to use? exploring alternatives) Search How to use them? Learning Knowledge


  1. Search Problems � Declarative knowledge Agent Perception creates alternatives: Robotics (Where reasoning consists of ● Which pieces of Reasoning knowledge to use? exploring alternatives) Search ● How to use them? Learning Knowledge Constraint R&N: Chap. 3, Sect. 3.1–2 + 3.6 � Search is a about rep. Planning satisfaction exploring alternatives. It is a major approach to exploit knowledge Natural ... Expert language Systems 1 2 Example: 8-Puzzle 8-Puzzle: Successor Function SUCC(state) � subset of states 8 2 7 8 2 1 2 3 The successor function is knowledge 3 4 about the 8-puzzle game, but it does 3 4 7 4 5 6 not tell us which outcome to use, nor to 5 1 6 which state of the board to apply it. 5 1 6 7 8 8 2 8 2 7 8 2 7 Initial state Goal state 3 4 7 3 4 6 3 4 5 1 6 5 1 5 1 6 State: Any arrangement of 8 numbered tiles and an empty tile on a 3x3 board Search is about the exploration of alternatives 3 4 Across history, puzzles and games requiring the exploration of alternatives have been considered a challenge for human intelligence: � Chess originated in Persia and India about 4000 years ago � Checkers appear in 3600-year-old Egyptian paintings � Go originated in China over 3000 years ago So, it’s not surprising that AI uses games to design and test algorithms 5 6 1

  2. (n 2 -1)-puzzle 15-Puzzle Introduced (?) in 1878 by Sam Loyd, who dubbed himself “America’s greatest puzzle-expert” 1 2 3 4 .... 8 2 5 6 7 8 3 4 7 5 1 6 9 10 11 12 13 14 15 7 8 15-Puzzle Sam Loyd offered $1,000 of his own money to the first person who would solve the following problem: 1 2 3 4 1 2 3 4 5 6 7 8 ? 5 6 7 8 9 10 11 12 9 10 11 12 13 14 15 13 15 14 But no one ever won the prize !! 9 10 Stating a Problem as State Graph a Search Problem � Each state is represented by a S � State space S distinct node � Successor function: 1 2 x ∈ S → SUCCESSORS (x) ∈ 2 S 3 � An arc (or edge) � Initial state s 0 connects a node s � Goal test: to a node s’ if x ∈ S → GOAL? (x) =T or F s’ ∈ SUCCESSORS (s) � Arc cost � The state graph may contain more than one connected component 11 12 2

  3. Solution to the Search Problem Solution to the Search Problem � A solution is a path connecting the initial � A solution is a path connecting the initial node to a goal node (any one) node to a goal node (any one) � The cost of a path is the sum of the arc G costs along this path � An optimal solution is a solution path of minimum cost I � There might be no solution ! G I 13 14 How big is the state space of How big is the state space of the (n 2 -1)-puzzle? the (n 2 -1)-puzzle? � 8-puzzle � ?? states � 8-puzzle � 9! = 362,880 states � 15-puzzle � 16! ~ 2.09 x 10 13 states � 24-puzzle � 25! ~ 10 25 states But only half of these states are reachable from any given state (but you may not know that in advance) 15 16 � Proposition: (N mod 2) is invariant under Permutation Inversions any legal move of the empty tile Wlg, let the goal be: � 1 2 3 4 � Proof: 5 6 7 8 • Any horizontal move of the empty tile 9 10 11 12 leaves N unchanged 13 14 15 • A vertical move of the empty tile changes 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. N by an even increment ( ± 1 ± 1 ± 1 ± 1) 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 1 2 3 4 1 2 3 4 � 5 6 7 5 6 11 7 n 2 = 0 n 3 = 0 n 4 = 0 1 2 3 4 s = s’ = N(s’) = N(s) + 3 + 1 n 5 = 0 n 6 = 0 n 7 = 1 9 10 11 8 9 10 8 5 10 7 8 � N = 7 + 4 n 8 = 1 n 9 = 1 n 10 = 4 9 6 11 12 13 14 15 12 13 14 15 12 n 11 = 0 n 12 = 0n 13 = 0 13 14 15 n 14 = 0n 15 = 0 17 18 3

  4. � Proposition: (N mod 2) is invariant under 15-Puzzle any legal move of the empty tile Sam Loyd offered $1,000 of his own money to the first person who would solve the following problem: � � For a goal state g to be reachable 1 1 1 2 2 2 3 3 3 4 4 4 1 1 2 2 3 3 4 4 from a state s, a necessary condition is 5 5 5 6 6 6 7 7 7 8 8 8 5 5 6 6 7 7 8 8 ? ? that N(g) and N(s) have the same parity 9 9 9 10 10 10 11 11 11 12 12 12 9 9 10 10 11 11 12 12 13 13 13 14 14 14 15 15 15 13 13 15 15 14 14 � It can be shown that this is also a N = 4 N = 5 sufficient condition So, the second state is not reachable from the � � The state graph consists of two first, and Sam Loyd took connected components of equal size no risk with his money ... 19 20 What is the Actual State Space? Searching the State Space a) The set of all states? � It is often not [e.g., a set of 16! states for the 15-puzzle] feasible (or too expensive) to b) The set of all states reachable from a given build a complete initial state? representation [e.g., a set of 16!/2 states for the 15-puzzle] of the state In general, the answer is a) graph [because one does not know in advance which states are reachable] But a fast test determining whether a state is reachable from another is very useful, as search techniques are often inefficient when a problem has no solution 21 22 8-, 15-, 24-Puzzles Searching the State Space 8-puzzle � 362,880 states � Often it is not feasible (or too expensive) to 0.036 sec build a complete representation 15-puzzle � 2.09 x 10 13 states of the state graph ~ 55 hours � A problem solver must construct a 24-puzzle � 10 25 states solution by > 10 9 years exploring a small portion of the graph 100 millions states/sec 23 24 4

  5. Searching the State Space Searching the State Space Search tree Search tree 25 26 Searching the State Space Searching the State Space Search tree Search tree 27 28 Searching the State Space Searching the State Space Search tree Search tree 29 30 5

  6. Simple Problem-Solving-Agent State Space Algorithm � Each state is an abstract representation of a collection of possible worlds sharing some crucial properties and differing on non-important details only 1. I � sense/read initial state 2. GOAL? � select/read goal test E.g.: In assembly planning, a state does not define exactly the absolute position of each part 3. Succ � select/read successor function 4. solution � search (I, GOAL?, Succ) 5. perform(solution) � The state space is discrete. It may be finite, or infinite 31 32 Successor Function Successor Function � It implicitly represents all the actions � It implicitly represents all the actions that are feasible in each state 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 successor function may be quite complex (collision, stability, grasping, ...) 33 34 Path Cost Path Cost � An arc cost is a positive number � An arc cost is a positive number measuring the “cost” of performing the measuring the “cost” of performing the action corresponding to the arc, e.g.: action corresponding to the arc, e.g.: • 1 in the 8-puzzle example • 1 in the 8-puzzle example • expected time to merge two sub-assemblies • expected time to merge two sub-assemblies � We will assume that for any given � We will assume that for any given problem the cost c of an arc always problem the cost c of an arc always verifies: c ≥ ε > 0, where ε is a constant verifies: c ≥ ε > 0, where ε is a constant [This condition guarantees that, if path becomes arbitrarily long, its cost also becomes arbitrarily large] 35 Why is this needed? 36 6

  7. Goal State 1 2 3 � It may be explicitly described: 4 5 6 7 8 1 a a � or partially described: Other examples a a 5 (“a” stands for “any” a a 8 other than 1, 5, and 8) � or defined by a condition, e.g., the sum of every row, of every column, and of every diagonal equals 30 15 1 2 12 4 10 9 7 8 6 5 11 3 13 14 37 38 8-Queens Problem Formulation #1 � States: all arrangements of 0, Place 8 queens in a chessboard so that no two 1, 2, ..., 8 queens on the board queens are in the same row, column, or diagonal. � Initial state: 0 queens 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 queens attacking each other A solution Not a solution � ~ 64 x 63 x ... x 57 ~ 3 x 10 14 states 39 40 Formulation #2 n-Queens Problem � States: all arrangements of k = � A solution is a goal node, not a path to this 0, 1, 2, ..., 8 queens in the k node (typical of design problem) leftmost columns with no two queens attacking each other � Number of states in state space: � Initial state: 0 queens on the • 8-queens � 2,057 board • 100-queens � 10 52 � Successor function: each � But techniques exist to solve n-queens successor is obtained by adding one queen in any square that is problems efficiently for large values of n not attacked by any queen They exploit the fact that there are many already in the board, in the leftmost empty column solutions well distributed in the state space � Arc cost: irrelevant � Goal test: 8 queens are on the � 2,057 states board 41 42 7

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend