Professional Documents
Culture Documents
PLEASE NOTE
MONDAY OCT 30th NO FORMAL LECTURE! Question & Answer instead
(you ask the questions!), especially regarding the coursework(s).
Bring Questions!
With that
Study this map of Romania. the two cities takes between cities and try and calculate The optimal route between Note the distances us through Rimnicu and Pitesti. the shortest route between Sibiu and Bucharest. Then press space to see the Press space to continue with the slideshow. optimal route marked in red. Neamt
Zerind 75 71 Oradea 87 Iasi 92 Vaslui Sibiu 80 Lugoj 70 Mehadia 146 75 Dobreta 120 Craiova 138 Rimnicu 97 Pitesti 101 211 Urziceni 86 98 Hirsova 99 Faragas 142
Arad
140 118 Timisoara 111
Bucharest
90 Giurgui
86
Eforie
ANIMATION OF UCS.
3.Faragas 4.Arad 5.Pitesti 6.Zerind 7.Craiova 9.Bucharest 278 GOAL!! Fringe in RED with g Visited in BLUE 87 Iasi 92 Vaslui 142 Hirsova Neamt 8.Timisoara
71
286 Oradea
Arad
118
Timisoara 80 111 258 80 211 Lugoj Rimnicu 98 Urziceni 369 177 86 70 97 Pitesti Mehadia 146 101 Bucharest 75 138 310 (F) Dobreta 278 (R,P) 90 226 (R) 120 Craiova 336 [315 (R,P)] Giurgui
86
Eforie
Remarks
We expanded Arad and Zerind even though they are in totally the wrong direction! The search pattern was expanding concentric circles
increasing cost
Heuristic Search
Desired Search Pattern: biased in direction of goal(s) Fringe in red Visited in blue When reaches goal will have had to explore less of the graph Reduces time and memory usage outline of graph goal start
increasing cost
Heuristic Search
Want to achieve this pattern but stay
complete optimal outline of graph goal start
If bias the search too much then could miss goals or miss shorter paths
increasing cost
outline of graph
start
goal
increasing cost
Heuristic Search
Suppose have some estimates, h , of the cost from a (fringe) node to the goal Want to favour small h Expand A first? outline of graph hA hB goal
start
gA gB
A B
increasing cost
BestFS is same as UCS except use f(n) instead of just g(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 alternatively, instead of REMOVE-FIRST, just scan all queue and use REMOVE-SMALLEST-SCORE
EXPAND(node) // Lf is set of neighbours with their f values // obtained using SCORE_FN fringe INSERT-IF-NEW(Lf, fringe ) // ignore revisited nodes // unless they are better Lf
Greedy Search
Greedy First: try to move to nodes that are as close to the goal as possible Do not know true cost to goal, so just use the estimate h Want to implement Expand small h first : simply use f = h PROCEDURE Greedy( problem) return BestFS( problem, h )
Greedy Search
Dives in what h says is the best direction This direction is just an estimate and can be wrong
outline of graph goal start
Self-Study: Carefully go through the map of Romania examples in heuristic-searches.htm in the heuristic searches section or the course notes
Comparisons
1. UCS: BestFS( g )
complete, optimal, high memory usage
3. Greedy:
BestFS(
A* Search
Cannot implement Perfect Info! Try to get best combination
use g(n) : best path cost so far use heuristic h(n), as do not have the true hT(n)
A* Search is
BestFS( g + h )
Effects of h choices
Two extreme cases
h=0 A* becomes UCS : complete&optimal but search pattern undirected h too large : if h is large enough to dominate g then becomes like Greedy. uses less memory but lose optimality.
Usually when we say A* we exclude the last case, and imply that we have an: Admissible Heuristic: h(n) hT(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 memory usage can be much lower than UCS
Summary
Best First Search
similar to Uniform Cost Search but with a general score derived from g and h Greedy Search: use h only dive towards goals, but can miss best paths A* search with Admissible Heuristic
then you should be able to work through what BestFirst, UCS, Greedy, and A* would do
Questions?