03_Search
03_Search
G. Lakemeyer
AI/WS-2024/25 2 / 25
Problem Classification
Single-state problem
The vaccuum-world states:
complete world knowledge,
1 2 complete knowledge about the actions
Multiple-state problem
3 4 incomplete world knowledge,
© G. Lakemeyer
AI/WS-2024/25 3 / 25
The vacuum world
© G. Lakemeyer
AI/WS-2024/25 4 / 25
Some Terminology (1)
a given state.
Successor S (x ) returns the set of states reachable by any action
function S: from state x.
Goal test: Tests whether a state is a goal state.
AI/WS-2024/25 5 / 25
Some Terminology (2)
Note: For multiple-state problems, replace state by state set, operators apply
to all elements of the set, and paths connect sets of states.
AI/WS-2024/25 6 / 25
Choosing a State Space
It is an art to choose the right state space. Want to leave out unnecessary
detail (Abstraction)!
Oradea
Neamt
© G. Lakemeyer
Zerind
Iasi
Arad
Sibiu Fagaras
Vaslui
Rimnicu Vilcea
Timisoara
Pitesti
Lugoj
Hirsova
Mehadia Urziceni
Bucharest
Dobreta
Craiova Eforie
Giurgiu
AI/WS-2024/25 7 / 25
8-Puzzle
5 4 5
1 4
2 3
6 1 88 6
8 84
7 3 22 7 6 25
© G. Lakemeyer
AI/WS-2024/25 8 / 25
8-Queens Problem
Representation 1
States: any placement of 0–8 queens.
Operators: place a queen on the board.
© G. Lakemeyer
AI/WS-2024/25 9 / 25
8-Queens Problem
Representation 1
States: any placement of 0–8 queens.
Operators: place a queen on the board.
© G. Lakemeyer
Representation 2
States: 0–8 on board, all safe.
Operators: place a queen starting from left.
Problem: few state (2057), but sometimes deadend (see figure).
AI/WS-2024/25 9 / 25
8-Queens Problem
Representation 1
States: any placement of 0–8 queens.
Operators: place a queen on the board.
© G. Lakemeyer
Representation 2
States: 0–8 on board, all safe.
Operators: place a queen starting from left.
Problem: few state (2057), but sometimes deadend (see figure).
Representation 3
States: 8 queens on board, one per column.
Operators: move a queen under attack in the same column.
AI/WS-2024/25 9 / 25
Vacuum World 1
S S
R R
L R L R
L L
© G. Lakemeyer
S S
S S
R
L R
S S
AI/WS-2024/25 10 / 25
Vacuum World 2
Incomplete Knowledge (multiple-state problem).
L
L R
S
© G. Lakemeyer
S S
L R
R
S S
R L
L R
S S
R
of that state.
Sibiu Timisoara Zerind
Search tree = the tree induced
by expansion. (c) After expanding Sibiu Arad
AI/WS-2024/25 12 / 25
Search Nodes
PARENT-NODE
ACTION = right
© G. Lakemeyer
5 4 Node
DEPTH = 6
PATH-COST = 6
6 1 88
STATE
7 3 22
AI/WS-2024/25 13 / 25
Evaluating Search Strategies
case?
Space Complexity: How much memory is used in the worst case?
Optimality: Does it always find the best solution?
AI/WS-2024/25 14 / 25
Uninformed vs. Informed Search
AI/WS-2024/25 15 / 25
Breadth-First Search
Expand the nodes in the same order in which they are generated.
© G. Lakemeyer
AI/WS-2024/25 16 / 25
Cost of Breadth-First Search
The Cost is very high!. Let b be the max. branching factor, d the depth of a
solution. Then at most
b + b 2 + b 3 + . . . + b d + b d +1 − b
AI/WS-2024/25 17 / 25
Uniform cost search
A modified breadth-first search, which always expands node n with the least
path cost g (n).
S
0
S
A B C
1 5 15
S
© G. Lakemeyer
A
A B C
1 10 5 15
B G
5 5 S
S G 11
15 5
A B C
C 15
G G
11 10
(a) (b)
AI/WS-2024/25 18 / 25
Depth-First Search
AI/WS-2024/25 19 / 25
Depth-limited Search
Perform depth-first search, but only up to a pre-specified depth.
Route planning: For n cities the maximal depth is n − 1.
Oradea
Neamt
Zerind
Iasi
Arad
© G. Lakemeyer
Sibiu Fagaras
Vaslui
Rimnicu Vilcea
Timisoara
Pitesti
Lugoj
Hirsova
Mehadia Urziceni
Bucharest
Dobreta
Craiova Eforie
Giurgiu
for depth 0 to do 1
if DEPTH-LIMITED-SEARCH( problem, depth) succeeds then return its result
end
return failure
© G. Lakemeyer
Limit = 0
Limit = 1
Limit = 2
Limit = 3
.....
AI/WS-2024/25 21 / 25
Iterative Deepening 2
Number of expansions:
Example: b = 10, d = 5
© G. Lakemeyer
Breadth-first search:
10 + 100 + 1000 + 10000 + 100000 + 999990 = 1111110
Iterative deepening:
50 + 400 + 3000 + 20000 + 100000 = 123450
AI/WS-2024/25 22 / 25
Bidirectional Search
Start Goal
© G. Lakemeyer
Assuming that forward and backward search are symmetric, we can ideally
obtain search times of O (2 × bd /2 ) = O (bd /2 ).
AI/WS-2024/25 23 / 25
Problems with Bidirectional Search
We need efficient methods to decide when the two search methods have
met.
Which kind of search method should one use for each direction? (In the
figure it is breadth-first search for both, but that is not always optimal.)
AI/WS-2024/25 24 / 25
Comparison
© G. Lakemeyer
AI/WS-2024/25 25 / 25