1 / 75

Course: Engineering Artificial Intelligence

Course: Engineering Artificial Intelligence. Dr. Radu Marinescu. Lecture 3. Classes of search. Any path search Uninformed search Informed search Optimal path search Uninformed search Informed search. Recap: Problem solving paradigm.

bethan
Download Presentation

Course: Engineering Artificial Intelligence

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Course:Engineering Artificial Intelligence Dr. Radu Marinescu Lecture 3

  2. Classes of search • Any path search • Uninformed search • Informed search • Optimal path search • Uninformed search • Informed search

  3. Recap: Problem solving paradigm • What are the states? (All relevant aspects of the problem) • Arrangement of parts (to plan an assembly) • Positions of trucks (to plan package distribution) • Cities (to plan a trip) • Set of facts (e.g., to prove a mathematical theorem) • What are the actions(operators)? (deterministic, discrete) • Assemble two parts • Move a truck to a new position • Fly to a new city • Apply a theorem to derive a new fact • What is the goaltest? (Condition for success) • All parts in place • All packages delivered • Reached destination city • Derived goal fact

  4. Recap: Sliding tile puzzle state space

  5. Recap: Search algorithms • Basic idea • Exploration of state space graph by generating successors of already-explored states (a.k.a. expanding states) • Every states is evaluated: is it a goal state?

  6. Recap: Terminology • A state is a (representation of) a physical configuration • A node is a data structure constituting part of a search tree contains info such as: state, parent node, action, path costg(x), depth

  7. Recap: Simple search algorithm • A search node is a path from some state X to the start state, e.g., (X B A S) • The state of a search node is the most recent state of the path, e.g., X • Let Q be a list of search nodes, e.g., ((X B A S) (C B A S) …) • Let S be the start state • Initialize Q with search node (S) as only entry, set Visited = (S) • If Q is empty, fail. Else, pick some node N from Q • If state(N) is goal, return N (we’ve reached the goal) • (Otherwise) Remove N from Q • Find all descendants of state(N) not in Visited and create all the one-step extensions of N to each descendant • Add the extended paths to Q; add children of state(N) to Visited • Go to step 2. Critical decisions: Step 2: picking N from Q Step 6: adding extensions of N to Q

  8. Classes of search

  9. Terminology • Heuristic – the word generally refers to a “rule of thumb”, something that may be helpful in some cases but not always. Generally held to be in contrast to “guaranteed” or “optimal” • Heuristic function – in search terms, a function that computes a value for a state (but does not depend on any path to that state) that may be helpful in guiding the search • Estimated distance to goal – this type of heuristic function depends on the state and the goal. The classic example is straight-line distance used as an estimate for actual distance in a road network. This type of information can help increase the efficiency of search.

  10. Implementing the search strategies • Depth-first • Pick first element of Q • Add path extensions to front of Q • Breadth-first • Pick first element of Q • Add path extensions to end of Q • Best-first (Greedy) • Pick “best” (measured by heuristic value of state) element of Q • Add path extensions anywhere in Q (it may be more efficient to keep Q ordered in some way to make it easier to find the “best”)

  11. Implementation issue: finding the best node • There are many possible approaches to finding the best node in Q • Scanning Q to find lowest value • Sorting Q and picking the first element • Keeping Q sorted by doing “sorted” insertions • Keeping Q as a priority queue • Which of these is best will depend among other things on how many children nodes have on average.

  12. Best-First Pick best (by heuristic value) element of Q; Add path extensions anywhere in Q C G A Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0 D S B Added paths in blue; heuristic value of node’s state is in front. We show the paths in reversedorder; the node’s state is the first entry.

  13. Best-First Pick best (by heuristic value) element of Q; Add path extensions anywhere in Q 1 C G A Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0 D S B Added paths in blue; heuristic value of node’s state is in front. We show the paths in reversedorder; the node’s state is the first entry.

  14. Best-First Pick best (by heuristic value) element of Q; Add path extensions anywhere in Q 2 1 C G A Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0 D S B Added paths in blue; heuristic value of node’s state is in front. We show the paths in reversedorder; the node’s state is the first entry.

  15. Best-First Pick best (by heuristic value) element of Q; Add path extensions anywhere in Q 3 2 1 C G A Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0 D S B Added paths in blue; heuristic value of node’s state is in front. We show the paths in reversedorder; the node’s state is the first entry.

  16. Best-First Pick best (by heuristic value) element of Q; Add path extensions anywhere in Q 3 2 1 C G 4 A Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0 D S B Added paths in blue; heuristic value of node’s state is in front. We show the paths in reversedorder; the node’s state is the first entry.

  17. Best-First Pick best (by heuristic value) element of Q; Add path extensions anywhere in Q 3 5 2 1 C G 4 A Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0 D S B Added paths in blue; heuristic value of node’s state is in front. We show the paths in reversedorder; the node’s state is the first entry.

  18. Best-First Pick best (by heuristic value) element of Q; Add path extensions anywhere in Q 3 5 2 1 C G 4 A Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0 D S B Added paths in blue; heuristic value of node’s state is in front. We show the paths in reversedorder; the node’s state is the first entry.

  19. Classes of search

  20. Simple search algorithm • A search node is a path from some state X to the start state, e.g., (X B A S) • The state of a search node is the most recent state of the path, e.g., X • Let Q be a list of search nodes, e.g., ((X B A S) (C B A S) …) • Let S be the start state • Initialize Q with search node (S) as only entry, set Visited = (S) • If Q is empty, fail. Else, pick some node N from Q • If state(N) is goal, return N (we’ve reached the goal) • (Otherwise) Remove N from Q • Find all descendants of state(N) not in Visited and create all the one-step extensions of N to each descendant • Add the extended paths to Q; add children of state(N) to Visited • Go to step 2. Critical decisions: Step 2: picking N from Q Step 6: adding extensions of N to Q

  21. Simple search algorithm • A search node is a path from some state X to the start state, e.g., (X B A S) • The state of a search node is the most recent state of the path, e.g., X • Let Q be a list of search nodes, e.g., ((X B A S) (C B A S) …) • Let S be the start state • Initialize Q with search node (S) as only entry, set Visited = (S) • If Q is empty, fail. Else, pick some node N from Q • If state(N) is goal, return N (we’ve reached the goal) • (Otherwise) Remove N from Q • Find all descendants of state(N) not in Visited and create all the one-step extensions of N to each descendant • Add the extended paths to Q; add children of state(N) to Visited • Go to step 2. Don’t use Visited for optimal search Critical decisions: Step 2: picking N from Q Step 6: adding extensions of N to Q

  22. Why not a Visited list? • For the any-path algorithms, the Visited list would not cause us to fail to find a path when one existed, since the path to a state did not matter • However, the Visited list in connection with optimal searches can cause us to miss the best path

  23. Why not a Visited list? • For the any-path algorithms, the Visited list would not cause us to fail to find a path when one existed, since the path to a state did not matter • However, the Visited list in connection with optimal searches can cause us to miss the best path • The shortest path from S to G is • (S A D G) 1 A 2 G D 4 S

  24. Why not a Visited list? • For the any-path algorithms, the Visited list would not cause us to fail to find a path when one existed, since the path to a state did not matter • However, the Visited list in connection with optimal searches can cause us to miss the best path • The shortest path from S to G is • (S A D G) • But, when extending (S), A and D • would be added to the Visited list and • so (S A) would not be extended to • (S A D) 1 A 2 G D 4 S

  25. Implementing optimal search strategies • Uniform cost • Pick best (measured by path length) element of Q • Add path extensions anywhere in Q

  26. Uniform Cost • Like best-first except that is uses the “total length (cost)” of a path instead of a heuristic value of the state • Each link has a “length” or “cost” (which is always > 0) • We want “shortest” or “least cost” path C G 2 A 3 2 4 D 2 5 S 1 B 5

  27. Uniform Cost • Like best-first except that is uses the “total length (cost)” of a path instead of a heuristic value of the state • Each link has a “length” or “cost” (which is always > 0) • We want “shortest” or “least cost” path Total path cost: (S A C) 4 C G 2 A 3 2 4 D 2 5 S 1 B 5

  28. Uniform Cost • Like best-first except that is uses the “total length (cost)” of a path instead of a heuristic value of the state • Each link has a “length” or “cost” (which is always > 0) • We want “shortest” or “least cost” path Total path cost: (S A C) 4 (S B D G) 8 C G 2 A 3 2 4 D 2 5 S 1 B 5

  29. Uniform Cost • Like best-first except that is uses the “total length (cost)” of a path instead of a heuristic value of the state • Each link has a “length” or “cost” (which is always > 0) • We want “shortest” or “least cost” path Total path cost: (S A C) 4 (S B D G) 8 (S A D C) 9 C G 2 A 3 2 4 D 2 5 S 1 B 5

  30. Uniform Cost Pick best (by path length) element of Q; Add path extensions anywhere in Q 1 C G 2 A 3 2 4 D 2 5 S 1 B 5 Added paths in blue; underlined paths are chosen for extension. We show the paths in reversedorder; the node’s state is the first entry.

  31. Uniform Cost Pick best (by path length) element of Q; Add path extensions anywhere in Q 2 1 C G 2 A 3 2 4 D 2 5 S 1 B 5 Added paths in blue; underlined paths are chosen for extension. We show the paths in reversedorder; the node’s state is the first entry.

  32. Uniform Cost Pick best (by path length) element of Q; Add path extensions anywhere in Q 3 2 1 C G 2 A 3 2 4 D 2 5 S 1 B 5 Added paths in blue; underlined paths are chosen for extension. We show the paths in reversedorder; the node’s state is the first entry.

  33. Uniform Cost Pick best (by path length) element of Q; Add path extensions anywhere in Q 3 2 1 C G 2 4 A 3 2 4 D 2 5 S 1 B 5 Added paths in blue; underlined paths are chosen for extension. We show the paths in reversedorder; the node’s state is the first entry.

  34. Uniform Cost Pick best (by path length) element of Q; Add path extensions anywhere in Q 3 2 5 1 C G 2 4 A 3 2 4 D 2 5 S 1 B 5 Added paths in blue; underlined paths are chosen for extension. We show the paths in reversedorder; the node’s state is the first entry.

  35. Uniform Cost Pick best (by path length) element of Q; Add path extensions anywhere in Q 3 2 5,6 1 C G 2 4 A 3 2 4 D 2 5 S 1 B 5 Added paths in blue; underlined paths are chosen for extension. We show the paths in reversedorder; the node’s state is the first entry.

  36. Uniform Cost Pick best (by path length) element of Q; Add path extensions anywhere in Q 3 7 2 5,6 1 C G 2 4 A 3 2 4 D 2 5 S 1 B 5 Added paths in blue; underlined paths are chosen for extension. We show the paths in reversedorder; the node’s state is the first entry.

  37. Uniform Cost Pick best (by path length) element of Q; Add path extensions anywhere in Q 3 7 2 5,6 1 C G 2 4 A 3 2 4 D 2 Shortest path (S A D G) with length 8 5 S 1 B 5 Added paths in blue; underlined paths are chosen for extension. We show the paths in reversedorder; the node’s state is the first entry.

  38. Why not stop on first generating a goal? • When doing Uniform Cost, it is not correct to stop the search when the first path to a goal is generated, that is, when a node whose state is a goal is added to Q

  39. Why not stop on first generating a goal? • When doing Uniform Cost, it is not correct to stop the search when the first path to a goal is generated, that is, when a node whose state is a goal is added to Q • We must wait until such a path is pulled off the Q and tested in step 3. It is only at this point that we are sure it is the shortest path to a goal since there are no other shortest paths that remain unexpanded

  40. Why not stop on first generating a goal? • When doing Uniform Cost, it is not correct to stop the search when the first path to a goal is generated, that is, when a node whose state is a goal is added to Q • We must wait until such a path is pulled off the Q and tested in step 3. It is only at this point that we are sure it is the shortest path to a goal since there are no other shortest paths that remain unexpanded • This contrasts with the non-optimal searches where the choice of whether to test for a goal was a matter of convenience and efficiency, not correctness

  41. Why not stop on first generating a goal? • When doing Uniform Cost, it is not correct to stop the search when the first path to a goal is generated, that is, when a node whose state is a goal is added to Q • We must wait until such a path is pulled off the Q and tested in step 3. It is only at this point that we are sure it is the shortest path to a goal since there are no other shortest paths that remain unexpanded • This contrasts with the non-optimal searches where the choice of whether to test for a goal was a matter of convenience and efficiency, not correctness • In the previous example, a path to G was generated at step 5, but it was a different, shorter, path at step 7 that we accepted

  42. Uniform Cost: another (easier?) way to see it S B 2 5 A 6 4 6 10 D G D C 9 8 9 8 C G C G C G Total path cost 2 A 3 2 4 D 2 5 S 1 B 5 UC enumerates paths in order of total path cost!

  43. Uniform Cost: another (easier?) way to see it 1 S B 2 5 A 6 4 6 10 D G D C 1 9 8 9 8 C G C G C G Total path cost 2 A 3 Order pulled off of Q (expanded) 2 4 D 2 5 S 1 B 5 UC enumerates paths in order of total path cost!

  44. Uniform Cost: another (easier?) way to see it 1 S 2 B 2 5 A 2 6 4 6 10 D G D C 1 9 8 9 8 C G C G C G Total path cost 2 A 3 Order pulled off of Q (expanded) 2 4 D 2 5 S 1 B 5 UC enumerates paths in order of total path cost!

  45. Uniform Cost: another (easier?) way to see it 1 S 3 2 B 2 5 A 2 3 6 4 6 10 D G D C 1 9 8 9 8 C G C G C G Total path cost 2 A 3 Order pulled off of Q (expanded) 2 4 D 2 5 S 1 B 5 UC enumerates paths in order of total path cost!

  46. Uniform Cost: another (easier?) way to see it 1 S 3 4 2 B 2 5 A 2 3 6 4 6 10 D G D C 1 9 8 9 8 C G C G C G Total path cost 2 4 A 3 Order pulled off of Q (expanded) 2 4 D 2 5 S 1 B 5 UC enumerates paths in order of total path cost!

  47. Uniform Cost: another (easier?) way to see it 1 S 3 4 2 B 2 5 A 2 5 3 6 4 6 10 D G D C 5 1 9 8 9 8 C G C G C G Total path cost 2 4 A 3 Order pulled off of Q (expanded) 2 4 D 2 5 S 1 B 5 UC enumerates paths in order of total path cost!

  48. Uniform Cost: another (easier?) way to see it 1 S 3 4 2 B 2 5 A 2 6 5 3 6 4 6 10 D G D C 5,6 1 9 8 9 8 C G C G C G Total path cost 2 4 A 3 Order pulled off of Q (expanded) 2 4 D 2 5 S 1 B 5 UC enumerates paths in order of total path cost!

  49. Uniform Cost: another (easier?) way to see it 1 S 3 4 2 7 B 2 5 A 2 6 5 3 6 4 6 10 D G D C 5,6 7 1 9 8 9 8 C G C G C G Total path cost 2 4 A 3 Order pulled off of Q (expanded) 2 4 D 2 5 S 1 B 5 UC enumerates paths in order of total path cost!

  50. Uniform Cost: another (easier?) way to see it 1 S 3 4 2 7 B 2 5 A 2 6 5 3 6 4 6 10 D G D C 5,6 7 1 9 8 9 8 C G C G C G Total path cost 2 4 A 3 Order pulled off of Q (expanded) 2 4 D 2 5 S 1 B 5 UC enumerates paths in order of total path cost!

More Related