Iterative Deepening and IDA : Alan Mackworth UBC CS 322 - Search 6 January 21, 2013
Iterative Deepening and IDA : Alan Mackworth UBC CS 322 - Search 6 January 21, 2013
Alan Mackworth
Textbook § 3.7.3
Lecture Overview
• Iterative Deepening
Slide 2
Search with Costs
• Sometimes there are costs associated with arcs.
Def.: The cost of a path is the sum of the costs of its arcs
k
cost ( n0 ,…, nk ) = ∑ cost( ni −1 , ni )
i =1
3
Lowest-Cost-First Search (LCFS)
• Expands the path with the lowest cost on the frontier.
4
Heuristic search
Def.:
A search heuristic h(n) is an estimate of the cost of the optimal
(cheapest) path from node n to a goal node.
Estimate: h(n1)
n1
n2 Estimate: h(n2)
n3
Estimate: h(n3)
5
Best-First Search (LCFS)
• Expands the path with the lowest h value on the frontier.
6
A*
• Expands the path with the lowest cost + h value on the
frontier
7
Admissibility of a heuristic
Def.:
Let c(n) denote the cost of the optimal path from node n to any
goal node. A search heuristic h(n) is called
admissible if h(n) ≤ c(n) for all nodes n, i.e. if for all nodes it
is an underestimate of the cost to any goal.
8
Admissibility of A*
• A* is complete (finds a solution, if one exists) and
optimal (finds the optimal path to a goal) if:
9
Why is A* admissible: complete
If there is a solution, A* finds it:
- fmin:= cost of optimal solution path s (unknown but finite)
12
Learning Goals for last week, continued
• Apply basic properties of search algorithms:
– completeness, optimality, time and space complexity
Complete Optimal Time Space
DFS N N O(bm) O(mb)
(Y if finite & no
cycles)
BFS Y Y O(bm) O(bm)
LCFS Y Y m)
O(b O(bm)
(when arc costs available) Costs > 0 Costs ≥ 0
Best First N N m)
O(b O(bm)
(when h available)
A* Y Y m)
O(b O(bm)
(when arc costs and h Costs > 0
Costs ≥ 0
available) h admissible h admissible
13
Lecture Overview
• Iterative Deepening
14
Iterative Deepening DFS (IDS): Motivation
Want low space complexity but completeness and optimality
Key Idea: re-compute elements of the frontier
rather than saving them
Complete Optimal Time Space
DFS N N O(bm) O(mb)
(Y if finite & no
cycles)
BFS Y Y O(bm) O(bm)
LCFS Y Y m)
O(b O(bm)
(when arc costs available) Costs > 0 Costs ≥ 0
Best First N N m)
O(b O(bm)
(when h available)
A* Y Y m)
O(b O(bm)
(when arc costs and h Costs > 0
Costs ≥ 0
available) h admissible h admissible
15
Iterative Deepening DFS (IDS) in a Nutshell
• Use DFS to look for solutions at depth 1, then 2, then 3, etc
– For depth D, ignore any paths with longer length
– Depth-bounded depth-first search
depth = 1
depth = 2
depth = 3
...
(Time) Complexity of IDS
• That sounds wasteful!
• Let’s analyze the time complexity
• For a solution at depth m with branching factor b
• Complete? Yes No
• Optimal? Yes No
– Proof by contradiction
19
Search methods so far
Complete Optimal Time Space
DFS N N O(bm) O(mb)
(Y if finite & no
cycles)
BFS Y Y O(bm) O(bm)
IDS Y Y O(bm) O(mb)
LCFS Y Y m)
O(b O(bm)
(when arc costs available) Costs > 0 Costs >=0
Best First N N m)
O(b O(bm)
(when h available)
A* Y Y m)
O(b O(bm)
(when arc costs and h Costs > 0
Costs >=0
available) h admissible h admissible
20
(Heuristic) Iterative Deepening: IDA*
21
Analysis of Iterative Deepening A* (IDA*)
• Complete and optimal? Same conditions as A*
– h is admissible
– all arc costs > ε > 0
– finite branching factor
m)
• Time complexity: O(b
• Space complexity:
22
Search methods so far
Complete Optimal Time Space
DFS N N O(bm) O(mb)
(Y if no cycles)
BFS Y Y O(bm) O(bm)
IDS Y Y O(bm) O(mb)
LCFS Y Y m)
O(b O(bm)
(when arc costs available) Costs > 0 Costs >=0
Best First N N m)
O(b O(bm)
(when h available)
A* Y Y m)
O(b O(bm)
(when arc costs and h Costs > 0
Costs >=0
available) h admissible h admissible
IDA* Y (same cond. Y m)
O(b O(mb)
as A*)
Learning Goals for today’s class
• Define/read/write/trace/debug different search algorithms
- New: Iterative Deepening,
Iterative Deepening A*
• Apply basic properties of search algorithms:
– completeness, optimality, time and space complexity
Announcements:
– Practice exercises on course home page
• Heuristic search
• Please use these! (Only takes 5 min. if you understood things…)
– Assignment 1 is out: see Connect.
24