Search 2
Search 2
Heuristic Search .
Page 1 of 20
Artificial Intelligence Searching
Best-First Search
Idea: use an evaluation function f(n) that gives an indication of
which node to expand next for each node.
– usually gives an estimate to the goal.
– the node with the lowest value is expanded first.
Page 2 of 20
Artificial Intelligence Searching
f(A)=8.5 A D f(D)=8
f(A)=8.5 A E f(E)=6
… … ...
Page 3 of 20
Artificial Intelligence Searching
Page 4 of 20
Artificial Intelligence Searching
A* Search
Idea: avoid expanding paths that are already expensive.
It finds a minimal cost-path joining the start node and a goal node
for node n.
h*(n)
h*(m) h*(p)
G
Page 5 of 20
Artificial Intelligence Searching
A* Search
[8.5] [6] [3]
4 4
A B C
3
[10] S 5
5
4 G
D 2 E F 3
4
[8] [6] [3]
g (A)=3 g (D)=4
h (A)=8.5 S h (D)=8
3 4 f (D)=4+8
f (A)=3+8.5
A 11.5 12 D
4 5 5 2
C 14 18 E 11+6 B 17 13 F 10+3
3
G 13
Page 6 of 20
Artificial Intelligence Searching
Admissibility of A*
If estimated distance h(n) never exceed the true distance
h*(n) between the current node to goal node, the A*
algorithm will always find a shortest path - This is
known as the admissibility of A* algorithm and h(n) is a
admissible heuristic.
IF
0 =< h (n) =< h*(n), and costs of all arcs are positive
THEN A* is guaranteed to find a solution path of minimal
cost if any solution path exists.
Page 7 of 20
Artificial Intelligence Searching
Optimality of A* (Proof)
Suppose some suboptimal goal G2 has been generated and is in the queue.
Let n be an unexpanded node on a shortest path to an optimal goal G.
Let the cost of Optimal solution be C*
Monotonicity
A heuristic h(n) is monotone if, for every node n and every successors n` of
n, the estimated cost of reaching the goal from n is no greater than the step
cost of getting to n` plus the estimated cost of reaching the goal from n`:
h (n) =< c (n, n`) + h (n`). (triangle inequality)
Page 9 of 20
Artificial Intelligence Searching
Monotonicity
Theorem: If h(n) is monotone, then the values of f(n) along any path
are nondecreasing.
Page 10 of 20
Artificial Intelligence Searching
Page 11 of 20
Artificial Intelligence Searching
Example: 8-puzzle
Fig. shows 8-puzzle start state and goal state. The solution is 26 steps long.
• h1(n) = number of misplaced tiles
• h2(n) = sum of the distance of the tiles from their goal position (not diagonal).
• h1(S) = ? 8
• h2(S) = ? 3+1+2+2+2+3+3+2 = 18
• hn(S) = max{h1(S), h2(S)} = 18
Page 12 of 20
Artificial Intelligence Searching
Relaxing 8-Puzzle
Page 13 of 20
Artificial Intelligence Searching
Advantages:
– they use very little memory. (not required to store all nodes)
– they can find solution even in infinite state space.
– Applicable in finding the best solution according objective function.
Page 14 of 20
Artificial Intelligence Searching
Example: n-queens
Put n queens on an n × n board with no two
queens on the same row, column, or diagonal.
Page 15 of 20
Artificial Intelligence Searching
Hill-climbing Search
“Like climbing Everest in thick fog with amnesia”.
Always expand the node which appears closest to goal (according to the heuristic
function h)
A special case of best-first search algorithm but only one node keeps in memory.
Problem:
depending on
initial state, can
get stuck in
local maxima,
shoulder etc.
By Bishnu Gautam 16
Page 16 of 20
Artificial Intelligence Searching
Genetic algorithms
Page 18 of 20
Artificial Intelligence Searching
Genetic algorithms
Page 20 of 20