Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Heuristic Search

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 29

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:-

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 and add
them to the beginning of START
Step 6 : Goto Step 2.
SEARCH TREE FOR HILL CLIMBING
Problems of Hill-Climbing Technique

1. Local maximum : A state that is better than all


its neighbors but not so when compared to
states to states that are farther away.
2. Plateau : A flat area of the search space, in
which all neighbors have the same value.
3. Ridge : This is an area in the path which must
be traversed very carefully because movement
in any direction might maintain one at the
same level or result in fast decent.
SOLUTION
• Backtracking for local maximum. Backtracking
helps in doing what has been done so far and
permits to try a totally different path to attain
the global peak.
• A big jump is the solution to escape from the
plateau.
• Trying different paths at the same time is the
solution for ridges.
Best-First Search
• This search procedure is an evaluation-function variant of breadth-first search.

• 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

1 S (A:3), (B:6), (C:5) (A:3), (B:6), (C:5) (A:3)

2 A (D:9),(E:8) (B:6),(C:5),(D:9),(E:8) (C:5)

3 C (H:7) (B:6),(D:9),(E:8),(H:7) (B:6)

4 B (F:12), (G:14) (D:9), (E:8), (H:7), (F:12), (H:7)


(G:14)

5 H (I:5), (J:6) (D:9), (E:8), (F:12), (G:14), (I:5)


(I:5), (J:6)

6 I (K:1), (L:0), (M:2) (D:9), (E:8), (F:12), (G:14), Search stops as


(J:6), (K:1), (L:0), (M:2) the goal is
reached
A* Algorithm
• In this algorithm, we use the evaluation function and
cost function.
• Evaluation function estimates how far a particular
node is from goal.
• Cost functions indicates how much resources like time,
energy, money etc., have been spent in reaching a
particular node from the start.
• The sum of the evaluation function value and the cost
along the path leading to that state is called fitness
number.
A Sample tree with fitness number used for
A* Search
D
2 9
A
2 1
Start 3 8 E K
node 3 1
2 B 4
1
6 F I 2 L
2 Goal
5 0
3 node
2
3 1
G M
5 C 4 7
2

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

Steal TV Earn Money Buy TV


AND/OR Search (AO*)
• We must examine several nodes
simultaneously when choosing the next
move
A
(9) A
(3) B D (5)
(4) C 38
B C D
17 9 27
E F G H I J
(5) (10) (3) (4) (15) (10)
AND/OR Best-First-Search
• Traverse the graph (from the initial node)
following the best current path.
• Pick one of the unexpanded nodes on that
path and expand it. Add its successors to the
graph and compute f for each of them
• Change the expanded node’s f value to reflect
its successors. Propagate the change up the
graph.
• Reconsider the current best solution and
repeat until a solution is found
AND/OR Best-First-Search example
1. 2.
A A
(5) (9)
(3) B D (5)
(4) C
3. A
(9) D (10)
B (3) C (4)
(10)
E (4) F (4)
AND/OR Best-First-Search example

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:

i. Remove a node from S and call it CURRENT.


ii. Compute the cost of each of the arcs emerging from CURRENT.
Assign minimum cost of its successors as its h.
iii. Mark the best path out of CURRENT by marking the arc that had
the minimum cost in step ii
iv. Mark CURRENT as SOLVED if all of the nodes connected to it
through new labeled arc have been labeled SOLVED
v. If CURRENT has been labeled SOLVED or its cost was just changed,
propagate its new cost back up through the graph. So add all of the
ancestors of CURRENT to S.
An Example
An Example
(8) A
An Example
[12] A [13]
4 5
5
(1) B D (8)

(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

You might also like