Académique Documents
Professionnel Documents
Culture Documents
• Problem-solving agents
• Problem types
• Problem formulation
Solving problems by searching • Example problems
• Basic search algorithms
Chapter 3
3 4
Problem-solving agent Problem types
• Sensorless, start in
{1,2,3,4,5,6,7,8} e.g.,
Right goes to {2,4,6,8}
Solution?
7 8
Example: vacuum world Example: vacuum world
• Contingency • Contingency
- Nondeterministic: Suck may - Nondeterministic: Suck may
dirty a clean carpet dirty a clean carpet
- Partially observable: location, dirt at current location - Partially observable: location, dirt at current location.
- Percept: [L, Clean], i.e., start in #5 or #7 - Percept: [L, Clean], i.e., start in #5 or #7
Solution? Solution? [Right, if dirt then Suck]
9 10
11 12
Vacuum world state space graph Vacuum world state space graph
15 16
Example: robotic assembly Example: 8-queens problem
• States?
• States? real-valued coordinates of robot joint angles and parts of the
object to be assembled • Actions?
• Actions? continuous motions of robot joints • Goal test?
• Goal test? complete assembly • Path cost?
• Path cost? time to execute
17 18
Incremental formulation
Incremental formulation vs. complete-state formulation
• States? any arrangement of 0 to 8 queens on the board
• States?
• Initial state? no queens
• Actions?
• Actions? add queen in empty square
• Goal test?
• Goal test? 8 queens on board and none attacked
• Path cost?
• Path cost? none
64*63*…*57 approx. 1.8 x 1014 possible sequences to investigate
19 20
Example: 8-queens problem Basic search algorithms
Incremental formulation (alternative) - Nodes and leafs generated through successor function.
21 22
function TREE-SEARCH(problem, strategy) return a solution or failure function TREE-SEARCH(problem, strategy) return a solution or failure
Initialize search tree to the initial state of the problem Initialize search tree to the initial state of the problem
do do
if no candidates for expansion then return failure if no candidates for expansion then return failure
choose leaf node for expansion according to strategy choose leaf node for expansion according to strategy
if node contains goal state then return solution if node contains goal state then return solution
else expand the node and add resulting nodes to the search tree else expand the node and add resulting nodes to the search tree
enddo enddo
23 24
Simple tree search example State space vs. search tree
25 26
function TREE-SEARCH(problem,fringe) return a solution or failure function EXPAND(node,problem) return a set of nodes
fringe ← INSERT(MAKE-NODE(INITIAL-STATE[problem]), fringe) successors ← the empty set
for each <action, result> in SUCCESSOR-FN[problem](STATE[node]) do
s ← a new NODE
loop do
STATE[s] ← result
if EMPTY?(fringe) then return failure
node ← REMOVE-FIRST(fringe)
PARENT-NODE[s] ← node
ACTION[s] ← action
if GOAL-TEST[problem] applied to STATE[node] succeeds
27 28
Search strategies Uninformed search strategies
29 30
31 32
Breadth-first search Breadth-first search
33 34
• Two lessons:
- Memory requirements are a bigger problem than its execution time
- Uniformed search only applicable for small instances
-> Exploit knowledge about the problem
35 36
Uniform-cost search Depth-first search
37 38
39 40
Depth-first search Depth-first search
41 42
43 44
Depth-first search Depth-first search
45 46
47 48
Depth-first search Properties of depth-first search
49 50
51 52
Iterative deepening search Iterative deepening search
for depth ← 0 to ∞ do
Combines benefits of DF- and BF-search result ← DEPTH-LIMITED_SEARCH(problem, depth)
if result ≠ cuttoff then return result
53 54
55 56
Iterative deepening search l =2 Iterative deepening search l =3
57 58
• For b = 10, d = 5, Num. comparison for b=10 and d=5 solution at far right
- NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111 NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456
- NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456 NBFS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 + 999,990= 1,111,101
+b ≠b
The predecessor of each node should be efficiently computable
- Motivation: d /2 d /2 d
b - When actions are easily reversible
Number of goal states does not explode
Check whether the node belongs to the other fringe before expansion
Complete and optimal if both searches are BF
Space complexity is the most significant weakness
61 62
Criterion Breadth- Uniform- Depth- Depth- Iterative Bidirectio • Failure to detect repeated states can turn a linear problem into an
First cost First limited deepe nal exponential one!
ning search
Comp YESa YESa,b NO YES, YESa YESa,d
lete? if l ≥ d
Time bd+1 b1+floor(C*/e) bm bl bd bd/2
a … if d is finite
b … if step costs >= e
c … if step costs are equal
d … if both directions use BFS 63 64
Graph search algorithm Graph search, evaluation
65 66
Summary
• Iterative deepening search uses only linear space and not much
more time than other uninformed algorithms
67