3. Search Heuristics
A heuristic is:
A function that estimates how close a state is to a goal
Designed for a particular search problem
Examples: Manhattan distance, Euclidean distance for
pathing
10
5
11.2
5. Best-first search
• Idea: use an evaluation function f(n) for each node
• estimate of "desirability"
Expand most desirable unexpanded node
• Implementation:
Order the nodes in fringe in decreasing order of desirability
14. Properties of Best First Search
• Complete? No – can get stuck in loops
• Optimal? No
15. Difference between Uniform Cost Search and
Best First Search
• Uniform-cost search is uninformed search
• It doesn't use any domain knowledge.
• It expands the least cost node, and it does so in every direction because no information
about the goal is provided.
• Best-first search is informed search
• It uses a heuristic function to estimate how close the current state is to the goal.
16. Greedy best-first search
• Evaluation function f(n) = h(n) (heuristic)
= estimate of cost from n to goal
• e.g., hSLD(n) = straight-line distance from n to Bucharest
• Greedy best-first search expands the node that appears to be closest to goal
17. Greedy best-first search example
A 366
B 0
C 160
D 242
E 161
F 176
G 77
H 151
I 226
L 244
M 241
N 234
O 380
P 100
R 193
S 253
T 329
U 80
V 199
Z 374
18. Greedy best-first search example
A 366
B 0
C 160
D 242
E 161
F 176
G 77
H 151
I 226
L 244
M 241
N 234
O 380
P 100
R 193
S 253
T 329
U 80
V 199
Z 374
19. Greedy best-first search example
A 366
B 0
C 160
D 242
E 161
F 176
G 77
H 151
I 226
L 244
M 241
N 234
O 380
P 100
R 193
S 253
T 329
U 80
V 199
Z 374
20. Greedy best-first search example
A 366
B 0
C 160
D 242
E 161
F 176
G 77
H 151
I 226
L 244
M 241
N 234
O 380
P 100
R 193
S 253
T 329
U 80
V 199
Z 374
22. Properties of greedy best-first search
• Complete? No – can get stuck in loops
• Optimal? No
23. A* search
• Idea: 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 from n to goal
• f(n) = estimated total cost of path through n to goal
24. A* search example
A 366
B 0
C 160
D 242
E 161
F 176
G 77
H 151
I 226
L 244
M 241
N 234
O 380
P 100
R 193
S 253
T 329
U 80
V 199
Z 374
25. A* search example
A 366
B 0
C 160
D 242
E 161
F 176
G 77
H 151
I 226
L 244
M 241
N 234
O 380
P 100
R 193
S 253
T 329
U 80
V 199
Z 374
26. A* search example
A 366
B 0
C 160
D 242
E 161
F 176
G 77
H 151
I 226
L 244
M 241
N 234
O 380
P 100
R 193
S 253
T 329
U 80
V 199
Z 374
27. A* search example
A 366
B 0
C 160
D 242
E 161
F 176
G 77
H 151
I 226
L 244
M 241
N 234
O 380
P 100
R 193
S 253
T 329
U 80
V 199
Z 374
28. A* search example
A 366
B 0
C 160
D 242
E 161
F 176
G 77
H 151
I 226
L 244
M 241
N 234
O 380
P 100
R 193
S 253
T 329
U 80
V 199
Z 374
29. A* search example
A 366
B 0
C 160
D 242
E 161
F 176
G 77
H 151
I 226
L 244
M 241
N 234
O 380
P 100
R 193
S 253
T 329
U 80
V 199
Z 374
30. Admissible heuristics
• A heuristic h(n) is admissible if for every node n,
h(n) ≤ h*(n), where h*(n) is the true cost to reach the goal state from n.
• An admissible heuristic never overestimates the cost to reach the goal, i.e., it
is optimistic
• Example: hSLD(n) (never overestimates the actual road distance)
• Theorem: If h(n) is admissible, A* using TREE-SEARCH is optimal
31. Properties of A*
• Complete? Yes (unless there are infinitely many nodes with f ≤ f(G) )
• Space? Keeps all nodes in memory
• Optimal? Yes
Not complete since going for Iasi to Fagaas > the algorithm will never find the solution Iasi-> Vaslui -> Urziceni -> Bucharest -> Fagaras
Conditions for optimality:
Admissibility and consistency
Consistency (monotonocity) is slightly stronger than admissibility
Every consistent heuristic is also admissible.