Skip to main content
Informed search
algorithms
Chapter Sections 1-5
Informed= use problem-specific
knowledge
Which search strategies?
—Best-first search and its variants
Heuristic functions?
—How to invent them
Local search and optimization
—Hill climbing, local beam search, genetic
algorithms,...
Local search in continuous
spaces Online search agents
function TREE-SEARCH(problem,fringe) return a solution or
failure fringe INSERT(MAKE-NODE(INITIAL-STATE problem]),
fringe) loop do
if EMPTY?(Fringe) then return failure
node +- REMOVE-FIRST(fringe)
if GOAL-TEST[pool/em] applied to STATE[node]
succeeds
then return SOLUTION(node)
fringe INSERT-ALL(EXPAND(node, problem), fringe)
A strategy is defined by picking the
order of node expansion
General approach of informed search:
- Best-first search • node is selected for expansion based
on an evaluation function f(n)
Idea: evaluation function measures
distance to the goal.
— Choose node which appears best
Implementation:
fringe is queue sorted in decreasing order of desirability.
- Special cases: greedy search, A” search
—l›‹iil estimated cost of the
cheapest path from
node n to goal node.
—If n is goal then li(i››=J
— More information
later
”,
••=
.g
ili
’é!
* **** *"
•°
hS
L
D
——straight-
line
distance
heuristic.
hS‹D can NOT be
computed from
the problem
description itself
In this example
f(n) —
—h(n)
§;;g
“
”-“
,°
’
•
- Expand node that
is closest to goal
= Greedy best-first search
Arad
(366)
Assume that we want to use greedy
search to solve the problem of travelling
from Arad to Bucharest.
The initial state=Arad
Sibiu(253)
Arad
Timisoara
(329)
The first expansion step
produces:
- Sibiu, Timisoara and Zerind
Greedy best-first will select
Sibiu.
Zerind(374)
Arad
(366)
Sibiu
(380) (193)
Fagaras
(176)
Arad
Ora ea l i e u Vilcea
If Sibiu is expanded we get:
— Arad, Fagaras, Oradea and Rimnicu Vilcea
Greedy best-firstsearch will select:
Fagaras
Sibiu
(253)
Sibiu
Fagaras
ucharest
(0)
Arad
If Fagaras is expanded we get:
Sibiu and Bucharest
Goal reached ! !
Yet not optimal (see Arad, Sibiu, Rim nicu Vil cea,
Pitesti
Completeness: NO (e.g. DF-search)
- Check on repeated states
- Minimizing h(n) can result in false starts, e.g.
lasi to Fagaras.
Completeness: NO (e.g. DF-search)
Time complexity?
- Worst-case DF-search @b
fH)
(with m is maximum depth of search space)
—Good heuristic can give dramatic
improvement.
Completeness: NO (e.g. DF-
search)
Time complexity:
O(b”)
Space complexity:
o(bM
—Keeps all nodes in memory
Time complexity:
Completeness: NO (e.g. DF-search)
O(b‘}
Optimality?
NO
— Same as DF-
search
W)
Space complexity: ( b
Best-known form of best-first search.
Idea: avoid expanding paths
that are already expensive.
Evaluation function f(n) —
—g(n) -i- h(n)
—g(n) the cost (so far) to reach the node.
—h(n) estimated cost to get from the node to the
goal.
—f(n) estimated total cost of path through n to
goal.
A* search uses an admissible
heuristic
— A heuristic is admissible if it never
overestimates the cost to reach the
goal
—Are optimistic
Formally:
t. h(n} < = h”(n) where is the true cost from n
2. h(n) > — 0 so h(G) —
—0 for any goal G.
e.g. hgtofn) never overestimates the actual road distance
U0
Tim I90e
æ
î0 J
360=0-›366
Find Buchareststarting at Arad
I(Arad) - c(??,Arad) + h(Arad) -0+366=
366
4+z-
11s-›oze
440=75+27
4
Expand Arrad and determine f(n) for each node
— f(5ibiu)=c(Arad,5ibiu)+h(5ibiu)=140+253=393
—f(Timisoara)=c(Arad,Timisoara)+h(Timisoara)=118+329=447
—f(Zerind)=c(Arad,Zerind)+h(Zerind)=75+374=449
Best choice is Sibiu
e46 @+300 415 3B+17B B71=æ1+2a0 413 1+1e3
Expand Sibiu and determine /¢nÿ for each
node
— f(Arad)=c(Sibiu,Arad)+h(Arad)=280+366=646
— f(Fagaras)-c(Sibiu,Fagaras)+h(Fagaras)=239+179—415
— f(Oradea) —c(Sibiu,Oradea)+h(Oradea) —291+380—671
— f(Rimnicu Vilcea)=c(Sibiu,Rimnicu Vìlcea)+
h(Rimnicu ViIcea)—220+ 192—
413
Best choice is Rimnicu Vilcea
+No 418 1?6 a71=&1+9W
Expand Rimnicu Vilcea and determine
f(n) for each node
— f(Craiova)=c(Rimnicu Vilcea, Craiova)+h(Craiova)=360+
160=526
- I(Pitesti)=c(Rimnicu Vilcea, Pitesti)-i-
h(Pitesti)=317+100=417
- I(Sibiu)=c(Rimnicu Vilcea,Sibiu)+h(Sibiu)=300+253=553
Best choice is Fagaras
52'6W0+160 417-G17+10€i 553=3 €I+253
Expand Fagaras and determine f(n) for each
node
—f(Sibiu)=c(Fagaras, Sibiu)+h(Sibiu)—338+253= 591
—f(Bucharest) -—c(Fagaras, Bucharest) +h(Bucharest) -—450+0-—
450
Best choice is Pitesti !!!
Expand Pitesti and determine f(n) for each
node
f(Bucharest) ——c(Pitesti,Bucharest)+h(Bucharest) —
—41
8+ 0 —
—4
1
8
Best choice is Bucharest ! !!
- Optimal solution (onIy if h(n) is admissable}
Note values along optimal path !!
Suppose suboptimalgoal G2 in the queue.
Let n be an unexpanded node on a shortest to
optimal goal G.
I(Gy) since h¿G
—
—0
—
—
g(Gy)
> g(G)
>= f(n)
since Cl is
suboptimal
since h is admissible
Since f(G,) > f(n), A* will never select G for
expansion
A heuristic is consistent
if (^
If h is consistent, we have
——g(n)+ c{n,a,n') + h{n')
?: g(n) + h(n)
i.e. f(n) is nondecreasing along any
path.
A” expands nodes in order of increasing I
value Contours can be drawn in state space
— Uniform -cost sea rch adds circ les.
F-contours are g radually
Aadea :
1) n Od es with I(n) < C
2) Some nodes on the goal
¿
Contour (I{n} —
—C”’ ).
Contour I nas a
l
l
Nodes with f=f,
vvnere
Completeness:YES
—Since bands of increasing 7 are added
—Unless there are infinitly many nodes
with
Completeness:
YESTime
complexity:
Number of nodes expanded is still exponential
in the length of the solution.
Completeness: YES
Time complexity: (exponential with
path
length)
Space complexity:
—It keeps all generated nodes in memory
—Hence space is the major problem not time
Completeness: YES
Time complexity: (exponential with
path length)
Space complexity:(all nodes are
stored) Optimality: YES
— Cannot expand f,+t until I, is finished.
- A* expands all nodes with /°{n/ < C*
— A
” expands some nodes with f(n) —
—C
”
- A* expands no nodes with f{n/ >C*
Also optimally efficient (not including
ties)
Some solutions to A” space
problems (maintain completeness and
optimality)
—Iterative-deepening A* (IDA*)
—Here cutoff information is the I-cost (g+h) instead of depth
—Recursive best-first search(RBFS)
—Recursive algorithm that attempts to mimic standard
best-first search with linear space.
— (simple)Memory-bounded A* ((S)MA*)
— Drop the worst-leaf node when memory is full
8
function RECURSIVE-BEST-FIRST-SEARCH problem) return a solution or failure
return RFBS(problem,MAKE-NODE(INITIAL-STATE problem]), )
function RFBS( prOblem, mode, /° /irnit) return a solution or failure and a
new f- cost limit
if GOAL-TEST(problem)(STATE[node]) then return
node successors +
— EXPAND(node, problem)
if successors is empty then return failure,
for each s in successors dn
max(g(s) + h(s), f (node) j
f (s)
repeat
best the lowest /-value node in
successors
if I [best) > I limit then return failure, I
[test]
alternative the second lowest I-value among successors
RBFS¿prob/em, best, min(£ limit, alternative))
result, I best)
if result failure then return
result
Recursive best-first
search
Keeps track of the f-value of the
best-alternative path available.
— If current f-values exceeds this
alternative
f-
value than backtrack to alternative path.
- Upon backtracking change f-value to best
f-
value of its children.
— Re-expansion of this result is thus
Path until Rumnicu Vilcea is already expanded
Above node; /°-limit for every recursive call is shown on
top. Below node: I(n)
The path is followed until Pitesti which has a /°-value worse
than the f-limit.
Ib
)
un•*edmg toSJü° .
’
1
41s 417
Unwind recursion and store best /-value for
current best leaf Pitesti
result, f (best) +- RBF5¿prOö/em, best, min(/°_//mit,
alternative))
liest •is nowFagaras. Call RBFS for new best
— best value is now 450
Unwind recursion and store best /°-value for current
best leaf
Fagaras
result, I (best] +- RBFS¿prod/em, best, min(ñ_/imit, alternative))
best is now Rimnicu Viclea (again). Call RBFS for new best
— Subtree is again expanded.
Best alternative subtree is now through Timisoara.
Solution is found since because 447 > 417.
RBFS is a bit more efficientthan
IDA”
—Still excessive node generation (mind changes)
Like A”, optimal if h(n) is
admissible Space complexity is
0(bd).
—IDA” retains onIy one single number (the
current f-cost limit)
Time complexity difficultto
characterize
—Depends on accuracy if h(n) and how often
best path changes.
IDA” en RBFS suffer from too
little memory.
E.g for the 8-puzzle knows two commonly used
heuristics
h —
— the number of misplaced tiles
— hp(s)=8
h —
— the sum of the distances of the tiles from
their goal positions (manhattan distance).
— h2(*)= 3 -i-1--2 -i-2 -i-2 --3 -i-3 -i-2= 18
E.g for the 8-puzzle
Avg. solution cost is about 22 steps (branching factor +/-
3) Exhaustive search to depth 22: 3.1 x 10‘0 states.
A good heuristic function can reduce the search process.
Effective branching factor
b*
—Is the branching factor that a uniform tree
of depth 4 would have in order to
contain //+ 4 nodes.
N + 1 = l + b * +(b*)2
+ ...+ {b*)d
—Measure is fairly constant for sufficiently
hard
problems.
—Can thus provide a good guide to the heuristic's
overall
useful ness.
—A good value of b” is 1
4 1
İ2
IO
47I27
I2
364d035
I4 -
16.
93'
539
J301
113
2IT
‹67f
1219
2.87
279
?:J8
I.38
I:42
1,45
1.46
1:47
I.28
If hymn) >= h1(n) for all n (both admissible)
then h2 dominates h1 and is better for
search
Admissible heuristics can be derived from the
exact solution cost of a relaxed version of the
problem: a
— Relaxed 8-puzzle for h1 tile can move
anywhere
As a result, h (n) gives the shortest solution
— Relaxed B-puzzle for h a tile can move to any adjacent squa
re.
As a result, h (n) gives the shortest solution.
The optimal solution cost of a relaxed problem
is no greater than the optimal solution cost of
the real problem.
ABSo1veZ fOUnd a usefull heuristicfor the rubic
cube.
Admissible heuristics can also be derived from the solution
cost
of a subproblemof a given problem.
This cost is a lower bound on the cost of the real problem.
Pattern databases store the exact solution to for every
possible subproblem instance.
— The complete heuristic is constructed using the patterns in the DB
Another way to find an
admissible heuristic is through
learning from experience:
—Experience solving lots of 8-puzzles
— An inductive learning algorithm can be used
to predict costs for other states that arise during
search.