Professional Documents
Culture Documents
Informed Search CHP 4 Hamid IBIT
Informed Search CHP 4 Hamid IBIT
Informed Search
Outline
Best-first search
Greedy best-first search
A* search
Heuristics
Memory Bounded A* Search
SEARCH TECHNIQUES
Search techniques
Blind Heuristic
Breadth Hill
Depth first A*
first climbing
Search search
Search Search
( DFS )
( BFS )
Best-First Greedy
Search Search
Informed Search
A search strategy which searches the most promising branches of the
state-space first can:
find a solution more quickly,
find solutions even when there is limited time available,
often find a better solution, since more profitable parts of the state-
space can be examined, while ignoring the unprofitable parts.
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
HEURISTIC SEARCH ALGORITHM
Example: in route planning the estimate of the cost of the cheapest path might be the straight line
distance between two cities
Example Heuristics
Straight-line distance Manhattan Distance
The distance between two locations on a The smallest number of
map can be known without knowing how vertical and horizontal moves
they are linked by roads (i.e. the absolute needed to get to the goal
path to the goal). (ignoring obstacles).
E A B C Manhattan
D Distance
Problem S E F A=4
Space E=2
C G H X
A
S =3
B 2= E A =4
D 1= H B =3
Search
E C 2= G C =2
Tree
B F =1
A X
EXAMPLE
Heuristic function for 8-tile puzzle
1 . The number of states out of place.
[the state that has fewest tiles out of place is probably closer to the desired goal
and would be best to examine next]
State = l
F(l) = 4 G(n) = 4
State = n
G(n) = 5
State = m
F(m) = 4 F(n) = 6
Goal
2 8 3 1 2 3
1 6 4 8 4
7 5 7 6 5
Open and closed as they appear after the 3rd iteration of heuristic search
BEST FIRST SEARCH
Definition
• Is another more informed heuristic algorithm.
• Best-first search in its most general form is a simple heuristic search
algorithm.
• “Heuristic” here refers to a general problem-solving rule or set of rules
that do not guarantee the best solution or even any solution, but serves
as a useful guide for problem-solving.
• Best-first search is a graph-based search algorithm, meaning that the
search space can be represented as a series of nodes connected by
paths.
BEST FIRST SEARCH (cont.)
How it works
• The name “best-first” refers to the method of exploring the node with the
best “score” first.
• An evaluation function is used to assign a score to each candidate node.
The algorithm maintains two lists, one containing a list of candidates yet to
explore (OPEN), and one containing a list of already visited nodes (CLOSED).
States in OPEN are ordered according to some heuristic estimate of their
“closeness” to a goal. This ordered OPEN list is referred to as priority queue.`
How it works
• Since all unvisited successor nodes of every visited node are included in
the OPEN list, the algorithm is not restricted to only exploring successor
nodes of the most recently visited node. In other words, the algorithm
always chooses the best of all unvisited nodes that have been graphed,
rather than being restricted to only a small subset, such as immediate
neighbors. Other search strategies, such as depth-first and breadth-first,
have this restriction.
A 8 1
E
K
6
13 0
B F
L
S
14
5
5 G
I 1
C
M
H
7
J
OPEN={ S} 6
CLOSED={}
10
D
2
A 8 1
E
K
6
13 0
B F
L
S
14
5
5 G
I 1
C
M
H
7
J
OPEN={ A(2),C(5),B(6)} 6
CLOSED={S}
10
D
2
A 8 1
E
K
6
13 0
B F
L
S
14
5
5 G
I 1
C
M
H
7
J
A 8 1
E
K
6
13 0
B F
L
S
14
5
5 G
I 1
C
M
H
7
J
A 8 1
E
K
6
13 0
B F
L
S
14
5
5 G
I 1
C
M
H
7
J
A 8 1
E
K
6
13 0
B F
L
S
14
5
5 G
I 1
C
M
H
7
J
A 8 1
E
K
6
13 0
B F
L
S
14
5
5 G
I 1
C
M
H
7
J
A 8 1
E
K
6
13 0
B F
L
S
14
5
5 G
I 1
C
M
H
7
J
A 8 1
E
K
6
13 0
B F
L
S
14
5
5 G
I 1
C
M
H
7
J
State = l
F(l) = 5 G(n) = 4
State = n
G(n) = 5
State = m
F(m) = 5 F(n) = 7
Goal
10
4 D
2
A 8
2 18
E
6 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5
5 G 2
5
I 1
C
7 M
4 1
H
7 1 J
6
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5
5 G 2
5
I 1
C
7 M
4 1
H
7 1 J
OPEN={S}
CLOSED={}
6
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5
5 G 2
5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={A(5+2=7}, B(6+2=8), C(5+5=10)}
CLOSED={S}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5
5 G 2
5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={B(8), C(10),E(7+8=15), D(9+10=19)}
CLOSED={S,A}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5
5 G 2
5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={C(10),E(15), F(5+13=18),G(4+14=18), D(19)}
CLOSED={S,A,B}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5
5 G 2
5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={E(15), F(18),G(18), D(19),H(5+7+7=19)}
CLOSED={S,A,B,C}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5
5 G 2
5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={K(5+2+2+1=10), F(18),G(18), D(19),H(19)}
CLOSED={S,A,B,C,E}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5 G 2
5 5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={ F(18),G(18), D(19),H(19), I(21+5=26)}
CLOSED={S,A,B,C,E,K}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5 G 2
5 5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={ I(2+3+8+5=18),(F(18),G(18), D(19),H(19), I(26)}
CLOSED={S,A,B,C,E,K,F}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5 G 2
5 5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={ M(2+3+8+1+1=15),F(18),G(18), D(19),H(19),L(21+0=21) ,I(26)}
CLOSED={S,A,B,C,E,K,F,I}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5 G 2
5 5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={ L(2+3+8+1+2+0=16), F(18),G(18), D(19),H(19),L(21) ,I(26)}
CLOSED={S,A,B,C,E,K,F,I,M}
10
4 D
2
A 8
2 18
E 2
5 6 K
13 1
3 0
B F
2 1 L
S 8
1 2 8
2 14
5 G 2
5 5
I 1
C
7 M
4 1
H
7 1 J
6
OPEN={F(18),G(18), D(19),H(19),L(21) ,I(26)} GOAL FOUND!!
CLOSED={S,A,B,C,E,K,F,I,M,L}
Romania with step costs in km, Shortest Path Example
A* Shortest Path Example
56
A* Shortest Path Example
57
A* Shortest Path Example
A* Shortest Path Example
A* Shortest Path Example
A* Shortest Path Example
A* search example
A * search example
A * search example tracing
A* search
Properties of A*
Complete?? Yes, unless there are infinitely many
nodes with f f(G)
Time?? Exponential in
[relative error in h x length of solution.]
Space?? Keeps all nodes in memory
Optimal?? Yes – cannot expand f i+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*
A*: Summary
A* uses both backward costs and (estimates of) forward costs
start
goal
Properties of greedy best-first search
Complete?
No – can get stuck in loops
Optimal?
No
Properties of greedy best-first search
Complete?
No – can get stuck in loops
Optimal?
No
Time?
Worst case: O(bm)
Best case: O(bd) – If h(n) is 100% accurate
Space?
Worst case: O(bm)
HILL-CLIMBING SEARCH
- Expand the current state in the search and evaluate it’s children .
- Search halts when it reaches a state that is better than any of its children .
(i.e. The process ends when all operators have been applied and none of the resulting states
are better than the current state)
- Ve :
1 . Local maximum .
2 . Flat area .
3 . Cant backtrack. (WHY?)
+ Ve :
Low memory requirement .
EXAMPLE on HILL-CLIMBING
For example, hill climbing can be applied to the travelling salesman problem. It is easy to
find an initial solution that visits all the cities but will be very poor compared to the
optimal solution.
The algorithm starts with such a solution and makes small improvements to it, such as
switching the order in which two cities are visited.
A 6 B
1 2
5 3
D 4 C
HILL-CLIMBING SEARCH (cont.)
Hill Climbing can get stuck at local maxima. Consider the following tree. a is an
initial state and h and k are final states. The numbers near the states are the
heuristic values.
When hill climbing is run on the tree, we get a -> f -> g and here we get stuck at
local maxima g. Hill climbing can't go back and make a new choice (for example j or
e) because it keeps no history. So how to avoid this stuck in order to get global
maxima.
Comparison of search strategies
Space
Algorithm Complete? Optimal? Time complexity
complexity
Yes If all step O(bd) O(bd)
BFS
costs are equal
If all step
IDS Yes O(bd) O(bd)
costs are equal