Professional Documents
Culture Documents
Indah Werdiningsih
Search Algorithms
Blind search BFS, DFS, uniform cost
no notion concept of the right direction
can only recognize goal once its achieved
Fringe
Set of search nodes that have not been
expanded yet
Implemented as a queue FRINGE
INSERT(node,FRINGE)
REMOVE(FRINGE)
Breadth-First Strategy
New nodes are inserted at the end of FRINGE
1
2
4
FRINGE = (1)
3
5
Breadth-First Strategy
New nodes are inserted at the end of FRINGE
1
2
4
FRINGE = (2, 3)
3
5
Breadth-First Strategy
New nodes are inserted at the end of FRINGE
1
2
4
FRINGE = (3, 4, 5)
3
5
Breadth-First Strategy
New nodes are inserted at the end of FRINGE
1
2
4
FRINGE = (4, 5, 6, 7)
3
5
Depth-First Strategy
New nodes are inserted at the front of FRINGE
1
2
4
FRINGE = (1)
Depth-First Strategy
New nodes are inserted at the front of FRINGE
1
2
4
FRINGE = (2, 3)
Depth-First Strategy
New nodes are inserted at the front of FRINGE
1
2
4
FRINGE = (4, 5, 3)
10
Depth-First Strategy
New nodes are inserted at the front of FRINGE
1
2
4
3
5
11
Depth-First Strategy
New nodes are inserted at the front of FRINGE
1
2
4
3
5
12
Depth-First Strategy
New nodes are inserted at the front of FRINGE
1
2
4
3
5
13
Depth-First Strategy
New nodes are inserted at the front of FRINGE
1
2
4
3
5
14
Depth-First Strategy
New nodes are inserted at the front of FRINGE
1
2
4
3
5
15
Depth-First Strategy
New nodes are inserted at the front of FRINGE
1
2
4
3
5
16
Depth-First Strategy
New nodes are inserted at the front of FRINGE
1
2
4
3
5
17
Depth-First Strategy
New nodes are inserted at the front of FRINGE
1
2
4
3
5
18
Contoh Kasus
Uniform-Cost Strategy
Each step has some cost > 0.
The cost of the path to each fringe node N is
g(N) = costs of all steps.
The goal is to generate a solution path of minimal
The queue FRINGE is sorted in increasing cost.
S
1
S
10
5 B 5 G
15
15
11
10
20
22
Concept of informed
(heuristic) search
Heuristic (informed) search -> explore the
node that is most likely to be the nearest
to a goal state.
There is no guarantee that the heuristic
provided most likely node will get you
closer to a goal state than any other.
23
Knowledge/info
Example:
Visit the doctor
Symptoms: fever, nausea, headache,
Leading questions: how long?, traveled?,
(Malaria, typhoid, meningitis, flu,..)
x Blood test, y test,...
24
Knowledge/info
Example:
Climbing a hill in thick Fog
Heuristic function: check the change in altitude in 4
directions; the strongest increase is the direction in
which to move next.
25
Heuristic Functions
Hill climbing
Greedy search
A* search algorithm
26
Height Defined by
Evaluation
27
Function
Hill climbing
Steepest descent (~ greedy best-first with
no search) may get stuck into local
minimum
28
Robot Navigation
Local-minimum problem
1
h = -4
-5
8
1
7
3
4
h=0
-2
3
4
8
7
-5
2
goal
1
h = -3
h = -1
-4
-3
2
h = -3
-4
h = -2
30
start
1
-3
-4
goal
1
-4
8
-4
31
Greedy Search
f(N) = h(N) greedy best-first
32
Robot Navigation
33
Robot Navigation
f(N) = h(N), with h(N) = Manhattan distance to the goal
8
6
7
6
5
4
5
34
Robot Navigation
f(N) = h(N), with h(N) = Manhattan distance to the goal
8
6
77
5
1
00
What happened???
6
5
5
35
DO
3. IF goal reached
THEN success;
ELSE failure;
37
38
Robot Navigation
f(N) = g(N)+h(N), with h(N) = Manhattan distance to goal
8
7
6
5
4
3
2
3
4
8+3
7+4
6+3
6+5
5+6
4+7
3+8
2+9
3+10
7
7+2
6
6+1
5
4
3
5+6
4+7
3+8
3
2
1
0
1
2+9
1+10
0+11
5
2
7
6
7+0
6+1
8
7
6
5
4
3
2
3
8+1
7+2
6+3
5+4
4+5
3+6
2+7
3+8
5
4
40
A* Search
Evaluation function:
f(N) = g(N) + h(N)
where:
g(N) is the cost of the best path found so far to N
h(N) is an admissible heuristic
Then, best-first search with this evaluation function is
called A* search
Important AI algorithm developed by Fikes and Nilsson in
early 70s. Originally used in Shakey robot.
41
Robot navigation
f(N) = g(N) + h(N), with h(N) = straight-line distance from N to goal
42
S
4
10.4
6.7
C 4
The estimate
G can be wrong!
11
D
8.9
E 6.9
43
A
5
S
4
4
4
B
2
E 4
G
F
3
5
4
4
2
5
G
44
A* Algorithm Example:
road map
Imagine the problem of finding a route on a road map. The
paths distances between nodes define g(n):
4
S
4
10.4
6.7
C 4
11
D
8.9
G
E 6.9
45
S
3 + 10.4 = 13.4 A
D 4 + 8.9 = 12.9
S
A 13.4
9 + 10.4 = 19.4 A
E 6 + 6.9 = 12.9
A 13.4
S
A
D
E
11 + 6.7 = 17.7
A 13.4
F 10 + 3.0 = 13.0
S
A
D
17.7 B
STOP!
F
G 13 + 0.0 = 13.0
46
Reference
Russel, Stuart J., Peter Norvig,
"Artificial Intelligence, a modern
approach, Second Edition, Prentice
Hall, New Jersey, 2010.
Winston, Patrick Henry, "Artificial
Intelligence, Addison Wesley.
TERIMA
KASIH