280 likes | 300 Views
Learn how to design heuristic functions to mimic different search algorithms behavior such as Uniform Cost Search, BFS, and more. Understand the principles behind A* search and its variations.
E N D
Q1.1 Describe a heuristic estimating function that will make A* search behave exactly like uniform-cost search for a given cost function.
Q1.1 – When A* search Like UCS • We know: • A* expands nodes with minimal f(n) = g(n) + h(n). • UCS expands nodes with minimal path cost g(n). • Then: • For h(n) = 0 or constant A* Expands nodes with minimal path cost g(n) i.e. A* behave like UCS.
Q1.2 Describe a heuristic estimating function that will make greedy search behave like breadth-first search.
Q1.2 – When Greedy search Like BFS • We know: • Greedy search expand nodes with minimal h(n). • Then, If h(n) = d(n) where d(n) is the depth of node n: • Nodes will be expanded according to increasing values of depth i.e. the shallowest before the deepest i.e. like BFS.
Q2 proof that If h(n) is consistent, then the values of f(n) along any path are non-decreasing.
Q2 - h(n) consistent : f(n) non-decreasing. • We know in A*: • F(n) = g(n) + h(n) • If n’ successor of n g(n’) = g(n) + c(n,a,n’) • if h(n) consistent h(n) < c(n,a,n’) + h(n’). • Then: • F(n’) = g(n’) + h(n’) • F(n’) = g(n) + c(n,a,n’) + h(n’) • F(n’) = g(n) + c(n,a,n’) + h(n’) >= g(n) + h(n) • F(n’) >= F(n) i.e. nodes expanding is non-decreasing order of [f(n)].
Q3 Trace BFS, DFS, IDS and UCS …
BFS • Final Closed List [A B C D E] • Solution path A B D G • Order of node expansion A B C A C D A B D E B C G
DFS • Final Closed List [A B C D] • Solution path A B C D G • Order of node expansion A B A C A B D B C G
IDS • D=0 • Final Closed List [A] • Solution Failure • Order of node expansion A • D=1 • Final Closed List [ABC] • Solution Failure • Order of node expansion A B C
IDS cont • D=2 • Final Closed List [ABCDE] • Solution Failure • Order of node expansion A B A C D C A B D E • D=3 • Final Closed List [ABCD] • Solution pathA B C D G • Order of node expansion A B A C A B D B C G
UCS • Final Closed List [A0 C2 B5 D5 E5] • Solution path [A0 C2 D5 G6] • Order of node expansion A0 C2 A4 B5 B5 D5 E5 G6
Q4 Prove…
Q4.1 – BFS special of UCS • We know: • When step costs are the same UCS expands with minimal path cost. • Then: • Path costs will increase in depth. • Nodes of the same level have equal path cost. • Path cost of nodes at level I is less than path cost of nodes at level i+1. • Then: • UCS will expand shallowest nodes before deepest, i.e. like the case of BFS.
Q4.2.1 – BFS special of Best First search • We know: • Best first search expands nodes with minimal f(n). • Using Q1.2 Greedy search behave like BFS when h(n) = d(n) f(n) = d(n) BFS is a special case of Greedy search. • Greedy search is a best first search. • Then: • BFS is a special case of Best First search.
Q4.2.2 – DFS special of Best First search • We know: • Best first search expands nodes with minimal f(n). • If h(n) = 1/d(n) Greedy search will expand deepest nodes before shallowest behave like DFS i.e. DFS is a special case of Greedy search. • Greedy search is a best first search. • Then: • BFS is a special case of Best First search.
Q4.2.3 – UCS special of Best First search • We know: • Best first search expands nodes with minimal f(n). • Using Q1.1 A* behave like UCS when h(n) = 0 f(n) = g(n) UCS is a special case of A*. • A* is a best first search. • Then: • UCS is a special case of Best First search.
Q4.3 – UCS special of A* search • Same as Q4.2.3.
G e f d c b a Q5 Answer questions on the figure…
Q5.1 – Complete States G e 4 f 3 d c 2 1 b a
G e f d c b a Q5.2 – Which better (DFS or BFS) • DFS… a b d 1 a 2 3 4 1 b 2 c 1 . . . Repeated States Infinite Loop!
G e f d c b a Q5.2 – Which better (DFS or BFS) • BFS… a b d 1 a a 3 4 . . . . . . e d f c d e b 2 2 2 3 4 1 . . . . . . . . . . . . . . . 1 3 G 3 1 4 3 G G . . . . 2 e f d • Complete!
G e 4 f 3 d 5.3 – More Suitable Technique c 2 1 b a Try A* technique
Example…g(n) 1 5 G e 4 2 2 1 2 f 3 d 5 2 5 c 3 1 2 1 1 b a 6
Example…h(n) 6 5 0 G e 4 6 2 f 3 d 5 3 c 6 4 2 1 8 b a 5
6 6 5 2 1 D 4 E 5 0 1 2 G 3 2 5 2 5 3 F 8 A 2 6 2 6 5 4 A*: Final Closed List [A D 3 B 4 E F 1] Solution path A D 3 E G Order of node expansion A D 3 B 4 D E F 1 E G 1 B 1 5 1 C 3