0% found this document useful (0 votes)
48 views30 pages

Grundlagen Der K Unstlichen Intelligenz - Informed Search: Matthias Althoff

This document discusses informed search strategies for problem solving using artificial intelligence. It begins by introducing informed search and how it uses problem-specific knowledge in the form of heuristic functions to guide the search for solutions more efficiently than uninformed search. It then describes greedy best-first search and A* search as two common informed search algorithms. It provides examples of how each algorithm would solve a route finding problem in Romania using straight-line distance as the heuristic. The document concludes by discussing heuristic functions and alternatives to A* search that address its high memory usage.

Uploaded by

Marawan Okasha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views30 pages

Grundlagen Der K Unstlichen Intelligenz - Informed Search: Matthias Althoff

This document discusses informed search strategies for problem solving using artificial intelligence. It begins by introducing informed search and how it uses problem-specific knowledge in the form of heuristic functions to guide the search for solutions more efficiently than uninformed search. It then describes greedy best-first search and A* search as two common informed search algorithms. It provides examples of how each algorithm would solve a route finding problem in Romania using straight-line distance as the heuristic. The document concludes by discussing heuristic functions and alternatives to A* search that address its high memory usage.

Uploaded by

Marawan Okasha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Grundlagen der kunstlichen Intelligenz Informed Search

Matthias Althoff
TU M
unchen

17. October 2014

Matthias Althoff

Informed Search

17. October 2014

1 / 22

Organization

Informed search strategies


Heuristic functions

The content is covered in the AI book by the section Solving Problems by


Searching, Sec. 5-6.

Matthias Althoff

Informed Search

17. October 2014

2 / 22

Informed Search Strategies

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

17. October 2014

3 / 22

Informed Search Strategies

Greedy Best-First Search: Idea


Expands the node that is closest to the goal by using just the heuristic function
so that f (n) = h(n).
Example: Route-finding problem in Romania. We use the straight line distance to
the goal as h(n), which is listed below:
71

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

Informed Search Strategies

Greedy Best-First Search: Example

Arad
366

Matthias Althoff

Informed Search

17. October 2014

5 / 22

Informed Search Strategies

Greedy Best-First Search: Example

Arad

Matthias Althoff

Sibiu

Timisoara

Zerind

253

329

374

Informed Search

17. October 2014

5 / 22

Informed Search Strategies

Greedy Best-First Search: Example

Arad

Sibiu

Arad
366

Fagaras
176

Matthias Althoff

Oradea
380

Timisoara

Zerind

329

374

Rimnicu Vilcea

193

Informed Search

17. October 2014

5 / 22

Informed Search Strategies

Greedy Best-First Search: Example

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

17. October 2014

5 / 22

Informed Search Strategies

Greedy Best-First Search: Another Example


Greedy best-first search is incomplete when not using an explored set,
even on finite state spaces.
E.g. when going from Iasi to Faragas, Neamt is first expanded due to
closer straight line distance, but this is a dead end.
Oradea

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

Informed Search Strategies

Greedy Best-First Search: Performance

Reminder: Branching factor b, depth d, maximum length m of any path.


Completeness: Yes, if an explored set is used, otherwise no (see
previous example).
Optimality: No (see previous example).
Time complexity: The worst-case is that the heuristics is misleading
the search such that the solution is found last: O(b m ). But a good
heuristic can provide dramatic improvement.
Space complexity: Equals time complexity since all nodes are stored:
O(b m ).

Matthias Althoff

Informed Search

17. October 2014

7 / 22

Informed Search Strategies

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

17. October 2014

8 / 22

Informed Search Strategies

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

Nodes are labeled with f = g + h


Matthias Althoff

Informed Search

17. October 2014

9 / 22

Informed Search Strategies

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

Nodes are labeled with f = g + h


Matthias Althoff

Informed Search

17. October 2014

9 / 22

Informed Search Strategies

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

646=280+366 415=239+176 671=291+380 413=220+193

Nodes are labeled with f = g + h


Matthias Althoff

Informed Search

17. October 2014

9 / 22

Informed Search Strategies

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

646=280+366 415=239+176 671=291+380


Craiova

Pitesti

Sibiu

526=366+160 417=317+100 553=300+253

Nodes are labeled with f = g + h


Matthias Althoff

Informed Search

17. October 2014

9 / 22

Informed Search Strategies

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

526=366+160 417=317+100 553=300+253

Nodes are labeled with f = g + h


Matthias Althoff

Informed Search

17. October 2014

9 / 22

Informed Search Strategies

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

Nodes are labeled with f = g + h


Matthias Althoff

Informed Search

17. October 2014

9 / 22

Informed Search Strategies

A* Search: Effects of the Heuristics


The heuristics steers the search towards the goal.
A* expands nodes in order of increasing f value, so that f -contours
of nodes are gradually added.
Each contour i has all nodes with f = fi , where fi < fi +1 .
O
N

A
S

380

400

R
P

U
B

420

C
G

Matthias Althoff

Informed Search

17. October 2014

10 / 22

Informed Search Strategies

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

17. October 2014

11 / 22

Informed Search Strategies

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

17. October 2014

12 / 22

Informed Search Strategies

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

17. October 2014

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

17. October 2014

14 / 22

Heuristic Functions

Heuristic Functions for the 8-Puzzle


Two commonly used candidates that underestimate the costs to the goal:
h1 : the number of misplaced tiles (e.g. in the figure h1 = 8).
Admissible since any misplaced tile has to be moved at least once.
h2 : the sum of the distances to the goal positions using horizontal
and vertical movement. Admissible since all a move can do is bring
the tile one step closer. In the figure:
tile
steps
7

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

(the true cost is 26)

Goal State
Informed Search

17. October 2014

15 / 22

Heuristic Functions

Effective Branching Factor


One way of characterizing the quality of a heuristics is the effective
branching factor b .
Given:
Number of nodes N generated by the A* search.
A uniform tree with depth d (each node has the same fractional
number b of children)
Thus,
N + 1 = 1 + b + (b )2 + . . . + (b )d .
E.g. if A* generates a solution at depth 5 using 52 nodes, b = 1.92 since
53 1 + 1.92 + (1.92)2 + . . . + (1.92)5 .
The branching factor makes it possible to compare heuristics applied to
problems of different size. Why?
Matthias Althoff

Informed Search

17. October 2014

16 / 22

Heuristic Functions

Comparison of the Heuristics for the 8-Puzzle


1200 random problems with solution length from 2 24 (100 for each
number):
Search Cost (nodes generated)
Effective Branching
d
IDS
A*(h1 )
A*(h2 )
IDS
A*(h1 )
2
10
6
6
2.45
1.79
4
112
13
12
2.87
1.48
6
680
20
18
2.73
1.34
8
6384
39
25
2.80
1.33
10
47127
93
39
2.79
1.38
12
3644035
227
73
2.78
1.42
14

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. October 2014

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

17. October 2014

18 / 22

Heuristic Functions

Heuristics from Relaxed Problems


Idea: The previous heuristics h1 and h2 are perfectly accurate for simplified
versions of the 8-puzzle.
Method: Formalize a problem definition and remove restrictions.
Result:
One obtains a relaxed problem, i.e. a problem with more freedom, whose
state-space graph is a supergraph of the original problem (see figure).
An optimal solution in the original problem is automatically a solution in the
relaxed problem, but the relaxed problem might have better solutions due to
added edges in the state-space graph.
Hence, the cost of an optimal solution in the relaxed problem is an
underapproximative heuristic for the original problem.
supergraph
graph

Matthias Althoff

Informed Search

17. October 2014

19 / 22

Heuristic Functions

Heuristics from Relaxed Problems: 8-Puzzle Example


A tile can move from square A to B if 1 2 , where
1 : B is blank
2 : A is adjacent to B
We generate three relaxed problems by removing one or two conditions:
1 remove : A tile can move from square A to B if A is adjacent to B.
1
2 remove : A tile can move from square A to B if B is blank.
2
3 remove and : A tile can move from square A to B.
1
2
From the first relaxed problem, we can generate h2 and from the third
relaxed problem, we can derive h1 .
If one is not sure which heuristics is better, one can apply in each step
h(n) = max{h1 (n), h2 (n), . . . , hM (n)}.
Why?
Matthias Althoff

Informed Search

17. October 2014

20 / 22

Heuristic Functions

Heuristics from Pattern Databases


Underapproximative heuristics can also be obtained from subproblems.
Those solution costs are underapproximations and can be stored in a
database.
The number of subproblems has to be much less than the original problems
to not exceed storage capacities.
The figure shows a subproblem of an 8-puzzle, where only the first 4 tiles have to
be brought into a goal position (the cost is obtained by optimal backwards search
from the goal):

2
5
8

2
6

4
5

Start State
Matthias Althoff

Goal State
Informed Search

17. October 2014

21 / 22

Summary

Summary

Informed search methods require a heuristic function that estimates


the cost h(n) from a node n to the goal:
Greedy best-first search expands nodes with minimal h(n), which is
not always optimal.
A* search expands nodes with minimal f (n) = g (n) + h(n). A* is
complete and optimal for underapproximative h(n).

The performance of informed search depends on the quality of the


heuristics. Possibilities to obtain good heuristics are relaxed
problems and pattern databases.

Matthias Althoff

Informed Search

17. October 2014

22 / 22

You might also like