1 / 75

760 likes | 950 Views

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.

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

**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**• 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**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?**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**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**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.**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”)**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.**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.**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.**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.**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.**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.**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.**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.**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**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**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**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**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**Implementing optimal search strategies**• Uniform cost • Pick best (measured by path length) element of Q • Add path extensions anywhere in Q**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**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**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**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**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.**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.**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.**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.**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.**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.**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.**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.**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**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**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**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**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!**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!**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!**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!**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!**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!**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!**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!**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