State-Space Search
description
Transcript of State-Space Search
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
1
State-Space SearchOutline:
Demonstration with T*State spaces, operators, movesA Puzzle: The “Painted Squares”Combinatorics of the PuzzleRepresentations for pieces, boards, and states.Recursive depth-first searchIterative depth-first search
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
2
Introductory Demo
T* = T-STAR = Transparent STate-space search ARchitecture
Missionaries and Cannibals puzzle
Image processing operator sequences
Blocks-World problem (robot motion planning)
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
3
StatesA state consists of a complete description or snapshot of a situation arrived at during the solution of a problem.
Initial state: the starting position or arrangement, prior to any problem-solving actions being taken.
Goal state: the final arrangement of elements or pieces that satisfies the requirements for a solution to the problem.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
4
State Space
The set of all possible states of the elements or components to be used in solving a problem forms the space of states for the problem. This is known as the state space.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
5
MovesA move is a transition from one state to another.
An operator is a partial function (from states to states) that can be applied to a state to produce a new state, and also, implicitly, a move.
A sequence of moves that leads from the initial state to a goal state constitutes a solution.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
6
Operator Preconditions
Precondition: A necessary property of a state in which a particular operator can be applied.
Example: In checkers, a piece may only move into a square that is vacant.Vacant(place) is a precondition on moving a piece into place.
Example: In Chess, a precondition for moving a rook from square A to square B is that all squares between A and B be vacant. (A and B must also be either in the same row or the same column.)
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
7
Painted SquaresHow many possible arrangements?
Could we simply make a list of all the possible arrangements of pieces, and then select those that are solutions?
It depends on how many there are and how much time we can afford to spend.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
8
The Painted SquaresPuzzle(s)
A Painted Squares Puzzle consists of
1. a board (typically of size 2 by 2), and
2. a set of painted squares. Each square has its sides painted with a texture that is one of: striped, hashed, gray, or boxed.
The objective is to fill the board with the square pieces in such a way that adjacent squares have matching textures where their sides abut one another.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
9
Painted SquaresHow many possible arrangements?
Factors to consider:1. Number of places on the board2. Number of possible textures in the patterns3. Number of rotations of a square (usually 4)4. Whether flipping squares is allowed5. Symmetries of pieces6. Symmetries of the board7. All possible board shapes for a given side (e.g. the
possible “quadraminos”)8. Full boards only, or partially filled boards, too?
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
10
Painted SquaresHow many possible arrangements?
The number can be reduced by enforcing constraints:
1. Do not permit violations of the matching-sides criterion.
2. Require that filled positions on the board be contiguous and always the first k in some ordering.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
11
A Solution Approach for the Painted Squares Puzzle
state: partially filled board.
Initial state: empty board.
Goal state: filled board, in which pieces satisfy all constraints.
Operator: for a given remaining piece, given vacancy on the board, and given orientation, try placing that piece at that position in that orientation.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
12
Recursive Depth-First Method
Current board B empty board.Remaining pieces Q all pieces.Call Solve(B, Q).
Procedure Solve(board B, set of pieces Q)For each piece P in Q, { For each orientation A { Place P in the first available position of B in orientation A, obtaining B’. If B’ is full and meets all constraints, output B’. If B’ is full and does not meet all constraints, return. Call Solve(B’, Q - {P}). }}Return.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
13
The Combinatorial ExplosionSuppose a search process begins with the initial state.
Then it considers each of k possible moves. Each of those may have k possible subsequent moves.
In order to look n steps ahead, the number of states that must be considered is1 + k + k2 + . . . + kn.
For k > 1, this expression grows rapidly as n increases.(The growth is exponential.) This is known as thecombinatorial explosion.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
14
Search Trees
By applying operators from a given state we generate its children or successors.
Successors are descendants as are successors of descendants.
If we ignore possible equivalent states among descendants, we get a tree structure.
Depth-First Search: Examine the nodes of the tree by fully exploring the descendants of a node before trying any siblings of a node.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
15
Graph Search
When descendant nodes can be reached with moves via two or more paths, we are really searching a more general graph than a tree.
Depth-First Search: Examine the nodes of the graph by fully exploring the “descendants” of a node before trying any “siblings” of a node.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
16
Depth-First Search:Iterative Formulation
1. Put the start state on a list OPEN
2. If OPEN is empty, output “DONE” and stop.
3. Select the first state on OPEN and call it S.
Delete S from OPEN.
Put S on CLOSED.
If S is a goal state, output its description
4. Generate the list L of successors of S and delete
from L those states already appearing on CLOSED.
5. Delete any members of OPEN that occur on L.
Insert all members of L at the front of OPEN.
6. Go to Step 2.
CSE 415 -- (c) S. Tanimoto, 2007 Search 1: State Spaces
17
Breadth-First Search:Iterative Formulation
1. Put the start state on a list OPEN
2. If OPEN is empty, output “DONE” and stop.
3. Select the first state on OPEN and call it S.
Delete S from OPEN.
Put S on CLOSED.
If S is a goal state, output its description
4. Generate the list L of successors of S and delete
from L those states already appearing on CLOSED.
5. Delete any members of OPEN that occur on L.
Insert all members of L at the end of OPEN.
6. Go to Step 2.