1 / 61

The next RP deliverable

The next RP deliverable. 20. Review: Generate and Test Paradigm. Propose possible solutions then test whether each proposal constitutes a solution Will illustrate with n-Queens problem. n-Queens Problem. n-Queens are to be placed on an n x n board

tevin
Download Presentation

The next RP deliverable

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. The next RP deliverable 20

  2. Review: Generate and Test Paradigm • Propose possible solutions then test whether each proposal constitutes a solution • Will illustrate with n-Queens problem

  3. n-Queens Problem • n-Queens are to be placed on an n x n board • No two Queens should occupy the same row, column or diagonal • Example with a 4 x 4 board with 4 Queens

  4. Exhaustive Enumeration • A search methodology that looks everywhere for a solution to a problem (consider all 1820 combos in the 4-queens problem). • A partial solution is developed further even after it has been discovered that this set of steps cannot possibly lead to a successful problem solution

  5. Backtracking • An improvement to exhaustive enumeration • A proposed solution is divided into stages • In the 4-Queens problem, placing each queen on the board is a stage • In Stage i, Queens have been successfully placed in columns 1,…, i-1 • If no square remains on which the ith Queen may be placed that does not violate any of the constraints, then we must return to Stage i-1

  6. Backtracking / cont. • Undo the placement of the Queen at Stage i-1, make the next choice for this Queen, and return to Stage i. If it is not possible to successfully place the (i-1)st Queen, then backtracking continues to Stage i-2 • Can use Backtracking with Generate and Test • The Generator will attempt to place a Queen in each column. • The Test module will view a possible solution as it is being developed. • The algorithm contains four stages.

  7. Artificial Intelligence in the 21st CenturyS. Lucci / D. Kopec • Chapter 2:Uninformed Search

  8. Blind Search Algorithms • AKA Tree Search Algorithms (although this can be somewhat misleading as we will see later)

  9. Tree Search Algorithms • Basic idea:offline, simulated exploration of state spaceby generating successors of already-explored states (a.k.a. expanding states)

  10. Tree Search Example

  11. Tree Search Example

  12. Tree Search Example

  13. Blind Search Algorithms • AKA Tree Search Algorithms (although this can be somewhat misleading as we will see later) • Three principal algorithms (but each may have variations) • depth first search (dfs) • breadth first search (bfs) • depth first search with iterative deepening (dfs-id) • Two key properties • They do not use heuristics • Their aim is to find some solution to a problem

  14. Heuristics A heuristic is a “a rule of thumb” for solving a problem. This is to be contrasted with an algorithm which is a definite, effective procedure guaranteed to solve a problem. A heuristic may be helpful in solving a problem but it does not guarantee a solution. In the context of searches, a heuristic is an estimate of how close you are to the goal state.

  15. Depth First Search • Attempts to plunge as deeply into a tree as quickly as possible • If there is a choice, it selects the leftmost branch

  16. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  17. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  18. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  19. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  20. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  21. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  22. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  23. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  24. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  25. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  26. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  27. Depth-First Search • Expand deepest unexpanded nodeImplementation: fringe = LIFO queue, I.e., put successors at front

  28. Implementing Search • Searches are implemented by maintaining two lists: • open list – list of nodes still being explored • closed list – list of nodes already explored and no longer under consideration • The differences between strategies effect the management of the open list • Depth first search is accomplished by maintaining the open list as a stack (Consult Chapter 2, p 63)

  29. Implementing dfs Algorithm stops once it reaches the goal at G1

  30. Questions?

  31. Breadth First Search • Nodes are visited from the top of the tree to the bottom, from left to right • All nodes on level i are visited before any nodes on level i+1 are visited

  32. Breadth-First Search • Expanding shallowest unexpanded nodeImplementation fringe is a FIFO queue, i.e., new successors go at end

  33. Breadth-First Search • Expanding shallowest unexpanded nodeImplementation fringe is a FIFO queue, i.e., new successors go at end

  34. Breadth-First Search • Expanding shallowest unexpanded nodeImplementation fringe is a FIFO queue, i.e., new successors go at end

  35. Breadth-First Search • Expanding shallowest unexpanded nodeImplementation fringe is a FIFO queue, i.e., new successors go at end

  36. Recall: Implementing Search • Searches are implemented by maintaining two lists: • open list – list of nodes still being explored • closed list – list of nodes already explored and no longer under consideration • The differences between strategies effect the management of the open list • Breadth first search is accomplished by maintaining the open list as a queue(Consult Chapter 2, p 65)

  37. Implementing bfs Algorithm stops once goal G1 is reached .

  38. Questions?

  39. Measuring Problem Solving Performance • Completeness – an algorithm is complete when it is guaranteed to find a solution when there is one • Optimality – an algorithm is optimal if it provides the lowest cost path amongst all solutions • Time Complexity – measured in the number of nodes generated during the search • Space Complexity – how much memory is required to perform the search. We must also determine the maximum number of nodes

  40. The Branching Factor • The branching factor of a node is the number of branches emanating from it The branching factor of A is three • If every node in a search tree has a branching factor of b, then the branching factor of the tree is b

  41. Branching Factor / cont. • d : this parameter measures the depth of the shallowest goal node • m : this parameter measures the maximum length of any path

  42. This is how far we made it before we ran out of time.

  43. Properties of Depth-first Search • Complete??

  44. Properties of Depth-first Search • Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces

  45. Properties of Depth-first Search • Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces • Optimal??

  46. Properties of Depth-first Search • Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces • Optimal?? No.

  47. Properties of Depth-first Search • Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces • Optimal?? No. • Time??

  48. Properties of Depth-first Search • Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces • Optimal?? No. • Time?? O(bm): terrible if m is much larger than dbut if solutions are dense, may be much faster than breadth-first

  49. Properties of Depth-first Search • Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces • Optimal?? No. • Time?? O(bm): terrible if m is much larger than dbut if solutions are dense, may be much faster than breadth-first • Space??

  50. Properties of Depth-first Search • Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces • Optimal?? No. • Time?? O(bm): terrible if m is much larger than dbut if solutions are dense, may be much faster than breadth-first • Space?? O(bm), I.e., linear space!

More Related