intro to astar
Post on 07-Apr-2018
241 Views
Preview:
TRANSCRIPT
-
8/6/2019 Intro to Astar
1/26
Introduction ToInformed Search & A*
G51IAI Introduction to AI
Andrew Parkeshttp://www.cs.nott.ac.uk/~ajp/
-
8/6/2019 Intro to Astar
2/26
PLE ASE NOTEMOND AY OCT 30thNO
FORM
AL LECTUR
E!Question & Answer instead (y ou ask the questions!), especiall y regarding the coursework (s).
Bring Questions!
-
8/6/2019 Intro to Astar
3/26
-
8/6/2019 Intro to Astar
4/26
Shortest Path ProblemsWhen the graph becomes too large blindsearch is no longer practicalProblem is that blind search does not look inthe right placesT o see this think of the search pattern ofU niform C ost SearchO n the next 2 slides we will see an examplebased on a map of R omania from AI M A These include an animation of how UCS performs thesearch, hence printed version will be a mess! (BTW I removed the Oradea -Sibiu edge to simplif y the
animation and fix an error in an earlier version)
-
8/6/2019 Intro to Astar
5/26
Study this map of Romania. Note the distances between cities and try and calculatethe shortest route between Sibiu and Bucharest . Then press space to see theoptimal route marked in red.
Arad
Bucharest
OradeaZerind
Faragas
Neamt
Iasi
Vaslui
Hirsova
Eforie
Urziceni
Giurgui
Pitesti
Sibiu
Dobreta
Craiova
Rimnicu
Mehadia
Timisoara
Lugoj
87
92
142
86
98
86
211
101
90
99
71
75
140118
111
70
75
120
138
146
97
80
140
80
97
101
Sibiu
Rimnicu
Pitesti
Optimal route is (80+97+101) = 278 miles
The optimal route between the two cities takes us through Rimnicu and Pitesti.Press space to continue with the slideshow.
-
8/6/2019 Intro to Astar
6/26
-
8/6/2019 Intro to Astar
7/26
RemarksWe expanded Arad and Zerindeven though they are in totally thewrong direction!T he search pattern was
expanding concentric circles
-
8/6/2019 Intro to Astar
8/26
Uniform Cost Search in GraphsSearch Pattern:smaller costnodes beforelargerFringe in red
Visited in blue
Blind: still ignoresgoals
goal
outline of graph
increasing cost
start
T his region isbasicallywasted effort
-
8/6/2019 Intro to Astar
9/26
Heuristic SearchD esired SearchPattern: biased indirection of goal(s)
Fringe in red Visited in blueWhen reaches goalwill have had toexplore less of the
graphR educes time andmemory usage
goal
outline of graph
increasing cost
start
-
8/6/2019 Intro to Astar
10/26
Heuristic SearchWant to achievethis pattern but
stay complete optimal
If bias the search too much thencould miss goalsor miss shorterpaths
goal
outline of graph
increasing cost
start
-
8/6/2019 Intro to Astar
11/26
More Realistic PictureIn real problems thegraphs are messy andthe search pattern notclean
What we think iscorrect directionmight be ultimatelywrongStandard solution tostay complete andoptimal: A* search pronounced A star
But first do a moregeneral heuristicmethod: B est First Search
goal
outline of graph
increasing cost
start
-
8/6/2019 Intro to Astar
12/26
Heuristic SearchSupposehave someestimates,
h , of thecost from a(fringe) nodeto the goalWant tofavour smallhExpand Afirst?
goal
outline of graph
increasing cost
start A
B
g A
gB
h A
hB
-
8/6/2019 Intro to Astar
13/26
Best First Search (BestFS)Give each node, n, a score or fullcost : f(n)U sually f(n) is based g and h Small f values are better.
BestFS is same asUC
S except use f(n) instead of justg(n)
Search nodes with f before those of f+1
BestFS Queue: explicitly store the f value of a node with that node want smallest f value first if using REMOVE-FIRST then sort the queue in increasing order alternativel y, instead of REMOVE-FIRST, just scan all queue and
use REMOVE-SM ALLEST-SCORE
-
8/6/2019 Intro to Astar
14/26
Best First SearchPROCEDURE BestFS( problem, S CORE_FN )1. fringe M AKE-E M P T Y-Q U EU E()2. fringe I N SERT ( start _n ode ) // with its f value
3. loop {1. if fringe is empt y then return false // finished without goal2. node REMOVE-SM ALLEST-SCORE(fringe)3. if node is a goal
1. print node and g2. return true // that found a goal
4. Lf
EXP AND(node) // Lf
is set of n eighbours with th e ir f values // ob tain ed us ing SCORE_FN
5. f ring e INSERT-IF-NEW(Lf , fringe ) // ignore revisi t ed nodes // unless th ey a re be tt er
}
-
8/6/2019 Intro to Astar
15/26
UCS & BestFS
UC S just uses f = g
P ROC EDUR E UC S( problem )
return BestFS( problem , g )
-
8/6/2019 Intro to Astar
16/26
Greed y SearchGreedy First:try to move to nodes that are as close tothe goal as possibleD o not know true cost to goal, so justuse the estimate hWant to implement Expand small hfirst : simply use f = h
P ROC EDUR E Greedy( problem)return BestFS( problem, h )
-
8/6/2019 Intro to Astar
17/26
Greed y SearchD ives inwhat hsays isthe bestdirection
T his
directionis just anestimateand canbe wrong
goal
outline of graph
start
-
8/6/2019 Intro to Astar
18/26
Properties of Greed y SearchIncomplete: if nodes are not checked for revisiting thenit can be incomplete it can get stuck in a loop.Nonoptimalit y: sometimes the best short -term decisionis sub -optimal in the long term not surprising because it ignores the actual path cost g
P ractical: It is often a good wa y to solve big problems it is fast the memor y usage is small because the search dives towards a
solution (this makes it more like Depth -First Search) often the solutions are acceptable even when sub -optimalSelf -Stud y: Carefull y go through the map of Romaniaexamples in heuristic -searches.htm in the heuristicsearches section or the course notes
-
8/6/2019 Intro to Astar
19/26
P erfect Information SearchSuppose that by magic (by an oraclein C S parlance) we knew the T rue
minimum cost from any node N to thegoalI.e. suppose we know h T (n)In UC S we can expect to know g T (n)T rue min cost, f T(n) for going via n ,
fT (n) = g T(n) + h T(n)
-
8/6/2019 Intro to Astar
20/26
P erfect Information SearchSupposing that could use the true costin the search, we could do
BestFS( problem, f T(n) )Properties: it would never expand a node that was not on
some minimum cost path because such non perfect nodes will never be at the front
of the queue the search would never make a mistake
-
8/6/2019 Intro to Astar
21/26
Comparisons1. UC S: BestFS( g )
complete, optimal, high memor y usage
2. Perfect-Info: BestFS( g T (n) + h T(n) )complete, optimal, low memor y usage
3. Greedy: BestFS( h )incomplete, suboptimal, low memor y usage
-
8/6/2019 Intro to Astar
22/26
A* SearchC annot implement Perfect Info!T ry to get best combination use g (n) : best path cost so far use heuristic h (n), as do not have the true h T(n)
A* Search is B estFS ( g + h )
T hat is, define f(n) = g(n) + h(n) estimated minimum cost via n and use BestFS ( f (n) )
-
8/6/2019 Intro to Astar
23/26
Effects of h choicesT wo extreme cases h= 0 A* becomes UCS : complete&optimal but search
pattern undirected
h too large : if h is large enough to dominate g thenbecomes like Greed y. uses less memor y but lose optimalit y.U sually when we say A* we exclude the lastcase, and imply that we have an:
Admissible Heuristic: h(n) h T (n) we never over -estimate distance h(n) must provide a valid lower bound on cost to the goal the g term does not get swamped and misled, but the
search pattern improves A* is complete and optimal, and memor y usage can be
much lower than UCS
-
8/6/2019 Intro to Astar
24/26
A* with Admissible HeuristicC omplete and O ptimal Search as for Uniform Cost Search
Search Pattern seeks out goals Reduced memor y and time usage
It is good on maps/graphsIt is essential on planning and puzzles
-
8/6/2019 Intro to Astar
25/26
Summar yBest First Search similar to Uniform Cost Search but with a general score derived
from g and h Greed y Search: use h onl y dive towards goals, but can miss best
paths A* search with Admissible Heuristic
Self-study: heuristic searches section of the websiteExpectations: Given an example,
e,g, a map or graph or a small planning problem or puzzle,
then you should be able to work through what BestFirst, UCS,Greed y, and A* would doN ext lecture: T he example of A* in astar.ppt
-
8/6/2019 Intro to Astar
26/26
Questions?
top related