State Space Search
State Space Search
5
3 DISK, 3 PEG TOWER of HANOI STATE SPACE
6
STATES, SPACES, SOLUTIONS, SEARCH
• States
– Full / Perfect Information and Partial Information States
• State Transformation Rules
– Deterministic Outcomes
– Non-Deterministic / Probabilistic Outcomes
• State Spaces As Generalized Games
– Single Player: OR Graphs
– Multi-Player: And / Or, Adversarial, Probabilistic Graphs
• Solutions
– Paths
– Sub-graphs
– Expected Outcomes
• Costs
• Sizes
• Domain Knowledge
• Algorithms for Heuristic Search
7
OR-Graph: TRAVELLING SALESPERSON PROBLEM
A
100
120
200 190
B C
75
80
110
75 90
D E
50
8
OR-Graph: TRAVELLING SALESPERSON PROBLEM
A <A>,0
100
120
<AB>,100 <AC>,120 <AD>,200 <AE>190
200 190
B C
75
80 <ABC>,175 <ABD>,175 <ABE>,180
110
75 90
10
AND/OR GRAPHS: ADVERSARIAL
11
AND/OR GRAPHS: COMPOSITIONAL / ADVERSARIAL / PROBABILISTIC
12
COMPOSITIONAL AND/OR GRAPHS – MATRIX CHAIN MULTIPLICATION
(M1 X (M2 X (M3 X M4))) = ((M1 x M2) X (M3 X M4)) = (((M1 x M2) X M3) X M4) =
(M1 X (M2 X M3) ) X M4)
BUT THE NUMBER OF MULTIPLICATIONS TO GET THE ANSWER DIFFER !!
(M1 X M2) X M3 = 10*30*5 for P = (M1 X M2) and 10*5*60 for P X M3. Total = 4500
M1 X (M2 X M3) = 30*5*60 for Q = (M2 X M3) and 10*30*60 for M1 X Q. Total = 27000
13
COMPOSITIONAL AND/OR GRAPHS: MATRIX CHAIN
OR NODE (Min) MULTIPLICATION
(M1 :M4)
AND NODE (Fn)
(M1 :M1) (M2 :M4) (M1 :M2) (M3 :M4) (M1 :M3) (M4 :M4)
(M2 :M2) (M3 :M4) (M2 :M3) (M1 :M2) (M3 :M3)
(M1 X (M2 X (M3 X M4))) = ((M1 x M2) X (M3 X M4)) = (((M1 x M2) X M3) X M4) =
(M1 X (M2 X M3) ) X M4)
14
SEARCHING IMPLICIT GRAPHS
Given the start state the <A>,0
SEARCH Algorithm will
create successors based on
the State Transformation <AB>,100 <AC>,120 <AD>,200 <AE>190
Rules and make part of the
Graph EXPLICIT.
It will EXPAND the Explicit
graph INTELLGENTLY to <ABC>,175 <ABD>,175 <ABE>,180
rapidly search for a solution
without exploring the entire
Implicit Graph or State Space
For OR Graphs, the solution <ABCD>,285 <ABCE>,265 <ABDC>,285 <ABDE>,225
is a PATH from start to Goal.
Cost is usually sum of the
edge costs on the path, <ABCDE>,335 <ABCED>,315 <ABDCE>,375 <ABDEC>,315
though it could be something
based on the problem
<ABCDEA>,525 <ABCEDA>,515 <ABDCEA>,565 <ABDECA>,435
15
SEARCHING IMPLICIT GRAPHS
For And/OR Graphs, the Solution
is an AND Subgraph rooted at
the Start and each leaf is a Goal
Node.
The Cost of OR Node is usually a
Min or Max.
The Cost at the AND Node
depends on the type of Node
(Compositional, Adversarial,
Probabilistic).
For Adversarial two player
games, Max / Min is used at AND
Node (reverse of Or Node)
16
SEARCHING IMPLICIT GRAPHS
The various Search Algorithms include
• BASIC Algorithms: Depth-First (DFS), Breadth-first
(BFS), Iterative Deepening (IDS)
• COST-based Algorithms: Depth-First Branch-and-
Bound, Best First Search, Best-First Iterative Deepening
• Widely Used Algorithms: A* and IDA* (Or Graphs), AO*
(And/Or Graphs), Alpha-beta Pruning (Game-Trees)
17
BASIC ALGORITHMS in OR GRAPHS: DFS
1. [Initialize] Initially the OPEN List contains the
Start Node s. CLOSED List is Empty.
2. [Select] Select the first Node n on the OPEN List.
If OPEN is empty, Terminate
3. [Goal Test] If n is Goal, then decide on
Termination or Continuation / Cost Updation
4. [Expand]
a) Generate the successors n_1, n_2, …. n_k, of
node n, based on the State Transformation
Rules
b) Put n in LIST CLOSED
c) For each n_i, not already in OPEN or CLOSED
List, put n_i in the FRONT of OPEN List
d) For each n_i already in OPEN or CLOSED
decide based on cost of the paths
5. [Continue] Go to Step 2 18
BASIC ALGORITHMS in OR GRAPHS: IDS
1. [Initialize] Initially the OPEN List contains the Start
Node s. CLOSED List is Empty.
2. [Select] Select the first Node n on the OPEN List. If
OPEN is empty, Terminate
3. [Goal Test] If n is Goal, then decide on Termination or
Continuation / Cost Updation
4. [Expand]
a) Generate the successors n_1, n_2, …. n_k, of node
n, based on the State Transformation Rules
b) Put n in LIST CLOSED
c) For each n_i, not already in OPEN or CLOSED List,
put n_i in the FRONT of OPEN List
d) For each n_i already in OPEN or CLOSED decide
based on cost of the paths
3. [Continue] Go to Step 2
21
EXAMPLE: SEARCHING A STATE SPACE GRAPH
A START DEPTH-FIRST SEARCH:
1. OPEN ={A}, CLOSED = {}
2. OPEN = {B,C,D}, CLOSED = {A}
3. OPEN = {E,F,G,C,D}, CLOSED = (A,B}
B C D 4. OPEN = {I,J,F,G,C,D}, CLOSED = {A,B,E}
5. Goal Node I Found. Can Terminate with
Path from A to I or may Continue for
more Goal nodes if minimum length or
E F G H cost is a criteria
22
EXAMPLE: SEARCHING A STATE SPACE GRAPH
A START ITERATIVE DEEPENING SEARCH:
1. PERFORM DFS TILL LENGTH 1. NO
SOLUTION FOUND
2. PERFORM DFS TILL LEVEL 2. GOAL
B C D NODE H REACHED.
3. Can Terminate with Path from A to H.
This is guaranteed to be the minimum
length path.
E F G H
IDS GUARANTEES SHORTEST LENGTH
GOAL PATH TO GOAL
10
12 5
B C D
2
6 7 6
8 7 5 4
9 1 13
E F G H
14 3
18 GOAL
18
I J
GOA GOAL
L
25
MODIFYING BASIC ALGORITHMS TO INCORPORATE COSTS
1. [Initialize] Initially the OPEN List contains the Start Node s. CLOSED List is Empty.
2. [Select] Select the first Node n on the OPEN List. If OPEN is empty, Terminate
3. [Goal Test] If n is Goal, then decide on Termination or Continuation / Cost Updation
4. [Expand]
a) Generate the successors n_1, n_2, …. n_k, of node n, based on the State
Transformation Rules
b) Put n in LIST CLOSED
c) For each n_i, not already in OPEN or CLOSED List, put n_i in the FRONT (for
DFS) / END (for BFS) of OPEN List
d) For each n_i already in OPEN or CLOSED decide based on cost of the paths
5. [Continue] Go to Step 2
Algorithm IDS Performs DFS Level by Level Iteratively (DFS (1), DFS (2), ……. and so
on)
26
NEXT: SEARCHING STATE SPACE GRAPHS WITH EDGE COSTS
A START
• COST ORDERED SEARCH:
10 • DFBB
12
5 • Best First Search,
B C D • Best First IDS
2 • Use of HEURISTIC Estimates:
6 7 6
8 7 5 4 Algorithm A* (Or Graphs), AO*
1 13 (And/Or Graphs)
9 F G H
E
14 • PROPERTIES
18 3 GOAL • SOLUTION GUARANTEES
18
• MEMORY REQUIREMENTS
I J
GOA GOAL
L
27
Thank you