Heuristic Search
Heuristic Search
Heuristic Search
HEURISTIC SEARCH
• Heuristics are approximations used to minimize
the searching process. Generally, two categories
of problem use heuristics.
1. Problems for which no exact algorithms are
known and one needs to find an approximation
and satisfying solution. For e.g., computer
vision, speech recognition etc.
2. Problems for which exact solution are known,
but computationally infeasible, e.g., Chess etc.
HEURISTICS SEARCH ALGORITHMS
1. Hill Climbing
2. Constraint Satisfaction
3. Best-First Search
4. A* Algorithm
5. AO* Algorithm
6. Beam Search
HILL CLIMBING
• It is also known as discrete optimization algorithm.
• It uses a simple heuristic function viz., the amount of distance the node is from
the goal.
• Algorithm:-
• Algorithm:-
Step1 : Put the initial node on a list START
Step 2 : If (START is empty) or (START=GOAL) terminate search
Step 3 : Remove the first node from START. Call this node a
Step 4 : If (a==GOAL) terminate search with success.
Step 5 : Else if node a has successor, generate all of them. Find out how far they
are from the goal node. Sort them by the remaining distance from the goal.
Step 6 : Name this list as START 1
Step 7 : Replace START with START 1
Step 8 : Goto Step 2.
A Sample tree for best-first search
D
9
A
E 1 K
Start 3 8
node
B
1
6 F I L
2 Goal
5 0
node
1
G M
5 C 4
2
7
6
H
J
Search Process of Best-First Search
Step Node being Children Available nodes Node Chosen
expanded
5
7
6
H 6
J
A* Algorithm
Step1 : Put the initial node on a list START
Step 2 : If (START is empty) or (START=GOAL) terminate search
Step 3 : Remove the first node from START. Call this node a
Step 4 : If (a==GOAL) terminate search with success.
Step 5 : Else if node a has successor, generate all of them.
Estimate the fitness number of the successor by totaling the
evaluation-function value and the cost-function value. Sort the
list by fitness number.
Step 6 : Name the new list as START 1
Step 7 : Replace START with START 1
Step 8 : Goto Step 2.
AND/OR graphs
• Some problems are best represented as
achieving subgoals, some of which achieved
simultaneously and independently (AND)
• Up to now, only dealt with OR options
Possess TV set
4.
A
(12)
B (6) C (4) D (10)
(10)
G (5) H (7) E (4) F (4)
A Longer path may be better
A
B C D A
G H E F Unsolvable B C D
I J G H E F Unsolvable
I J
Interacting Sub goals
C E
(5) (2)
AO* algorithm
1. Let G be a graph with only starting node INIT.
2. Repeat the followings until INIT is labeled SOLVED or
h(INIT) > FUTILITY
a) Select an unexpanded node from the most promising path
from INIT (call it NODE)
b) Generate successors of NODE. If there are none, set h(NODE)
= FUTILITY (i.e., NODE is unsolvable); otherwise for each
SUCCESSOR that is not an ancestor of NODE do the following:
i. Add SUCCESSSOR to G.
ii. If SUCCESSOR is a terminal node, label it SOLVED and set
h(SUCCESSOR) = 0.
iii. If SUCCESSPR is not a terminal node, compute its h
AO* algorithm (Cont.)
c) Propagate the newly discovered information up the graph
by doing the following: let S be set of SOLVED nodes or
nodes whose h values have been changed and need to
have values propagated back to their parents. Initialize S to
Node. Until S is empty repeat the followings:
(2)
C
An Example
[15] A [13]
4 5
5
(4) B 2 D (8)
(2)
C
An Example
[15] A [8]
4 5
5
(4) B 2 D (3)
(2)
C 2
4
(1) E
(0) G
An Example
[15] A [9]
4 5
5
(4) B 2 D (4)
(2)
C 2
2
4
(3) E
3
(0) G
An Example
[15] A Solved
4 5
5
(4) B 2 D Solved
(2)
C 2
2
4
(3) E
3
(0) G Solved