Upload
others
View
17
Download
0
Embed Size (px)
Citation preview
HEURISTIC SEARCH STRATEGIES • Informed (Heuris7c) search strategy—one that uses problem-‐specific knowledge beyond the defini9on of the problem itself—can find solu9ons more efficiently than can an uninformed strategy.
• Most algorithms include a heuris7c func7on, denoted by h(n), where h(n) = es9mated cost of the cheapest path from the state at node n to a goal state.
• For example, in Romania, one might es9mate the cost of the cheapest path from Arad to Bucharest via the straight-‐line distance func7on.
Tuesday 25 February 20 1
Greedy best-‐first search • Greedy best-‐first search tries to expand the node that is closest to the goal by
using the straight-‐ line distance heuris9c hSLD. If the goal is Bucharest, we need to know the straight-‐line distances to Bucharest, which are shown in Figure on RHS.
Tuesday 25 February 20 2
Greedy best-‐first search • Following Figure shows the
progress of a greedy best-‐first search using hSLD
• It is not op9mal as the path via Sibiu and Fagaras to Bucharest is 32 kilometers longer than the path through Rimnicu Vilcea and Pites9.
• This shows why the algorithm is called “greedy”—at each step it tries to get as close to the goal as it can.
Tuesday 25 February 20 3
Greedy best-‐first search // This pseudocode is adapted from below // source: //hYps://courses.cs.washington.edu/ Best-‐First-‐Search(Grah g, Node start)
1) Create an empty PriorityQueue PriorityQueue pq; 2) Insert "start" in pq. pq.insert(start) 3) Un9l PriorityQueue is empty u = PriorityQueue.DeleteMin If u is the goal Exit Else Foreach neighbor v of u If v "Unvisited" Mark v "Visited" pq.insert(v) Mark u "Examined"
End procedure
Tuesday 25 February 20 4
Proper7es of greedy search • Complete?? No–it can get stuck in loops, e.g., Iasi → Neamt → Iasi →
Neamt → … if we want to reach from Lasi to Fagaras. – Complete in finite space with repeated-‐state checking (Graph Search)
• Time?? O(bm), but a good heuris9c can give drama9c improvement • Space?? O(bm)—keeps all nodes in memory • Op9mal?? No
• With a good heuris9c func9on, however, the complexity can be reduced substan9ally.
Tuesday 25 February 20 5
A* search • Idea: avoid expanding paths that are already expensive.
– Evalua9on func9on f(n) = g(n) + h(n) – g(n) = cost so far to reach n
h(n) = es9mated cost to goal from n f(n) = es9mated total cost of path through n to goal
• A∗ search uses an admissible heuris9c: – hSLD(n) never overes9mates the actual road distance.
Tuesday 25 February 20 6
Tuesday 25 February 20 7
Following figure explain it’s execu9on using the informa9on given in previous two figures.
Tuesday 25 February 20 8
Pseudo code for A* search
Proper7es of A∗ • Complete?? Yes, unless there are infinitely many nodes.
• Time?? O(bεm)—where ε = (h∗ − h)/h∗ is the rela9ve error in h. where h* is the op9mal heuris9c, the exact cost to get from x to the goal. – If h = 0, then ε = 1 and we get uniform-‐cost search – If h = h∗, then it is perfect and we find the solu9on immediately
• Space?? O(bm)—it keeps all nodes in memory
• Op7mal?? Yes – A∗ expands all nodes with f(n) < C∗ – A∗ expands some nodes with f(n) = C∗ – A∗ expands no nodes with f(n) > C∗
Tuesday 25 February 20 9
Issues in A* search • Exponen9al complexity of A∗ with respect to depth of goal
oven makes it imprac9cal in finding an op9mal solu9on.
• Computa9on 9me is not the main drawback of A∗. As A* keeps all generated nodes in memory (as do all GRAPH-‐SEARCH algorithms), and usually runs out of space long before it runs out of 9me.
• For this reason, A∗ is not prac9cal for many large-‐scale problems.
Tuesday 25 February 20 10
Read it Yourself • 3.5.3 Memory-‐bounded heuris9c search • 3.5.4 Learning to search beYer • 3.6 Heuris9c func9ons
Tuesday 25 February 20 11
Lab Work No.3
• Design a program for the greedy best first search and A* search – Implement the greedy best first search using the following link hYps://www.geeksforgeeks.org/best-‐first-‐search-‐informed-‐search/
– Implement the A* search using the following link hYps://www.geeksforgeeks.org/a-‐search-‐algorithm/