1 / 56

Uninformed Search: Basic Definitions and Techniques

Learn about the basics of uninformed search, including problem formulation, state space, operators, and goal tests. Discover how to code these techniques in Lisp.

morpheus
Download Presentation

Uninformed Search: Basic Definitions and Techniques

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. Everyday – search examples • Searching for the shortest route to RP? • Searching for your keys? • Searching for classes to take? • Searching for where the party is? • Searching for the best way to pack your car/truck when you move?

  2. Industry – search examples • Searching for ways to break a code? • Searching for ways to configure wireless antennae? • Searching for ways to set up the pipeline to transport oil/gas/water? • Searching for ways to schedule your workers? • Searching for ways to configure the shop floor?

  3. Today’s lecture • Uninformed search • Why is it called ‘uninformed’? • What are the search techniques? • How does the algorithm work? • How do you code these in lisp?

  4. Search • Basic definitions • Basic terms

  5. Problem solving by search Represent the problem as STATES and OPERATORSthat transform one state into another state. A solution to the problem is an OPERATOR SEQUENCE that transforms the INITIAL STATE into a GOAL STATE. Finding the sequence requires SEARCHING the STATE SPACE by GENERATINGthe paths connecting the two.

  6. 9 l 5 l 3 l Example: Measuring problem– water jug problem! • Problem: Using these three buckets, measure 7 liters of water.

  7. 9 l 5 l 3 l Example: Measuring problem! A c B

  8. 9 l 5 l 3 l Example: Measuring problem! • Another Solution: A B C 0 0 0 start 0 5 0 3 2 0 3 0 2 3 5 2 3 0 7goal A B C

  9. Which solution do we prefer? • Solution 1: • A B C • 0 0 0 start • 3 0 0 • 0 0 3 • 3 0 3 • 0 0 6 • 3 0 6 • 0 3 6 • 3 3 6 • 1 5 6 • 0 5 7 goal • Solution 2: • A B C • 0 0 0 start • 0 5 0 • 3 2 0 • 3 0 2 • 3 5 2 • 3 0 7goal

  10. Ok…Let’s review • What was the initial state? • What was the goal state? • What was the set of operations that took us from the initial state to the goal state? • What is the path that, if followed, would get us from the initial state to the goal state? • What would be the STATE SPACE?

  11. Basic concepts (1) • State: finiterepresentation of the world that you want to explore at a given time. • Operator: a function that transforms a state into another (also called rule, transition, successor function, production, action). • Initial state: The problem at the beginning. • Goal state: desired end state (can be several) • Goal test: test to determine if the goal has been reached. • Solution Path: The sequence of actions that get you from the initial state to the goal state.

  12. Basic concepts (2) • Reachable goal: a state for which there exists a sequence of operators to reach it. • State space: set of all reachable states from initial state (possibly infinite). • Cost function: a function that assigns a cost to each operation. • Performance (not for ALL uninformed): • cost of the final operator sequence • cost of finding the sequence

  13. Problem formulation • The first task is to formulate the problem in terms of states and operators • Some problems can be naturally defined this way, others not! • Formulation makes a big difference! • Examples: • water jug problem, tic-tac-toe, 8-puzzle, 8-queen problem, cryptoarithmetic • robot world, travelling salesman, parts assembly

  14. Example 1: water jug (1) Given 3 jugs (9, 5 and 3 liters), a water pump, and a sink, how do you get exactly 7 liters into the 9 liter jug? 9 5 3 Jug 3 Jug 2 Jug 1 Pump Sink • State: (x y z) for liters in jugs 1, 2, and 3 integers 0 to 9 assigned to all possible permutations of 1 2 3 • Operations: empty jug, fill jug, EX. (fill (0 5 0)) • Initial state: (0 0 0) • Goal state: (x x 7) • Solution seqence (5 0 0 (0 5 0 (0 0 0 etc….)

  15. Example 2: cryptoarithmetic Assign numbers to letters so that the sum is correct Solution F=2, O=9 R=7, T=8 Y=6, E=5 N=0, I=1 X=4 F O R T Y + T E N + T E N S I X T Y 2 9 7 8 6 + 8 5 0 + 8 5 0 3 1 4 8 6 • State space: All letters and all numbers assigned to the letters • Operations: replace all occurrences of a letter with a digit not already there • Initial State: Letters that make words, integers • Goal State: only digits, sum is correct • Solution: F= 2, etc. see above

  16. Example 4: 8-queens • State: any arrangement of up to 8 queens on the board • Operation: add a queen (incremental), move a queen (fix-it) • Initial state: no queens on board • Goal state: 8 queens, with no queen is attacked • Solution Path: The set of operations that allowed you to get to the The board that you see above at the indicated positions.

  17. Example: 8-puzzle • State: • Operators: • Goal test: • Solution path: start state goal state

  18. Example: 8-puzzle • Operators: moving blank left, right, up, down (ignore jamming) • Goal test: goal state • State: integer location of tiles (ignore intermediate locations) • Solution: move 4 tile to blank, move 1 tile blank, etc. start state goal state

  19. A different Problem • http://www.cs.wisc.edu/~jgast/cs540/sample/8puzzle.html • Initial State • State: • Operators: • Goal test:

  20. How do we represent the problem in Lisp? Data structures? • State: a list of lists, or a series of property lists • Node: • state, depth level • # of predecesors, list of cconnected nodes • # of successors, list of cconnected nodes • Edge: the cdr of the list or the get of the property…may also have a cost associated with it. • Operation: taking things off the list (or getting the property of a node, matching function • Queue or stack or list of lists to keep states to be expanded

  21. Tree for water jug problem b a (0,0,0) (0,3,0) (4,0, 0) b a (4,3,0) (4,3,0) (0,0,0) (3,0,0) (0,0,0) (1,3,0) (0,3,0) (1,0,0) (4,0,0) (4,3,0)

  22. Search algorithms • Basic idea: • offline, systematic exploration of simulated state-space by generating successors of explored states (expanding) Function General-Search(problem, strategy) returns a solution, or failure initialize the search tree using the initial state problem loop do if there are no candidates for expansion then return failure choose a leaf node for expansion according to some strategy if the node contains a goal state then return the corresponding solution else expand the node and add resulting nodes to the search tree end

  23. Implementation of search algorithms Function General-Search(problem, Queuing-Fn) returns a solution, or failure nodes  make-queue(make-node(initial-state[problem])) loop do if node is empty then return failure node  Remove-Front(nodes) if Goal-Test[problem] applied to State(node) succeeds then return node nodes  Queuing-Fn(nodes, Expand(node, Operators[problem])) end Queuing-Fn(queue, elements) is a queuing function that inserts a set of elements into the queue and determines the order of node expansion. Varieties of the queuing function produce varieties of the search algorithm.

  24. Evaluation of search strategies • Search algorithms are commonly evaluated according to the following four criteria: • Completeness: does it always find a solution if one exists? • Time complexity: how long does it take as a function of number of nodes? • Space complexity: how much memory does it require? • Optimality: does it guarantee the least-cost solution? • Time and space complexity are measured in terms of: • b – max branching factor of the search tree • d – depth of the least-cost solution • m – max depth of the state-space (may be infinity)

  25. Uninformed search strategies Use only information available in the problem formulation • Breadth-first • Depth-first • Depth-limited • Iterative deepening • Uniform Cost • Bi-Directional

  26. Search • Breadth-First Search

  27. Breath-first search Expand the tree in successive layers, uniformly looking at all nodes at level n before progressing to level n+1 function Breath-First-Search(problem) returns solution nodes := Make-Queue(Make-Node(Initial-State(problem)) loop do if nodes is empty then return failure node := Remove-Front (nodes) if Goal-Test[problem] applied to State(node) succeeds then returnnode new-nodes := Expand (node, Operators[problem])) nodes := Insert-At-End-of-Queue(new-nodes) end

  28. Another Breath-first search S A D B D A E C E E B B F 11 D F B F C E A C G 14 17 15 15 13 G C G F 19 19 17 G 25

  29. Properties of breadth-first search • Completeness: (Does it always find a solution?) • Time complexity: (How long does it take?) • Space complexity: (How much memory does it take?) • Optimality: (It always finds the shortest path)

  30. Properties of breadth-first search • Completeness: Yes, if b is finite • Time complexity: O(b d), i.e., exponential in d (Rem: b is no. of branches) • Space complexity: O(b d), keeps every node in memory • Optimality: Yes, if cost = 1 per step; not optimal in general

  31. Depth-first

  32. Depth first search Dive into the search tree as far as you can, backing up only when there is no way to proceed function Depth-First-Search(problem) returns solution nodes := Make-Queue(Make-Node(Initial-State(problem)) loop do if nodes is empty then return failure node := Remove-Front (nodes) if Goal-Test[problem] applied to State(node) succeeds then returnnode new-nodes := Expand (node, Operarors[problem])) nodes := Insert-At-Front-of-Queue(new-nodes) end

  33. Depth-first search S A D B D A E C E E B B F 11 D F B F C E A C G 14 17 15 15 13 G C G F 19 19 17 G 25

  34. Properties of depth-first search • Completeness: No, fails in infinite state-space • Time complexity: O(b m) • Space complexity: O(bm) • Optimality: No – it may never find the path!

  35. Examples • Graphs • http://www.cs.duke.edu/csed/jawaa/JAWAA.html

More Related