Informed= use problem-specific
knowledge
Whichsearch 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
3.
function TREE-SEARCH(problem,fringe) returna 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
4.
General approach ofinformed 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
5.
—l›‹iil estimated costof the
cheapest path from
node n to goal node.
—If n is goal then li(i››=J
— More information
later
Completeness: NO (e.g.DF-search)
- Check on repeated states
- Minimizing h(n) can result in false starts, e.g.
lasi to Fagaras.
12.
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.
13.
Completeness: NO (e.g.DF-
search)
Time complexity:
O(b”)
Space complexity:
o(bM
—Keeps all nodes in memory
Best-known form ofbest-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.
16.
A* search usesan 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
4+z-
11s-›oze
440=75+27
4
Expand Arrad anddetermine 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
20.
e46 @+300 4153B+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
21.
+No 418 1?6a71=&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
22.
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 !!!
23.
Expand Pitesti anddetermine 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 !!
24.
Suppose suboptimalgoal G2in 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
25.
A heuristic isconsistent
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.
26.
A” expands nodesin 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
Time complexity:(exponential with
path
length)
Space complexity:
—It keeps all generated nodes in memory
—Hence space is the major problem not time
30.
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)
31.
Some solutions toA” 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
32.
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
33.
Recursive best-first
search
Keeps trackof 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
34.
Path until RumnicuVilcea 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.
35.
Ib
)
un•*edmg toSJü° .
’
1
41s417
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
36.
Unwind recursion andstore 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.
37.
RBFS is abit 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.
38.
E.g for the8-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
39.
E.g for the8-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.
40.
Effective branching factor
b*
—Isthe 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
Admissible heuristics canbe 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.
43.
Admissible heuristics canalso 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
44.
Another way tofind 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.