Title: Ch' 3 Search
1Ch. 3 Search
- Supplemental slides for CSE 327
- Prof. Jeff Heflin
2Problem Solving Agent Algorithm
- function SIMPLE-PROBLEM-SOLVING-AGENT(percept) r
eturns an action - static seq, an action sequence, initially
empty state, some description of the current
world state goal, a goal, initially
null problem, a problem formulation - state ? UPDATE-STATE(state,percept) if seq is
empty then do goal ? FORMULATE-GOAL(state) pro
blem ?FORMULATE-PROBLEM(state,goal) seq ?
SEARCH(problem) action ? FIRST(seq) seq ?
REST(seq) return action - From Figure 3.1, p. 61
38-puzzle Successor Function
blank-right
blank-down
blank-left
blank-up
48-puzzle Search Tree
initial state
5Tree Search Algorithm
function TREE-SEARCH(problem,fringe) returns a
solution, or failure fringe ? INSERT(MAKE-NODE(IN
ITIAL-STATEproblem,fringe) loop do if
EMPTY?(fringe) then return failure node ?
REMOVE-FIRST(fringe) if GOAL-TESTproblem
applied to STATEnode succeeds then return
SOLUTION(node) fringe ? INSERT-ALL(EXPAND(node,p
roblem),fringe)
Notes 1. fringe argument should be an empty
queue. The type of the queue (e.g., LIFO, FIFO,
etc.) will affect the order of the search 2.
INITIAL-STATEproblem is just syntax for
accessing an objects data (think
problem.initialState in C/Java) From
Figure 3.9, p. 72
6Depth-first Search
1
A
not generated
on fringe
2
7
C
B
in memory
deleted
3
8
6
9
D
E
F
G
4
5
H
I
7Breadth-first Search
1
A
not generated
on fringe
2
3
C
B
in memory
deleted
4
7
6
5
D
E
F
G
8
9
H
I
8Uniform Cost Search
State space
Search tree
1
10
I
G
g(n)0
I
4
B
5
2
C
3
g(n)4
G
B
g(n)10
not generated
4
3
on fringe
G
g(n)9
C
g(n)7
in memory
deleted
9Uninformed Search Summary
10Water Jug Problem
- state ltJ12, J8, J3gt
- initial state lt0, 0, 0gt
- goal test lt1, x, ygt
- x and y can be any value
- path cost
- 1 per solution step?
- 1 per gallon of water moved?
- actions/successor function
- let C1212, C88, C33
- fill-jug-i
- if Ji lt Ci then JiCi
- empty-jug-i-into-jug-j
- if Ji lt Cj Jj thenJj Jj Ji, Ji0
- fill-jug-i-from-jug-j
- if Jj gt Ci Ji thenJj Jj (Ci Ji),
JiCi