Grundlagen Der K Unstlichen Intelligenz - Informed Search: Matthias Althoff
Grundlagen Der K Unstlichen Intelligenz - Informed Search: Matthias Althoff
Matthias Althoff
TU M
unchen
Matthias Althoff
Informed Search
1 / 22
Organization
Matthias Althoff
Informed Search
2 / 22
Informed Search
Requires problem-specific knowledge beyond the problem definition.
Can find solutions more efficiently than uninformed search.
Informed search uses indications whether a state is more promising
than another to reach a goal.
The choice of the next node is based on an evaluation function
f (n), which itself is often based on a heuristic function h(n).
h(n) is problem specific with the only constraints that it is
nonnegative and h(
n) = 0, where n is a goal node.
All presented informed search strategies are implemented identically to
uniform-cost search, except that f instead of g is used in the priority
queue.
Heuristic
Heuristic refers to the art to achieve good solutions with limited
knowledge and time based on experience.
Matthias Althoff
Informed Search
3 / 22
75
Oradea
Neamt
Zerind
87
151
Iasi
Arad
140
92
Sibiu
99
Fagaras
118
Vaslui
80
Rimnicu Vilcea
Timisoara
111
Lugoj
Pitesti
97
142
211
70
98
Mehadia
75
Dobreta
146
85
101
138
120
86
Bucharest
90
Craiova
Giurgiu
Matthias Althoff
Hirsova
Urziceni
Informed Search
Eforie
Straightline distance
to Bucharest
Arad
366
Bucharest
0
Craiova
160
Dobreta
242
Eforie
161
Fagaras
178
Giurgiu
77
Hirsova
151
Iasi
226
Lugoj
244
Mehadia
241
Neamt
234
Oradea
380
Pitesti
98
Rimnicu Vilcea 193
Sibiu
253
Timisoara
329
Urziceni
80
Vaslui
199
Zerind
374
17. October 2014
4 / 22
Arad
366
Matthias Althoff
Informed Search
5 / 22
Arad
Matthias Althoff
Sibiu
Timisoara
Zerind
253
329
374
Informed Search
5 / 22
Arad
Sibiu
Arad
366
Fagaras
176
Matthias Althoff
Oradea
380
Timisoara
Zerind
329
374
Rimnicu Vilcea
193
Informed Search
5 / 22
Arad
Sibiu
Arad
366
Fagaras
Oradea
380
Sibiu
Bucharest
253
Timisoara
Zerind
329
374
Rimnicu Vilcea
193
Note that the solution is not optimal since the path is 32 km longer than
through Rimnicu Vilcea and Pitesti.
Matthias Althoff
Informed Search
5 / 22
71
75
Neamt
Zerind
87
151
Iasi
Arad
140
Sibiu
92
99
Fagaras
118
Timisoara
111
Vaslui
80
Rimnicu Vilcea
Lugoj
Pitesti
97
142
211
70
98
Mehadia
75
Dobreta
146
Informed Search
Hirsova
Urziceni
86
138
Bucharest
120
Craiova
Matthias Althoff
85
101
90
Giurgiu
Eforie
17. October 2014
6 / 22
Matthias Althoff
Informed Search
7 / 22
A* search: Idea
The most widely known informed search is A* search (pronounced
A-star search).
It evaluates nodes by combining the path cost g (n) and the estimated
cost to the goal h(n):
f (n) = g (n) + h(n),
where h(n) has to be underestimated, i.e. it has to be less than the
actual cost.
f (n) never overestimates the cost to the goal and thus the
algorithm keeps searching for paths that might have lower cost to the
goal than the previously found ones.
Matthias Althoff
Informed Search
8 / 22
A* Search: Example
Straight line distance is an underestimation of the cost to the goal, which
are used for h(n).
Arad
366=0+366
Informed Search
9 / 22
A* Search: Example
Straight line distance is an underestimation of the cost to the goal, which
are used for h(n).
Arad
Sibiu
Timisoara
Zerind
393=140+253
447=118+329
449=75+374
Informed Search
9 / 22
A* Search: Example
Straight line distance is an underestimation of the cost to the goal, which
are used for h(n).
Arad
Sibiu
Arad
Fagaras
Oradea
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
Informed Search
9 / 22
A* Search: Example
Straight line distance is an underestimation of the cost to the goal, which
are used for h(n).
Arad
Sibiu
Arad
Fagaras
Oradea
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
Pitesti
Sibiu
Informed Search
9 / 22
A* Search: Example
Straight line distance is an underestimation of the cost to the goal, which
are used for h(n).
Arad
Sibiu
Arad
Fagaras
646=280+366
Oradea
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
671=291+380
Sibiu
Bucharest
591=338+253
450=450+0
Craiova
Pitesti
Sibiu
Informed Search
9 / 22
A* Search: Example
Straight line distance is an underestimation of the cost to the goal, which
are used for h(n).
Arad
Sibiu
Fagaras
Arad
646=280+366
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
Oradea
671=291+380
Sibiu
Bucharest
Craiova
591=338+253
450=450+0
526=366+160
Bucharest
418=418+0
Pitesti
Sibiu
553=300+253
Craiova
Rimnicu Vilcea
615=455+160 607=414+193
Informed Search
9 / 22
A
S
380
400
R
P
U
B
420
C
G
Matthias Althoff
Informed Search
10 / 22
A* Search: Pruning
Given the cost C of the optimal path, it is obvious that only paths
are expanded with f (n) < C .
A* never expands nodes, where f (n) C .
For instance, Timisoara is not expanded in the previous example. We
say that the subtree below Timisoara is pruned.
The concept of pruning eliminating possibilities from consideration
without having to examine them brings enormous time savings and
is similarly done in other areas of AI.
Especially for large problems, pruning becomes important.
Matthias Althoff
Informed Search
11 / 22
A* Search: Performance
Reminder: Branching factor b, depth d, maximum length m of any path.
Time and space complexity of A* is quite involved and we will not derive
the results. They are presented in terms of the relative error
= (h h)/h , where h is the estimated and h is the actual cost from
the root to the goal.
Completeness: Yes, if costs are greater than 0 (otherwise infinite
optimal paths of zero cost exist).
Optimality: Yes (if cost are positive).
Time complexity: We only consider the easiest case: The state
space has a single goal and all actions are reversible: O(b d ) (without
proof)
Space complexity: Equals time complexity since all nodes are stored.
Matthias Althoff
Informed Search
12 / 22
Alternatives of A* Search
One of the big disadvantages of A* search is the possibly huge space
consumption. This can be alleviated by extensions, which we only mention
here:
Iterative-deepening A*: adapts the idea of iterative deepening to
A*. The main difference is that the f -cost (g + h) is used for cutoff,
rather than the depth.
Recursive best-first search: a simple recursive algorithm with linear
space complexity. Its structure is similar to the one of
recursive-depth-first search, but keeps track of the f -value of the best
alternative path.
Memory-bounded A* and simplified memory-bounded A*: Those
algorithms work just as A* until the memory is full. The algorithms
drop less promising paths to free memory.
Matthias Althoff
Informed Search
13 / 22
Heuristic Functions
Heuristic Functions
For the shortest route in Romania, the straight line distance is an obvious
underapproximating heuristics.
7
5
8
Goal State
Start State
This is not always so easy, as we will show for the 8-puzzle. Problem size:
On average 22 steps to a solution.
Average branching factor is about 3 (4 moves when empty tile is in
the middle, 2 in a corner, and 3 on an edge).
An exhaustive search visits about 322 3.1 1010 states.
Remembering previously visited states reduces to 9!/2 = 181, 440
distinct states, but there are already 15!/2 1013 for the 15-puzzle.
Matthias Althoff
Informed Search
14 / 22
Heuristic Functions
5
8
3
Start State
Matthias Althoff
1
3
2
1
3
2
4
2
5
2
6
3
7
3
8
2
sum
18
Goal State
Informed Search
15 / 22
Heuristic Functions
Informed Search
16 / 22
Heuristic Functions
539
113
1.44
16
1301
211
1.45
18
3056
363
1.46
20
7276
676
1.47
22
18094
1219
1.48
24
39135
1641
1.48
Matthias Althoff
Informed Search
even
Factor
A*(h2 )
1.79
1.45
1.30
1.24
1.22
1.24
1.23
1.25
1.26
1.27
1.28
1.26
17 / 22
Heuristic Functions
Domination of a Heuristics
Question: Is h2 always better than h1 ?
Answer: Yes.
Reason:
For every node we have that h2 (n) > h1 (n). We say that h2
dominates h1 .
A* using h2 will never expand more nodes than with h1 (excepts
possibly for some nodes with f (n) = C ):
A* expands all nodes with
f (n) < C h(n) < C g (n),
where g (n) is fixed. Since h2 (n) > h1 (n), less nodes are expanded.
Matthias Althoff
Informed Search
18 / 22
Heuristic Functions
Matthias Althoff
Informed Search
19 / 22
Heuristic Functions
Informed Search
20 / 22
Heuristic Functions
2
5
8
2
6
4
5
Start State
Matthias Althoff
Goal State
Informed Search
21 / 22
Summary
Summary
Matthias Althoff
Informed Search
22 / 22