SlideShare a Scribd company logo
1 of 70
Download to read offline
Informed Search
Bùi Tiến Lên
2022
Contents
1. Best-first search
2. Greedy best-first search
3. A* search
4. Memory-bounded heuristic search
5. Heuristic functions
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Informed search strategies
Informed (heuristic) search strategies
• Use problem-specific knowledge beyond the definition of the problem itself
• Can find solutions more efficiently than can an uninformed strategy
What is heuristic
• Additional knowledge of the problem is imparted to the search algorithm.
• Heuristic estimates how close a state is to a goal.
3
Best-first search
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Best-first search
• An instance of the general tree/graph search algorithm
• A node is selected for expansion based on an evaluation function, f (n),
which is construed as a cost estimate.
• The node with the lowest evaluation f (n) is expanded first
• The implementation of best-first graph search is identical to that for
uniform-cost search, except for the use of f instead of g to order the
priority queue
• The choice of f determines the search strategy
5
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Best-first search (cont.)
• Most best-first algorithms include as a component of f a heuristic function,
denoted h(n):
h(n) estimated cost of the cheapest path from the state at node n to
a goal state
• h(n) depends only on the state at node n
• Assumption of h
• Arbitrary, nonnegative, problem-specific functions
• Constraint: if n is a goal node, then h(n) = 0
6
Greedy best-first search
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Greedy best-first search
• Try to expand the node that is closest to the goal, on the grounds that this
is likely to lead to a solution quickly.
• Thus, it evaluates nodes by using just the heuristic function
f (n) = h(n)
8
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration: Romania
• Use the straight-line distance heuristic, which we will call hSLD
Table 1: Values of hSLD – straight-line distances to Bucharest.
Urziceni
Neamt
Oradea
Zerind
Timisoara
Mehadia
Sibiu
Pitesti
Rimnicu Vilcea
Vaslui
Bucharest
Giurgiu
Hirsova
Eforie
Arad
Lugoj
Drobeta
Craiova
Fagaras
Iasi
0
160
242
161
77
151
366
244
226
176
241
253
329
80
199
380
234
374
100
193
9
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration: Romania (cont.)
• The initial state
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Rimnicu Vilcea
Vaslui
Iasi
Straight−line distance
to Bucharest
0
160
242
161
77
151
241
366
193
178
253
329
80
199
244
380
226
234
374
98
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Arad
366
10
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration: Romania (cont.)
• After expanding Arad
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Rimnicu Vilcea
Vaslui
Iasi
Straight−line distance
to Bucharest
0
160
242
161
77
151
241
366
193
178
253
329
80
199
244
380
226
234
374
98
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Zerind
Arad
Sibiu Timisoara
253 329 374
11
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration: Romania (cont.)
• After expanding Sibu
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Rimnicu Vilcea
Vaslui
Iasi
Straight−line distance
to Bucharest
0
160
242
161
77
151
241
366
193
178
253
329
80
199
244
380
226
234
374
98
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Rimnicu Vilcea
Zerind
Arad
Sibiu
Arad Fagaras Oradea
Timisoara
329 374
366 176 380 193
12
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration: Romania (cont.)
• After expanding Fagaras
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Rimnicu Vilcea
Vaslui
Iasi
Straight−line distance
to Bucharest
0
160
242
161
77
151
241
366
193
178
253
329
80
199
244
380
226
234
374
98
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Rimnicu Vilcea
Zerind
Arad
Sibiu
Arad Fagaras Oradea
Timisoara
Sibiu Bucharest
329 374
366 380 193
253 0 13
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Properties
• Time: O(bm), but a good heuristic can give dramatic improvement
• Space: O(bm), keeps all nodes in memory
• Complete: No, can get stuck in loops, e.g., find a path from Iasi to Fagaras,
Iasi → Neamt → Iasi → Neamt → ...
• Yes in finite space with repeated-state checking
• Optimal: No
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Drobeta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
14
A* search
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
A* search
• A* search (pronounced A-star search) is the most widely known form of
best-first search
• Ideas
• Use heuristic to guide search, but not only
• Avoid expanding paths that are already expensive
• Evaluation function
f (n) = g(n) + h(n)
• g(n): cost so far to reach n
• h(n): estimated cost of the cheapest path to goal from n
• f (n): estimated cost of the cheapest solution through n
• The algorithm is identical to Uniform-Cost-Search except that A* uses
g + h instead of g
16
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration: Romania
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Rimnicu Vilcea
Vaslui
Iasi
Straight−line distance
to Bucharest
0
160
242
161
77
151
241
366
193
178
253
329
80
199
244
380
226
234
374
98
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Arad
366=0+366
17
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration: Romania (cont.)
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Rimnicu Vilcea
Vaslui
Iasi
Straight−line distance
to Bucharest
0
160
242
161
77
151
241
366
193
178
253
329
80
199
244
380
226
234
374
98
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Zerind
Arad
Sibiu Timisoara
447=118+329 449=75+374
393=140+253
18
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration: Romania (cont.)
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Rimnicu Vilcea
Vaslui
Iasi
Straight−line distance
to Bucharest
0
160
242
161
77
151
241
366
193
178
253
329
80
199
244
380
226
234
374
98
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Zerind
Arad
Sibiu
Arad
Timisoara
Rimnicu Vilcea
Fagaras Oradea
447=118+329 449=75+374
646=280+366 413=220+193
415=239+176 671=291+380
19
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration: Romania (cont.)
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Rimnicu Vilcea
Vaslui
Iasi
Straight−line distance
to Bucharest
0
160
242
161
77
151
241
366
193
178
253
329
80
199
244
380
226
234
374
98
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Zerind
Arad
Sibiu
Arad
Timisoara
Fagaras Oradea
447=118+329 449=75+374
646=280+366 415=239+176
Rimnicu Vilcea
Craiova Pitesti Sibiu
526=366+160 553=300+253
417=317+100
671=291+380
20
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration: Romania (cont.)
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Rimnicu Vilcea
Vaslui
Iasi
Straight−line distance
to Bucharest
0
160
242
161
77
151
241
366
193
178
253
329
80
199
244
380
226
234
374
98
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Zerind
Arad
Sibiu
Arad
Timisoara
Sibiu Bucharest
Rimnicu Vilcea
Fagaras Oradea
Craiova Pitesti Sibiu
447=118+329 449=75+374
646=280+366
591=338+253 450=450+0 526=366+160 553=300+253
417=317+100
671=291+380
21
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration: Romania (cont.)
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Rimnicu Vilcea
Vaslui
Iasi
Straight−line distance
to Bucharest
0
160
242
161
77
151
241
366
193
178
253
329
80
199
244
380
226
234
374
98
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Zerind
Arad
Sibiu
Arad
Timisoara
Sibiu Bucharest
Rimnicu Vilcea
Fagaras Oradea
Craiova Pitesti Sibiu
Bucharest Craiova Rimnicu Vilcea
418=418+0
447=118+329 449=75+374
646=280+366
591=338+253 450=450+0 526=366+160 553=300+253
615=455+160 607=414+193
671=291+380
22
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Properties
• Time Exponential in [relative error in h × length of solution.]
• Space Keeps all nodes in memory
• Complete Yes, unless there are infinitely many nodes with f ≤ f (G)
• Optimal Yes, cannot expand fi+1 until fi is finished
• A* expands all nodes with f (n) < C∗
• A* expands some nodes with f (n) = C∗
• A* expands no nodes with f (n) > C∗
23
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Admissibility and Consistency
Concept 1
h(n) is an admissible heuristic
• if it never overestimates the cost to reach the goal
• or if for every node n, h(n) ≤ h∗(n) (h∗(n) is a the true optimal cost to reach
the goal state from n)
• An example of an admissible heuristic is the straight-line distance hSLD that
we used in getting to Bucharest
24
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Admissibility and Consistency (cont.)
Concept 2
h(n) is an consistent heuristic if for every node n and every
successor n0 of n generated by any action a, the estimated cost of
reaching the goal from n is no greater than the step cost of
getting to n0 plus the estimated cost of reaching the goal from n0
h(n) ≤ c(n, a, n0
) + h(n0
)
n
c(n,a,n’)
h(n’)
h(n)
G
n’
• Consistent heuristic is also admissible
25
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Optimal for A*
• Using tree search algorithm to find a path from S to G
1
1
3
S h = 5
a h = 4
G h = 0
26
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Optimal for A* (cont.)
Theorem 1
The tree-search version of A* is optimal if h(n) is admissible
Proof
Suppose some suboptimal goal G2 has been generated and is in the frontier.
Let n be an unexpanded node on a shortest path to an optimal goal G (graph
separation)
• f (G) = g(G) since h(G) = 0
• f (G2) = g(G2) since h(G2) = 0
• g(G2) > g(G) since G2 is suboptimal
• f (G) > f (n) since h is admissible
• Since f (G2) > f (n), A* will never select G2 for
expansion
G
n
G2
Start
27
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Optimal for A* (cont.)
• Using graph search algorithm to find a path from S to G
1 1
1 2
3
S h = 2
a h =4 b h = 1
c h = 1
G h = 0
28
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Optimal for A* (cont.)
Theorem 2
The graph-search version of A* is optimal if h(n) is consistent
Proof
• if h(n) is consistent, then the values of f (n) along any path are
nondecreasing. Suppose n0 is a successor of n; then g(n0) = g(n) + c(n, a, n0)
for some action a, and we have
f (n0
) = g(n0
) + h(n0
) = g(n) + c(n, a, n) + h(n0
) ≥ g(n) + h(n) = f (n)
• Whenever A* selects a node n for expansion, the optimal path to that node
has been found. Were this not the case, there would have to be another
frontier node n0 on the optimal path from the start node to n; f (n0) < f (n)
⇒ n0 would have been selected first.
29
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Contours
• Search algorithm expands nodes in order of increasing f value
• We can draw contours in the state space, just like the contours in a
topographic map
• Gradually adds “f -contours” of nodes, contour i has all nodes with
f < fi, where fi < fi+1
O
Z
A
T
L
M
D
C
R
F
P
G
B
U
H
E
V
I
N
380
400
420
S
30
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Contours (cont.)
• The bands of uniform-cost search will be “circular” around the start state.
• The bands of A* with more accurate heuristics will stretch toward the goal
state and become more narrowly focused around the optimal path
31
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
The 8-puzzle
• The average solution cost for a randomly generated 8-puzzle instance is
about 22 steps
• The branching factor b is about 3
• 8-puzzle:
• 322 ≈ 3.1 × 1010 states (using an exhaustive tree search)
• 9!/2 = 181, 440 reachable states (using graph search)
• 15-puzzle: around 1013 states
2
Start State Goal State
1
3 4
6 7
5
1
2
3
4
6
7
8
5
8
Figure 1: A typical instance of the 8-puzzle. The optimal solution is 26 steps long.
32
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Admissible heuristics for 8-puzzle
• h1 = the number of misplaced tiles. h1 is an admissible heuristic because it is
clear that any tile that is out of place must be moved at least once
• h2 = the sum of the distances of the tiles from their goal positions. h2 is also
admissible because all any move can do is move one tile one step closer to
the goal
2
Start State Goal State
1
3 4
6 7
5
1
2
3
4
6
7
8
5
8
• h1 = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 8 and
h2 = 3 + 1 + 2 + 2 + 2 + 3 + 3 + 2 = 18
33
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Solve 8 puzzle
• Using h2
2 3
1 4 5
8 7 6
2 3
1 4 5
8 7 6
1 2 3
4 5
8 7 6
2 3
1 4 5
8 7 6
1 2 3
4 5
8 7 6
1 2 3
8 4 5
7 6
1 2 3
8 4
7 6 5
Start Goal
6=0+6
8=1+7 6=1+5
6=2+4
8=2+6
8=2+6
34
Memory-bounded heuristic search
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Memory-bound heuristic search
• In practice, A* usually runs out of space long before it runs out of time
• Idea: try something like DFS, but not forget everything about the branches
we have partially explored
36
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Iterative-deepening A* (IDA*)
• The main difference with IDS
• Cut-off use the f -value (g + h) rather than the depth
• At each iteration, the cutoff value is the smallest f -value of any node
that exceeded the cutoff on the previous iteration
• Avoid the substantial overhead associated with keeping a sorted queue of
nodes.
• Practical for many problems with unit step costs, yet difficult with real valued
costs
37
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Algorithm
function IDA*(problem) returns a solution, or failure
local variables:
f _limit: the current f-COST limit
root: a node
root ← Make-Node(problem.Initial-State)
f _limit ← root.f
loop do
solution, f _limit ← DFS-Contour(problem, root, f _limit)
if solution is non-null then return solution
if f _limit = ∞ then return failure
38
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Algorithm (cont.)
function DFS-Contour(problem,node,f _limit)
returns a solution, or failure and a new f-cost limit
if node.f > f _limit then return null, node.f
if problem.Goal-Test(node.State) then return Solution(node)
successors ← ∅
for each action in problem.Actions(node.State) do
add Child-Node(problem,node,action) into successors
f _next ← ∞
for each s in successors do
solution,f _new ← DFS-Contour(problem, s, f _limit)
if solution is non-null then return solution, f _limit
f _next ← Min(f _next, f _new)
return null, f _next
39
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration
• IDA* search for the shortest route from v0 (start node) to v25 (goal node);
each node has a f value.
1
3 4
4 5 5 5
6 7 7 6 5 7 6 8
11 13 15 14 11 8 12 7 12 6 14 15 7 13 15 9
40
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Recursive best-first search (RBFS)
• Keep track of the f -value of the best alternative path available from any
ancestor of the current node
• backtrack when the current node exceeds f _limit
• As it backtracks, replace f -value of each along the path with the best value
f (n) of its children
41
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Algorithm
function Recursive-Best-First-Search(problem)
returns a solution, or failure
return Rbfs(problem,Make-Node(problem.Initial-State),∞)
function Rbfs(problem,node,f _limit)
returns a solution, or failure and a new f-cost limit
if problem.Goal-Test(node.State) then return Solution(node)
successors ← ∅
for each action in problem.Actions(node.State) do
add Child-Node(problem,node,action) into successors
if successors is empty then return failure,∞
for each s in successors do
# update f with value from previous search, if any
s.f ← Max(s.g + s.h, node.f )
loop do
best ← lowest f-value node in successors
if best.f > f _limit then return failure,best.f
alternative ← the second-lowest f -value among successors
result,best.f ← Rbfs(problem, best, Min(f _limit, alternative))
if result 6= failure then return result
42
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration
• Stages in an RBFS search for the shortest route to Bucharest. The f -limit
value for each recursive call is shown on top of each current node, and every
node is labeled with its f -cost.
Arad
Sibiu Timisoara Zerind
Arad Fagaras Oradea Rimnicu V.
Sibiu Bucharest Craiova Pitesti Sibiu
Bucharest Craiova Rimnicu V.
366
393 447 449
646 415 671 413
591 450 526 417 553
418 615 607
43
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration (cont.)
(a) The path via Rimnicu Vilcea is followed until the current best leaf (Pitesti)
has a value that is worse than the best alternative path (Fagaras).
Arad
Sibiu Timisoara Zerind
Arad Fagaras Oradea Rimnicu V.
Sibiu Bucharest Craiova Pitesti Sibiu
Bucharest Craiova Rimnicu V.
366
393 447 449
646 415 671 413
591 450 526 417 553
418 615 607
44
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration (cont.)
(b) The recursion unwinds and the best leaf value of the forgotten subtree (417)
is backed up to Rimnicu Vilcea; then Fagaras is expanded, revealing a best
leaf value of 450.
Arad
Sibiu Timisoara Zerind
Arad Fagaras Oradea Rimnicu V.
Sibiu Bucharest Craiova Pitesti Sibiu
Bucharest Craiova Rimnicu V.
366
393 447 449
646 415 671 413
591 450 526 417 553
418 615 607
45
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration (cont.)
(c) The recursion unwinds and the best leaf value of the forgotten subtree (450) is
backed up to Fagaras; then Rimnicu Vilcea is expanded. This time, because the
best alternative path (through Timisoara) costs at least 447, the expansion
continues to Bucharest.
Arad
Sibiu Timisoara Zerind
Arad Fagaras Oradea Rimnicu V.
Sibiu Bucharest Craiova Pitesti Sibiu
Bucharest Craiova Rimnicu V.
366
393 447 449
646 415 671 413
591 450 526 417 553
418 615 607
46
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Properties
• Optimality
• Like A*, optimal if h(n) is admissible
• Time complexity
• Difficult to characterize
• Depends on accuracy of h(n) and how often best path changes
• Can end up “switching” back and forth
• Space complexity
• Linear time: O(bd)
• Other extreme to A* - uses too little memory even if more memory were
available
47
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Simplified Memory-bound A* – SMA*
• Similar to A*, but delete the worst node (largest f -value) when memory is
full
• SMA* expands the (newest) best leaf and deletes the (oldest) worst leaf
• SMA* also backs up the value of the forgotten node to its parent.
• If there is a tie (equal f -values), delete the oldest nodes first
• Simplified-MA* finds the optimal reachable solution given the memory
constraint.
• The depth of the shallowest goal node, is less than the memory size
(expressed in nodes)
• Time can still be exponential.
48
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Algorithm
function SMA*(problem) returns a solution, or failure
frontier ← Make-Node(problem.Initial-State)
loop do
if frontier = ∅ then return failure
node ← Pop(frontier)
if problem.Goal-Test(node.State) then return Solution(node)
s ← Next-Successor(node)
if s is not a goal and is at maximum depth then
s.f ← ∞
else
s.f ← Max(s.g + s.h, node.f )
if all of node's successors have been generated then
update node's f-cost and those of its ancestors if necessary
if Successors(node) all in memory then
remove node from frontier
if memory is full then
delete shallowest, highest f-cost node in frontier
remove it from its parent's successor list
insert its parent on frontier if necessary
frontier ← Insert(s, frontier)
49
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration
• Find the lowest-cost goalnode with enough memory
• Max Nodes = 3
• A: start node and D, F, I, J: goal nodes
• Each edge/node is labelled with its step cost/heuristic value
A
B
10
G
8
C
10
D
10
H
8
I
16
E
10
F
10
J
8
K
8
12
5 5
5 2
5 0 0 5
0 0
50
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Illustration (const.)
• Consider only current f-cost
A
B G
C D H I
E F J K
12
15 13
25 18
35 30 24 29
20 24
51
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Learning to search better
• Could an agent learn how to search better? Yes
• Metalevel state space: in which each state captures the internal
(computational) state of a program that is searching in an object-level state
space.
• A metalevel learning algorithm learn from these experiences to avoid
exploring unpromising subtrees
• For example, the map of Romania problem
• The internal state of the A* algorithm is the current search tree.
• Each action in the metalevel state space is a computation step that
alters the internal state; for example, each computation step in A*
expands a leaf node and adds its successors to the tree
52
Heuristic functions
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
The effect of heuristic accuracy on performance
• Effective branching factor b∗ characterize the quality of a heuristic.
• If the total number of nodes generated by A* for a particular problem is N
and the solution depth is d, then b∗ is the branching factor that a uniform
tree of depth d would have to have in order to contain N + 1 nodes
N + 1 = 1 + (b∗
) + (b∗
)2
+ ... + (b∗
)d
• b∗ varies across problem instances, but fairly constant for sufficiently hard
problems
• A well-designed heuristic would have a value of b∗ close to 1 ⇒ fairly large
problems solved at reasonable cost
54
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
The effect of heuristic accuracy on performance (cont.)
Search Cost (nodes generated) Effective Branching Factor
d IDS A*(h1) A*(h2) IDS A*(h1) A*(h2)
2 10 6 6 2.45 1.79 1.79
4 112 13 12 2.87 1.48 1.45
6 680 20 18 2.73 1.34 1.30
8 6384 39 25 2.80 1.33 1.24
10 47127 93 39 2.79 1.38 1.22
12 3644035 227 73 2.78 1.42 1.24
14 – 539 113 – 1.44 1.23
16 – 1301 211 – 1.45 1.25
18 – 3056 363 – 1.46 1.26
20 – 7276 676 – 1.47 1.27
22 – 18094 1219 – 1.48 1.28
24 – 39135 1641 – 1.48 1.26
Table 2: Comparison of the search costs and effective branching factors for the IDS and
A* algorithms with h1, h2. Data are averaged over 100 instances of the 8-puzzle for each
of various solution lengths d.
55
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Dominance and Composite
• If h2(n) ≥ h1(n) for all n (both admissible) then h2 dominates h1 and is
better for search
• A* using h2 will never expand more nodes than A* using h1
• Hence, it is generally better to use a heuristic function with higher values,
provided it is consistent and that the computation time for the heuristic is
not too long.
• Given a collection of admissible heuristics {h1, ..., hm} is available for a
problem and none of them dominates any of the others.
• The composite heuristic function is defined as
h(n) = max{h1(n), . . . , hm(n)}
is consistent and dominates all component heuristics
56
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Relaxed problems
Concept 3
A problem with fewer restrictions on the actions is called a relaxed problem.
• Prove that the angle in a semicircle is a right angle.
A
O
B
C
57
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Generating admissible heuristics from relaxed problems
• The state-space graph of the relaxed problem is a supergraph of the original
state space because the removal of restrictions creates added edges in the
graph.
S
a
b
c
d
G
Figure 2: Original problem state-space
S
a
b
c
d
G
Figure 3: Relaxed problem state-space
58
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Generating admissible heuristics from relaxed problems
(cont.)
• Hence, the cost of an optimal solution to a relaxed problem is an admissible
heuristic for the original problem.
• Furthermore, because the derived heuristic is an exact cost for the relaxed
problem, it must obey the triangle inequality and is therefore consistent.
59
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Generating admissible heuristics from relaxed problems
(cont.)
Original problem of 8 puzzle
• A tile can move from square A to square B if A is horizontally or vertically
adjacent to B and B is blank
We can generate three relaxed problems by removing one or both of the conditions
Relaxed problems
1. A tile can move from square A to square B if A is adjacent to B → h2
2. A tile can move from square A to square B if B is blank → exercise
3. A tile can move from square A to square B → h1
60
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Generating admissible heuristics from subproblems
• Admissible heuristics can also be derived from the solution cost of a
subproblem of a given problem
• The cost of the optimal solution of this subproblem ≤ the cost of the
original problem (lower bound).
• More accurate than Manhattan distance in some cases
Start State Goal State
1
2
3
4
6
8
5
2
1
3 6
7 8
5
4
Figure 4: A subproblem of the 8-puzzle instance. The task is to get tiles 1, 2, 3, and 4
into their correct positions, without worrying about what happens to the other tiles.
61
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Goal fixed?
• Assume that the goal state G is fixed
• Using Uniform-Cost-Search to find the shortest path from G to the
other states
• The final g values can be considered as optimal h∗ values
62
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Goal fixed? (cont.)
9
3
6
8
5 4
1
8
17
21
4
4 G
b
d
h
c
e
f
9
3
6
8
5 4
1
8
17
21
4
4 G g = 0
b g = 7
d g = 3
h g = 6
c g = 4
e g = 9
f g = 26
9
3
6
8
5 4
1
8
17
21
4
4 G h = 0
b h = 7
d h = 3
h h = 6
c h = 4
e h = 9
f h = 26
63
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Pattern databases
• Pattern databases (PDB) where store the exact solution costs for every
possible subproblem instance
• E.g., every possible configuration of the four tiles and the blank
• The database itself is constructed by searching back from the goal and
recording the cost of each new pattern encountered; the expense of this
search is amortized over many subsequent problem instances
• The complete heuristic is constructed using the patterns in the databases
64
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Computing the Heuristic
1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
5 10 14 7
8 3 6 1
15 12
2 11 4
9
13
• 31 moves needed to solve red tiles
• 22 moves need to solve blue tiles
• Overall heuristic is maximum of 31 = max(31, 22) moves
65
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Disjoint pattern databases
• Limitation of traditional PDB: Take max → diminish returns on additional
PDBs
• Disjoint pattern databases: Count only moves of the pattern tiles, ignoring
non-pattern moves.
• If no tile belongs to more than one pattern, add their heuristic values.
66
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Computing the Heuristic
1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
5 10 14 7
8 3 6 1
15 12
2 11 4
9
13
• 20 moves needed to solve red tiles
• 25 moves needed to solve blue tiles
• Overall heuristic is sum, or 45 = 20 + 25 moves
67
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Performance
• 15 Puzzle
• 1000 × speedup vs. Manhattan distance
• IDA* with the two DBs (the 7-tile database contains 58 million entries
and the 8-tile database contains 519 million entries) solves 15-puzzles
optimally in 30 milliseconds
• 24 Puzzle
• 12 million × speedup vs. Manhattan distance
• IDA* can solve random instances in 2 days.
• Requires 4 DBs (each DB has 128 million entries)
• Without PDBs: 65,000 years
68
Best-first
search
Greedy
best-first search
A* search
Memory-
bounded
heuristic search
Heuristic
functions
Learning heuristics from experience
• Experience means solving a lot of instances of a problem.
• E.g., solving lots of 8-puzzles
• Each optimal solution to a problem instance provides examples from which
h(n) can be learned
• Learning algorithms
• Neural nets
• Decision trees
• Inductive learning
69
References
Goodfellow, I., Bengio, Y., and Courville, A. (2016).
Deep learning.
MIT press.
Lê, B. and Tô, V. (2014).
Cở sở trí tuệ nhân tạo.
Nhà xuất bản Khoa học và Kỹ thuật.
Nguyen, T. (2018).
Artificial intelligence slides.
Technical report, HCMC University of Sciences.
Russell, S. and Norvig, P. (2016).
Artificial intelligence: a modern approach.
Pearson Education Limited.

More Related Content

Similar to lect03-informed-searchhhhhhhhhhhhhhhhh.pdf

lecture 6 AI - A star.pdf
lecture 6 AI - A star.pdflecture 6 AI - A star.pdf
lecture 6 AI - A star.pdfHassanElalfy4
 
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdfAI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdfAsst.prof M.Gokilavani
 
Artificial intelligence(05)
Artificial intelligence(05)Artificial intelligence(05)
Artificial intelligence(05)Nazir Ahmed
 
Jarrar: Informed Search
Jarrar: Informed Search  Jarrar: Informed Search
Jarrar: Informed Search Mustafa Jarrar
 
09_Informed_Search.ppt
09_Informed_Search.ppt09_Informed_Search.ppt
09_Informed_Search.pptrnyau
 
Presentacion nro 1 redes y comunicaciones de datos
Presentacion nro 1 redes y comunicaciones de datosPresentacion nro 1 redes y comunicaciones de datos
Presentacion nro 1 redes y comunicaciones de datosLuisGabrielVasquez
 
Searching is the universal technique of problem solving in Artificial Intelli...
Searching is the universal technique of problem solving in Artificial Intelli...Searching is the universal technique of problem solving in Artificial Intelli...
Searching is the universal technique of problem solving in Artificial Intelli...KarpagaPriya10
 
Informed search (heuristics)
Informed search (heuristics)Informed search (heuristics)
Informed search (heuristics)Bablu Shofi
 
heuristic search
heuristic searchheuristic search
heuristic searchNajib Khan
 
Informed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptxInformed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptxKirti Verma
 

Similar to lect03-informed-searchhhhhhhhhhhhhhhhh.pdf (20)

lecture 6 AI - A star.pdf
lecture 6 AI - A star.pdflecture 6 AI - A star.pdf
lecture 6 AI - A star.pdf
 
3.informed search
3.informed search3.informed search
3.informed search
 
Searching
SearchingSearching
Searching
 
M4 heuristics
M4 heuristicsM4 heuristics
M4 heuristics
 
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdfAI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
AI3391 ARTIFICIAL INTELLIGENCE UNIT II notes.pdf
 
Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5
 
Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptx
 
abhishek ppt.pptx
abhishek ppt.pptxabhishek ppt.pptx
abhishek ppt.pptx
 
A Star Search
A Star SearchA Star Search
A Star Search
 
A Star Search
A Star SearchA Star Search
A Star Search
 
Artificial intelligence(05)
Artificial intelligence(05)Artificial intelligence(05)
Artificial intelligence(05)
 
Jarrar: Informed Search
Jarrar: Informed Search  Jarrar: Informed Search
Jarrar: Informed Search
 
09_Informed_Search.ppt
09_Informed_Search.ppt09_Informed_Search.ppt
09_Informed_Search.ppt
 
m4-heuristics.ppt
m4-heuristics.pptm4-heuristics.ppt
m4-heuristics.ppt
 
Presentacion nro 1 redes y comunicaciones de datos
Presentacion nro 1 redes y comunicaciones de datosPresentacion nro 1 redes y comunicaciones de datos
Presentacion nro 1 redes y comunicaciones de datos
 
Searching is the universal technique of problem solving in Artificial Intelli...
Searching is the universal technique of problem solving in Artificial Intelli...Searching is the universal technique of problem solving in Artificial Intelli...
Searching is the universal technique of problem solving in Artificial Intelli...
 
Informed search (heuristics)
Informed search (heuristics)Informed search (heuristics)
Informed search (heuristics)
 
heuristic search
heuristic searchheuristic search
heuristic search
 
Chap11 slides
Chap11 slidesChap11 slides
Chap11 slides
 
Informed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptxInformed Search Techniques new kirti L 8.pptx
Informed Search Techniques new kirti L 8.pptx
 

Recently uploaded

Displacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second DerivativesDisplacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second Derivatives23050636
 
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTS
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTSDBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTS
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTSSnehalVinod
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabiaahmedjiabur940
 
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxronsairoathenadugay
 
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...ThinkInnovation
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshareraiaryan448
 
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证pwgnohujw
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareGraham Ware
 
Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024patrickdtherriault
 
DAA Assignment Solution.pdf is the best1
DAA Assignment Solution.pdf is the best1DAA Assignment Solution.pdf is the best1
DAA Assignment Solution.pdf is the best1sinhaabhiyanshu
 
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...Payal Garg #K09
 
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...yulianti213969
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...Elaine Werffeli
 
Client Researchhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pptx
Client Researchhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pptxClient Researchhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pptx
Client Researchhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pptxStephen266013
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRajesh Mondal
 
Solution manual for managerial accounting 8th edition by john wild ken shaw b...
Solution manual for managerial accounting 8th edition by john wild ken shaw b...Solution manual for managerial accounting 8th edition by john wild ken shaw b...
Solution manual for managerial accounting 8th edition by john wild ken shaw b...rightmanforbloodline
 
bams-3rd-case-presentation-scabies-12-05-2020.pptx
bams-3rd-case-presentation-scabies-12-05-2020.pptxbams-3rd-case-presentation-scabies-12-05-2020.pptx
bams-3rd-case-presentation-scabies-12-05-2020.pptxJocylDuran
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证acoha1
 
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...ssuserf63bd7
 
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...Klinik Aborsi
 

Recently uploaded (20)

Displacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second DerivativesDisplacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second Derivatives
 
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTS
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTSDBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTS
DBMS UNIT 5 46 CONTAINS NOTES FOR THE STUDENTS
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
 
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
 
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshare
 
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham Ware
 
Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024
 
DAA Assignment Solution.pdf is the best1
DAA Assignment Solution.pdf is the best1DAA Assignment Solution.pdf is the best1
DAA Assignment Solution.pdf is the best1
 
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...
Unsatisfied Bhabhi ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Gi...
 
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
Client Researchhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pptx
Client Researchhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pptxClient Researchhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pptx
Client Researchhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pptx
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for Research
 
Solution manual for managerial accounting 8th edition by john wild ken shaw b...
Solution manual for managerial accounting 8th edition by john wild ken shaw b...Solution manual for managerial accounting 8th edition by john wild ken shaw b...
Solution manual for managerial accounting 8th edition by john wild ken shaw b...
 
bams-3rd-case-presentation-scabies-12-05-2020.pptx
bams-3rd-case-presentation-scabies-12-05-2020.pptxbams-3rd-case-presentation-scabies-12-05-2020.pptx
bams-3rd-case-presentation-scabies-12-05-2020.pptx
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
 
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
 
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
 

lect03-informed-searchhhhhhhhhhhhhhhhh.pdf

  • 2. Contents 1. Best-first search 2. Greedy best-first search 3. A* search 4. Memory-bounded heuristic search 5. Heuristic functions
  • 3. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Informed search strategies Informed (heuristic) search strategies • Use problem-specific knowledge beyond the definition of the problem itself • Can find solutions more efficiently than can an uninformed strategy What is heuristic • Additional knowledge of the problem is imparted to the search algorithm. • Heuristic estimates how close a state is to a goal. 3
  • 5. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Best-first search • An instance of the general tree/graph search algorithm • A node is selected for expansion based on an evaluation function, f (n), which is construed as a cost estimate. • The node with the lowest evaluation f (n) is expanded first • The implementation of best-first graph search is identical to that for uniform-cost search, except for the use of f instead of g to order the priority queue • The choice of f determines the search strategy 5
  • 6. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Best-first search (cont.) • Most best-first algorithms include as a component of f a heuristic function, denoted h(n): h(n) estimated cost of the cheapest path from the state at node n to a goal state • h(n) depends only on the state at node n • Assumption of h • Arbitrary, nonnegative, problem-specific functions • Constraint: if n is a goal node, then h(n) = 0 6
  • 8. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Greedy best-first search • Try to expand the node that is closest to the goal, on the grounds that this is likely to lead to a solution quickly. • Thus, it evaluates nodes by using just the heuristic function f (n) = h(n) 8
  • 9. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration: Romania • Use the straight-line distance heuristic, which we will call hSLD Table 1: Values of hSLD – straight-line distances to Bucharest. Urziceni Neamt Oradea Zerind Timisoara Mehadia Sibiu Pitesti Rimnicu Vilcea Vaslui Bucharest Giurgiu Hirsova Eforie Arad Lugoj Drobeta Craiova Fagaras Iasi 0 160 242 161 77 151 366 244 226 176 241 253 329 80 199 380 234 374 100 193 9
  • 10. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration: Romania (cont.) • The initial state Bucharest Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Rimnicu Vilcea Vaslui Iasi Straight−line distance to Bucharest 0 160 242 161 77 151 241 366 193 178 253 329 80 199 244 380 226 234 374 98 Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Arad 366 10
  • 11. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration: Romania (cont.) • After expanding Arad Bucharest Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Rimnicu Vilcea Vaslui Iasi Straight−line distance to Bucharest 0 160 242 161 77 151 241 366 193 178 253 329 80 199 244 380 226 234 374 98 Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Zerind Arad Sibiu Timisoara 253 329 374 11
  • 12. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration: Romania (cont.) • After expanding Sibu Bucharest Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Rimnicu Vilcea Vaslui Iasi Straight−line distance to Bucharest 0 160 242 161 77 151 241 366 193 178 253 329 80 199 244 380 226 234 374 98 Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Rimnicu Vilcea Zerind Arad Sibiu Arad Fagaras Oradea Timisoara 329 374 366 176 380 193 12
  • 13. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration: Romania (cont.) • After expanding Fagaras Bucharest Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Rimnicu Vilcea Vaslui Iasi Straight−line distance to Bucharest 0 160 242 161 77 151 241 366 193 178 253 329 80 199 244 380 226 234 374 98 Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Rimnicu Vilcea Zerind Arad Sibiu Arad Fagaras Oradea Timisoara Sibiu Bucharest 329 374 366 380 193 253 0 13
  • 14. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Properties • Time: O(bm), but a good heuristic can give dramatic improvement • Space: O(bm), keeps all nodes in memory • Complete: No, can get stuck in loops, e.g., find a path from Iasi to Fagaras, Iasi → Neamt → Iasi → Neamt → ... • Yes in finite space with repeated-state checking • Optimal: No Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Drobeta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 14
  • 16. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions A* search • A* search (pronounced A-star search) is the most widely known form of best-first search • Ideas • Use heuristic to guide search, but not only • Avoid expanding paths that are already expensive • Evaluation function f (n) = g(n) + h(n) • g(n): cost so far to reach n • h(n): estimated cost of the cheapest path to goal from n • f (n): estimated cost of the cheapest solution through n • The algorithm is identical to Uniform-Cost-Search except that A* uses g + h instead of g 16
  • 17. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration: Romania Bucharest Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Rimnicu Vilcea Vaslui Iasi Straight−line distance to Bucharest 0 160 242 161 77 151 241 366 193 178 253 329 80 199 244 380 226 234 374 98 Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Arad 366=0+366 17
  • 18. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration: Romania (cont.) Bucharest Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Rimnicu Vilcea Vaslui Iasi Straight−line distance to Bucharest 0 160 242 161 77 151 241 366 193 178 253 329 80 199 244 380 226 234 374 98 Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Zerind Arad Sibiu Timisoara 447=118+329 449=75+374 393=140+253 18
  • 19. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration: Romania (cont.) Bucharest Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Rimnicu Vilcea Vaslui Iasi Straight−line distance to Bucharest 0 160 242 161 77 151 241 366 193 178 253 329 80 199 244 380 226 234 374 98 Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Zerind Arad Sibiu Arad Timisoara Rimnicu Vilcea Fagaras Oradea 447=118+329 449=75+374 646=280+366 413=220+193 415=239+176 671=291+380 19
  • 20. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration: Romania (cont.) Bucharest Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Rimnicu Vilcea Vaslui Iasi Straight−line distance to Bucharest 0 160 242 161 77 151 241 366 193 178 253 329 80 199 244 380 226 234 374 98 Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Zerind Arad Sibiu Arad Timisoara Fagaras Oradea 447=118+329 449=75+374 646=280+366 415=239+176 Rimnicu Vilcea Craiova Pitesti Sibiu 526=366+160 553=300+253 417=317+100 671=291+380 20
  • 21. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration: Romania (cont.) Bucharest Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Rimnicu Vilcea Vaslui Iasi Straight−line distance to Bucharest 0 160 242 161 77 151 241 366 193 178 253 329 80 199 244 380 226 234 374 98 Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Zerind Arad Sibiu Arad Timisoara Sibiu Bucharest Rimnicu Vilcea Fagaras Oradea Craiova Pitesti Sibiu 447=118+329 449=75+374 646=280+366 591=338+253 450=450+0 526=366+160 553=300+253 417=317+100 671=291+380 21
  • 22. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration: Romania (cont.) Bucharest Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Rimnicu Vilcea Vaslui Iasi Straight−line distance to Bucharest 0 160 242 161 77 151 241 366 193 178 253 329 80 199 244 380 226 234 374 98 Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Zerind Arad Sibiu Arad Timisoara Sibiu Bucharest Rimnicu Vilcea Fagaras Oradea Craiova Pitesti Sibiu Bucharest Craiova Rimnicu Vilcea 418=418+0 447=118+329 449=75+374 646=280+366 591=338+253 450=450+0 526=366+160 553=300+253 615=455+160 607=414+193 671=291+380 22
  • 23. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Properties • Time Exponential in [relative error in h × length of solution.] • Space Keeps all nodes in memory • Complete Yes, unless there are infinitely many nodes with f ≤ f (G) • Optimal Yes, cannot expand fi+1 until fi is finished • A* expands all nodes with f (n) < C∗ • A* expands some nodes with f (n) = C∗ • A* expands no nodes with f (n) > C∗ 23
  • 24. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Admissibility and Consistency Concept 1 h(n) is an admissible heuristic • if it never overestimates the cost to reach the goal • or if for every node n, h(n) ≤ h∗(n) (h∗(n) is a the true optimal cost to reach the goal state from n) • An example of an admissible heuristic is the straight-line distance hSLD that we used in getting to Bucharest 24
  • 25. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Admissibility and Consistency (cont.) Concept 2 h(n) is an consistent heuristic if for every node n and every successor n0 of n generated by any action a, the estimated cost of reaching the goal from n is no greater than the step cost of getting to n0 plus the estimated cost of reaching the goal from n0 h(n) ≤ c(n, a, n0 ) + h(n0 ) n c(n,a,n’) h(n’) h(n) G n’ • Consistent heuristic is also admissible 25
  • 26. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Optimal for A* • Using tree search algorithm to find a path from S to G 1 1 3 S h = 5 a h = 4 G h = 0 26
  • 27. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Optimal for A* (cont.) Theorem 1 The tree-search version of A* is optimal if h(n) is admissible Proof Suppose some suboptimal goal G2 has been generated and is in the frontier. Let n be an unexpanded node on a shortest path to an optimal goal G (graph separation) • f (G) = g(G) since h(G) = 0 • f (G2) = g(G2) since h(G2) = 0 • g(G2) > g(G) since G2 is suboptimal • f (G) > f (n) since h is admissible • Since f (G2) > f (n), A* will never select G2 for expansion G n G2 Start 27
  • 28. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Optimal for A* (cont.) • Using graph search algorithm to find a path from S to G 1 1 1 2 3 S h = 2 a h =4 b h = 1 c h = 1 G h = 0 28
  • 29. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Optimal for A* (cont.) Theorem 2 The graph-search version of A* is optimal if h(n) is consistent Proof • if h(n) is consistent, then the values of f (n) along any path are nondecreasing. Suppose n0 is a successor of n; then g(n0) = g(n) + c(n, a, n0) for some action a, and we have f (n0 ) = g(n0 ) + h(n0 ) = g(n) + c(n, a, n) + h(n0 ) ≥ g(n) + h(n) = f (n) • Whenever A* selects a node n for expansion, the optimal path to that node has been found. Were this not the case, there would have to be another frontier node n0 on the optimal path from the start node to n; f (n0) < f (n) ⇒ n0 would have been selected first. 29
  • 30. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Contours • Search algorithm expands nodes in order of increasing f value • We can draw contours in the state space, just like the contours in a topographic map • Gradually adds “f -contours” of nodes, contour i has all nodes with f < fi, where fi < fi+1 O Z A T L M D C R F P G B U H E V I N 380 400 420 S 30
  • 31. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Contours (cont.) • The bands of uniform-cost search will be “circular” around the start state. • The bands of A* with more accurate heuristics will stretch toward the goal state and become more narrowly focused around the optimal path 31
  • 32. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions The 8-puzzle • The average solution cost for a randomly generated 8-puzzle instance is about 22 steps • The branching factor b is about 3 • 8-puzzle: • 322 ≈ 3.1 × 1010 states (using an exhaustive tree search) • 9!/2 = 181, 440 reachable states (using graph search) • 15-puzzle: around 1013 states 2 Start State Goal State 1 3 4 6 7 5 1 2 3 4 6 7 8 5 8 Figure 1: A typical instance of the 8-puzzle. The optimal solution is 26 steps long. 32
  • 33. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Admissible heuristics for 8-puzzle • h1 = the number of misplaced tiles. h1 is an admissible heuristic because it is clear that any tile that is out of place must be moved at least once • h2 = the sum of the distances of the tiles from their goal positions. h2 is also admissible because all any move can do is move one tile one step closer to the goal 2 Start State Goal State 1 3 4 6 7 5 1 2 3 4 6 7 8 5 8 • h1 = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 8 and h2 = 3 + 1 + 2 + 2 + 2 + 3 + 3 + 2 = 18 33
  • 34. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Solve 8 puzzle • Using h2 2 3 1 4 5 8 7 6 2 3 1 4 5 8 7 6 1 2 3 4 5 8 7 6 2 3 1 4 5 8 7 6 1 2 3 4 5 8 7 6 1 2 3 8 4 5 7 6 1 2 3 8 4 7 6 5 Start Goal 6=0+6 8=1+7 6=1+5 6=2+4 8=2+6 8=2+6 34
  • 36. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Memory-bound heuristic search • In practice, A* usually runs out of space long before it runs out of time • Idea: try something like DFS, but not forget everything about the branches we have partially explored 36
  • 37. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Iterative-deepening A* (IDA*) • The main difference with IDS • Cut-off use the f -value (g + h) rather than the depth • At each iteration, the cutoff value is the smallest f -value of any node that exceeded the cutoff on the previous iteration • Avoid the substantial overhead associated with keeping a sorted queue of nodes. • Practical for many problems with unit step costs, yet difficult with real valued costs 37
  • 38. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Algorithm function IDA*(problem) returns a solution, or failure local variables: f _limit: the current f-COST limit root: a node root ← Make-Node(problem.Initial-State) f _limit ← root.f loop do solution, f _limit ← DFS-Contour(problem, root, f _limit) if solution is non-null then return solution if f _limit = ∞ then return failure 38
  • 39. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Algorithm (cont.) function DFS-Contour(problem,node,f _limit) returns a solution, or failure and a new f-cost limit if node.f > f _limit then return null, node.f if problem.Goal-Test(node.State) then return Solution(node) successors ← ∅ for each action in problem.Actions(node.State) do add Child-Node(problem,node,action) into successors f _next ← ∞ for each s in successors do solution,f _new ← DFS-Contour(problem, s, f _limit) if solution is non-null then return solution, f _limit f _next ← Min(f _next, f _new) return null, f _next 39
  • 40. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration • IDA* search for the shortest route from v0 (start node) to v25 (goal node); each node has a f value. 1 3 4 4 5 5 5 6 7 7 6 5 7 6 8 11 13 15 14 11 8 12 7 12 6 14 15 7 13 15 9 40
  • 41. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Recursive best-first search (RBFS) • Keep track of the f -value of the best alternative path available from any ancestor of the current node • backtrack when the current node exceeds f _limit • As it backtracks, replace f -value of each along the path with the best value f (n) of its children 41
  • 42. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Algorithm function Recursive-Best-First-Search(problem) returns a solution, or failure return Rbfs(problem,Make-Node(problem.Initial-State),∞) function Rbfs(problem,node,f _limit) returns a solution, or failure and a new f-cost limit if problem.Goal-Test(node.State) then return Solution(node) successors ← ∅ for each action in problem.Actions(node.State) do add Child-Node(problem,node,action) into successors if successors is empty then return failure,∞ for each s in successors do # update f with value from previous search, if any s.f ← Max(s.g + s.h, node.f ) loop do best ← lowest f-value node in successors if best.f > f _limit then return failure,best.f alternative ← the second-lowest f -value among successors result,best.f ← Rbfs(problem, best, Min(f _limit, alternative)) if result 6= failure then return result 42
  • 43. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration • Stages in an RBFS search for the shortest route to Bucharest. The f -limit value for each recursive call is shown on top of each current node, and every node is labeled with its f -cost. Arad Sibiu Timisoara Zerind Arad Fagaras Oradea Rimnicu V. Sibiu Bucharest Craiova Pitesti Sibiu Bucharest Craiova Rimnicu V. 366 393 447 449 646 415 671 413 591 450 526 417 553 418 615 607 43
  • 44. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration (cont.) (a) The path via Rimnicu Vilcea is followed until the current best leaf (Pitesti) has a value that is worse than the best alternative path (Fagaras). Arad Sibiu Timisoara Zerind Arad Fagaras Oradea Rimnicu V. Sibiu Bucharest Craiova Pitesti Sibiu Bucharest Craiova Rimnicu V. 366 393 447 449 646 415 671 413 591 450 526 417 553 418 615 607 44
  • 45. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration (cont.) (b) The recursion unwinds and the best leaf value of the forgotten subtree (417) is backed up to Rimnicu Vilcea; then Fagaras is expanded, revealing a best leaf value of 450. Arad Sibiu Timisoara Zerind Arad Fagaras Oradea Rimnicu V. Sibiu Bucharest Craiova Pitesti Sibiu Bucharest Craiova Rimnicu V. 366 393 447 449 646 415 671 413 591 450 526 417 553 418 615 607 45
  • 46. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration (cont.) (c) The recursion unwinds and the best leaf value of the forgotten subtree (450) is backed up to Fagaras; then Rimnicu Vilcea is expanded. This time, because the best alternative path (through Timisoara) costs at least 447, the expansion continues to Bucharest. Arad Sibiu Timisoara Zerind Arad Fagaras Oradea Rimnicu V. Sibiu Bucharest Craiova Pitesti Sibiu Bucharest Craiova Rimnicu V. 366 393 447 449 646 415 671 413 591 450 526 417 553 418 615 607 46
  • 47. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Properties • Optimality • Like A*, optimal if h(n) is admissible • Time complexity • Difficult to characterize • Depends on accuracy of h(n) and how often best path changes • Can end up “switching” back and forth • Space complexity • Linear time: O(bd) • Other extreme to A* - uses too little memory even if more memory were available 47
  • 48. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Simplified Memory-bound A* – SMA* • Similar to A*, but delete the worst node (largest f -value) when memory is full • SMA* expands the (newest) best leaf and deletes the (oldest) worst leaf • SMA* also backs up the value of the forgotten node to its parent. • If there is a tie (equal f -values), delete the oldest nodes first • Simplified-MA* finds the optimal reachable solution given the memory constraint. • The depth of the shallowest goal node, is less than the memory size (expressed in nodes) • Time can still be exponential. 48
  • 49. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Algorithm function SMA*(problem) returns a solution, or failure frontier ← Make-Node(problem.Initial-State) loop do if frontier = ∅ then return failure node ← Pop(frontier) if problem.Goal-Test(node.State) then return Solution(node) s ← Next-Successor(node) if s is not a goal and is at maximum depth then s.f ← ∞ else s.f ← Max(s.g + s.h, node.f ) if all of node's successors have been generated then update node's f-cost and those of its ancestors if necessary if Successors(node) all in memory then remove node from frontier if memory is full then delete shallowest, highest f-cost node in frontier remove it from its parent's successor list insert its parent on frontier if necessary frontier ← Insert(s, frontier) 49
  • 50. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration • Find the lowest-cost goalnode with enough memory • Max Nodes = 3 • A: start node and D, F, I, J: goal nodes • Each edge/node is labelled with its step cost/heuristic value A B 10 G 8 C 10 D 10 H 8 I 16 E 10 F 10 J 8 K 8 12 5 5 5 2 5 0 0 5 0 0 50
  • 51. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Illustration (const.) • Consider only current f-cost A B G C D H I E F J K 12 15 13 25 18 35 30 24 29 20 24 51
  • 52. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Learning to search better • Could an agent learn how to search better? Yes • Metalevel state space: in which each state captures the internal (computational) state of a program that is searching in an object-level state space. • A metalevel learning algorithm learn from these experiences to avoid exploring unpromising subtrees • For example, the map of Romania problem • The internal state of the A* algorithm is the current search tree. • Each action in the metalevel state space is a computation step that alters the internal state; for example, each computation step in A* expands a leaf node and adds its successors to the tree 52
  • 54. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions The effect of heuristic accuracy on performance • Effective branching factor b∗ characterize the quality of a heuristic. • If the total number of nodes generated by A* for a particular problem is N and the solution depth is d, then b∗ is the branching factor that a uniform tree of depth d would have to have in order to contain N + 1 nodes N + 1 = 1 + (b∗ ) + (b∗ )2 + ... + (b∗ )d • b∗ varies across problem instances, but fairly constant for sufficiently hard problems • A well-designed heuristic would have a value of b∗ close to 1 ⇒ fairly large problems solved at reasonable cost 54
  • 55. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions The effect of heuristic accuracy on performance (cont.) Search Cost (nodes generated) Effective Branching Factor d IDS A*(h1) A*(h2) IDS A*(h1) A*(h2) 2 10 6 6 2.45 1.79 1.79 4 112 13 12 2.87 1.48 1.45 6 680 20 18 2.73 1.34 1.30 8 6384 39 25 2.80 1.33 1.24 10 47127 93 39 2.79 1.38 1.22 12 3644035 227 73 2.78 1.42 1.24 14 – 539 113 – 1.44 1.23 16 – 1301 211 – 1.45 1.25 18 – 3056 363 – 1.46 1.26 20 – 7276 676 – 1.47 1.27 22 – 18094 1219 – 1.48 1.28 24 – 39135 1641 – 1.48 1.26 Table 2: Comparison of the search costs and effective branching factors for the IDS and A* algorithms with h1, h2. Data are averaged over 100 instances of the 8-puzzle for each of various solution lengths d. 55
  • 56. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Dominance and Composite • If h2(n) ≥ h1(n) for all n (both admissible) then h2 dominates h1 and is better for search • A* using h2 will never expand more nodes than A* using h1 • Hence, it is generally better to use a heuristic function with higher values, provided it is consistent and that the computation time for the heuristic is not too long. • Given a collection of admissible heuristics {h1, ..., hm} is available for a problem and none of them dominates any of the others. • The composite heuristic function is defined as h(n) = max{h1(n), . . . , hm(n)} is consistent and dominates all component heuristics 56
  • 57. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Relaxed problems Concept 3 A problem with fewer restrictions on the actions is called a relaxed problem. • Prove that the angle in a semicircle is a right angle. A O B C 57
  • 58. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Generating admissible heuristics from relaxed problems • The state-space graph of the relaxed problem is a supergraph of the original state space because the removal of restrictions creates added edges in the graph. S a b c d G Figure 2: Original problem state-space S a b c d G Figure 3: Relaxed problem state-space 58
  • 59. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Generating admissible heuristics from relaxed problems (cont.) • Hence, the cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem. • Furthermore, because the derived heuristic is an exact cost for the relaxed problem, it must obey the triangle inequality and is therefore consistent. 59
  • 60. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Generating admissible heuristics from relaxed problems (cont.) Original problem of 8 puzzle • A tile can move from square A to square B if A is horizontally or vertically adjacent to B and B is blank We can generate three relaxed problems by removing one or both of the conditions Relaxed problems 1. A tile can move from square A to square B if A is adjacent to B → h2 2. A tile can move from square A to square B if B is blank → exercise 3. A tile can move from square A to square B → h1 60
  • 61. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Generating admissible heuristics from subproblems • Admissible heuristics can also be derived from the solution cost of a subproblem of a given problem • The cost of the optimal solution of this subproblem ≤ the cost of the original problem (lower bound). • More accurate than Manhattan distance in some cases Start State Goal State 1 2 3 4 6 8 5 2 1 3 6 7 8 5 4 Figure 4: A subproblem of the 8-puzzle instance. The task is to get tiles 1, 2, 3, and 4 into their correct positions, without worrying about what happens to the other tiles. 61
  • 62. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Goal fixed? • Assume that the goal state G is fixed • Using Uniform-Cost-Search to find the shortest path from G to the other states • The final g values can be considered as optimal h∗ values 62
  • 63. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Goal fixed? (cont.) 9 3 6 8 5 4 1 8 17 21 4 4 G b d h c e f 9 3 6 8 5 4 1 8 17 21 4 4 G g = 0 b g = 7 d g = 3 h g = 6 c g = 4 e g = 9 f g = 26 9 3 6 8 5 4 1 8 17 21 4 4 G h = 0 b h = 7 d h = 3 h h = 6 c h = 4 e h = 9 f h = 26 63
  • 64. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Pattern databases • Pattern databases (PDB) where store the exact solution costs for every possible subproblem instance • E.g., every possible configuration of the four tiles and the blank • The database itself is constructed by searching back from the goal and recording the cost of each new pattern encountered; the expense of this search is amortized over many subsequent problem instances • The complete heuristic is constructed using the patterns in the databases 64
  • 65. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Computing the Heuristic 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 5 10 14 7 8 3 6 1 15 12 2 11 4 9 13 • 31 moves needed to solve red tiles • 22 moves need to solve blue tiles • Overall heuristic is maximum of 31 = max(31, 22) moves 65
  • 66. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Disjoint pattern databases • Limitation of traditional PDB: Take max → diminish returns on additional PDBs • Disjoint pattern databases: Count only moves of the pattern tiles, ignoring non-pattern moves. • If no tile belongs to more than one pattern, add their heuristic values. 66
  • 67. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Computing the Heuristic 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 5 10 14 7 8 3 6 1 15 12 2 11 4 9 13 • 20 moves needed to solve red tiles • 25 moves needed to solve blue tiles • Overall heuristic is sum, or 45 = 20 + 25 moves 67
  • 68. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Performance • 15 Puzzle • 1000 × speedup vs. Manhattan distance • IDA* with the two DBs (the 7-tile database contains 58 million entries and the 8-tile database contains 519 million entries) solves 15-puzzles optimally in 30 milliseconds • 24 Puzzle • 12 million × speedup vs. Manhattan distance • IDA* can solve random instances in 2 days. • Requires 4 DBs (each DB has 128 million entries) • Without PDBs: 65,000 years 68
  • 69. Best-first search Greedy best-first search A* search Memory- bounded heuristic search Heuristic functions Learning heuristics from experience • Experience means solving a lot of instances of a problem. • E.g., solving lots of 8-puzzles • Each optimal solution to a problem instance provides examples from which h(n) can be learned • Learning algorithms • Neural nets • Decision trees • Inductive learning 69
  • 70. References Goodfellow, I., Bengio, Y., and Courville, A. (2016). Deep learning. MIT press. Lê, B. and Tô, V. (2014). Cở sở trí tuệ nhân tạo. Nhà xuất bản Khoa học và Kỹ thuật. Nguyen, T. (2018). Artificial intelligence slides. Technical report, HCMC University of Sciences. Russell, S. and Norvig, P. (2016). Artificial intelligence: a modern approach. Pearson Education Limited.