03 Informedsearch
03 Informedsearch
03 Informedsearch
International University
School of Computer Science and Engineering
2
Informed Search
Definition:
Use problem-specific knowledge beyond the
definition of the problem itself
Can find solutions more efficiently
Best-first search
Greedy best-first search
A*
Heuristics
3
Best-First Search
Idea: use an evaluation function f(n) for each node
estimate of "desirability"
Expand most desirable unexpanded node
Implementation: use a data structure that maintains the frontier in
a decreasing order of desirability
Is it really the best?
4
Best First Search Algorithm
1. initialize the Q with the starting state (node)
2. while Q is not empty, do
1) assign the first element of Q to N
2) if N is the goal, return SUCCESS
3) remove N from Q
4) add the children of N to Q
5) sort the entire Q by f (n)
3. return FAILURE
5
Recall Romania Map Example
What’s a proper heuristic that measures cheapest path from current node to goal node?
6
Romania Map with Costs
7
Greedy Best-First Search
Evaluation function: f(n) = h(n)
estimate the cost from n to goal
hSLD = straight line distance from n to
Bucharest
8
Example: Arad to Bucharest
9
Example: Arad to Bucharest
10
Example: Arad to Bucharest
11
Example: Arad to Bucharest
12
Analysis of Greedy Best-First
Complete?
From Iasi to Fagaras
No – can get stuck in loops, e.g., Iasi => Neamt => Iasi =>
Neamt => …
Time?
O(bm), but a good heuristic can give dramatic
improvement
Space?
O(bm) -- keeps all nodes in memory
Optimal?
No
13
A*: Minimizing Total Est. Cost
Idea: avoid expanding paths that are
already expensive
14
A* Search Example
15
A* Search Example
16
A* Search Example
17
A* Search Example
18
A* Search Example
19
A* Search Example
20
Exercise
Use A* graph-search to generate a path
from Lugoj to Bucharest using the straight-
line distance heuristic.
21
Admissible Heuristic
A heuristic h(n) is admissible if for every node n,
h(n) ≤ h*(n), where h*(n) is the true cost to reach
the goal state from n
22
Optimality of A* -- Proof
Suppose some suboptimal goal G2 has been generated
and is in the frontier. Let n be an unexpanded node in
the frontier such that n is on a shortest path to an
optimal goal G.
23
Consistency Heuristics
A heuristic is consistent if for every node n, every successor
n' of n generated by any action a, h(n) ≤ c(n,a,n') + h(n')
Triangle inequality
24
A* With Graph Search
Theorem: If h(n) is consistent, A* using GRAPH-
SEARCH is optimal
25
Optimality of A*
A* expands nodes in order of increasing f value
Assume C* is the optimal cost
A* expands all nodes with f(n) < C*
A* might then expand some of the nodes right on the “goal contour”
(f(n) = C*) before selecting a goal node
Uniform-cost search (h(n) = 0) => bands more circular
26
Analysis of A*
Important idea:
appropriate h(n) function
A* is optimal efficient (no other optimal alg. is guaranteed to
expand fewer nodes than A*)
pruning while still guaranteeing optimality
Complete?
Yes (unless there are infinitely many nodes with f ≤ f(G))
Optimal?
Yes, with finite b and positive path cost
However, A* is not the answer for all problems
Time?
Exponential in the length of the solution
Space?
Keeps all nodes in memory
A* usually runs out of space long before it runs out of time
27
Heuristic Functions
28
Quality of Heuristic
Assume # of nodes generated by A* for a problem
is N and the solution depth is d, then b* is the
effective branching factor that a uniform tree of
depth d would have to have. Thus:
N + 1 = 1 + b* + (b*)2 + … + (b*)d
29
The Comparison
then h2 dominates h1
31
Inventing Admissible Heuristic
A problem with fewer restrictions on the
actions is called a relaxed problem
32
Inventing Admissible Heuristic
If a collection of admissible heuristics h1 …
hm is available, and none of them
dominates any of the others, we can choose
h (n) = max{h1(n), …, hm(n)}
33
Exercise
The heuristic path algorithm is a best-first
search in which the objective function is
f(n) = (2-w) x g(n) + w x h(n). For what
values of w is the algorithm guaranteed to
be optimal? (You may assume that h is
admissible.) What kind of search does this
perform when w = 0? When w = 1? When
w = 2?
34
Exercise
Prove each of the following statements:
Breadth-first search is a special case of uniform-
cost search.
Breadth-first search, depth-first search, and
uniform-cost search are special cases of best-
first search.
Uniform-cost search is a special case of A*
search.
35
Discussion
Lab Assignments
36