Problem Solving as Search - PowerPoint PPT Presentation

1 / 50
About This Presentation
Title:

Problem Solving as Search

Description:

Want to cross a river using one canoe. Canoe can hold up to two people. ... We can show number of cannibals, missionaries and canoes on each side of the river. ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 51
Provided by: systema178
Category:

less

Transcript and Presenter's Notes

Title: Problem Solving as Search


1
Problem Solving as Search
2
Problem Types
  • Deterministic, fully observable ? single-state
    problem
  • Non-observable ? conformant problem
  • Nondeterministic and/or partially observable ?
    contingency problem
  • Unknown state space ? exploration problem

3
A Starter Activity
  • Cannibals and Missionaries
  • Three missionaries and three cannibals
  • Want to cross a river using one canoe.
  • Canoe can hold up to two people.
  • Can never be more cannibals than missionaries on
    either side of the river.
  • Get all safely across the river without any
    missionaries being eaten.
  • Find a solution

4
Single-State Problem Formulation
  • A problem is defined by four items
  • initial state
  • successor function (which actually defines all
    reachable states)
  • goal test
  • path cost (additive) e.g., sum of distances,
    number of actions executed, etc. C(x,a,y) is the
    step cost, assumed to be ? 0

5
Problem Representation Cannibals and
Missionaries
  • Initial State
  • We can show number of cannibals, missionaries and
    canoes on each side of the river.
  • Start state is therefore
  • 3,3,1,0,0,0

6
Problem Representation Cannibals and
Missionaries
  • Initial State
  • However, since the system is closed, we only need
    to represent one side of the river, as we can
    deduce the other side.
  • We will represent the finishing side of the
    river, and omit the starting side.
  • So start state is
  • 0,0,0

7
Problem Representation Cannibals and
Missionaries
  • Successor Function
  • There are five actions we can represent
  • Move one cannibal across the river.
  • Move two cannibals across the river.
  • Move one missionary across the river.
  • Move two missionaries across the river.
  • Move one missionary and one cannibal.

8
Problem Representation Cannibals and
Missionaries
  • Successor Function
  • To be a little more mathematical/computer like,
    we want to represent this in a true successor
    function format
  • S(state) ? state
  • Move one cannibal across the river.
  • S(x,y,0) ? x1,y,1
  • S(x,y,1) ? x-1,y,0
  • Note, this is a slight simplification.
  • Obviously, 0 ? x, y, x1, and x-1 ? 3

9
Problem Representation Cannibals and
Missionaries
  • Successor Function
  • S(x,y,0) ? x1,y,1
  • S(x,y,1) ? x-1,y,0
  • S(x,y,0) ? x2,y,1
  • S(x,y,1) ? x-2,y,0
  • S(x,y,0) ? x,y1,1
  • S(x,y,1) ? x,y-1,0
  • S(x,y,0) ? x,y2,1
  • S(x,y,1) ? x,y-2,0
  • S(x,y,0) ? x1,y1,1
  • S(x,y,1) ? x-1,y-1,0

10
Problem Representation Cannibals and
Missionaries
  • Successor Function
  • S(x,y,0) ? x1,y,1 , x2,y,1 , x,y1,1 ,
    x,y2,1 , x1,y1,1
  • S(x,y,1) ? x-1,y,0 , x-2,y,0 , x,y-1,0 ,
    x,y-2,0 , x-1,y-1,0
  • Where valid states a,b,c are those such that
  • 0 ? a ? 3
  • 0 ? b ? 3
  • 0 ? c ? 1

11
Problem Representation Cannibals and
Missionaries
  • Successor Function
  • S(x,y,0) ? x1,y,1 , x2,y,1 , x,y1,1 ,
    x,y2,1 , x1,y1,1
  • S(x,y,1) ? x-1,y,0 , x-2,y,0 , x,y-1,0 ,
    x,y-2,0 , x-1,y-1,0
  • Where valid states a,b,c are those such that
  • 0 ? a ? 3
  • 0 ? b ? 3
  • 0 ? c ? 1
  • Actually one more set of constraints we will
    get to later.

12
Problem Representation Cannibals and
Missionaries
  • Goal State
  • 3,3,1

13
Problem Representation Cannibals and
Missionaries
  • Path Cost
  • One unit per trip across the river.

14
Problem Representation Cannibals and
Missionaries
  • Initial State
  • 0,0,0
  • Successor Function
  • S(x,y,0) ? x1,y,1 , x2,y,1 , x,y1,1 ,
    x,y2,1 , x1,y1,1
  • S(x,y,1) ? x-1,y,0 , x-2,y,0 , x,y-1,0 ,
    x,y-2,0 , x-1,y-1,0
  • Goal State
  • 3,3,1
  • Path Cost
  • One unit per trip across the river.

15
Tree Search Algorithms
  • Basic ideaoffline, simulated exploration of
    state spaceby generating successors of
    already-explored states (a.k.a. expanding states)

16
Tree Search Example
17
Tree Search Example
18
Tree Search Example
19
Implementation States vs. Nodes
  • A state is a representation of a physical
    configuration
  • A node is a data structure constituting part of a
    search tree
  • includes parent, children, depth, path cost g(x)
  • States do not have parents, children, depth, or
    path cost!

20
Implementation States vs. Nodes
  • The EXPAND function creates new nodes, filling in
    the various fields and using the SUCCESSORFN of
    the problem to create the corresponding states.

21
Search Strategies
  • A strategy is defined by picking the order of
    node expansion
  • Strategies are evaluated along the following
    dimensions completeness does it always find
    a solution if one exists? time
    complexity number of nodes
    generated/expanded space complexity maximum
    number of nodes in memory optimality
    does it always find a least-cost
    solution

22
Search Strategies
  • Time and space complexity are measured in terms
    of b maximum branching factor of the search
    treed depth of the least-cost solutionm
    maximum depth of the state space (may be infinite)

23
Uninformed Search Strategies
  • Uninformed strategies use only information
    available in the problem definition
  • Breadth-first search
  • Uniform-cost search
  • Depth-first search
  • Depth-limited search
  • Iterative deepening search

24
Uninformed Search Strategies
  • Uninformed strategies use only information
    available in the problem definition
  • Breadth-first search
  • Uniform-cost search
  • Depth-first search
  • Depth-limited search
  • Iterative deepening search

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

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

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

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

29
Properties of Breadth-First Search
  • Complete??

30
Properties of Breadth-First Search
  • Complete?? Yes (if b is finite)
  • Time??

31
Properties of Breadth-First Search
  • Complete?? Yes (if b is finite)
  • Time?? 1 b b2 b3 bd b(bd 1) O(
    bd1 ), ie, exp. in d
  • Space??

32
Properties of Breadth-First Search
  • Complete?? Yes (if b is finite)
  • Time?? 1 b b2 b3 bd b(bd 1) O(
    bd1 ), ie, exp. in d
  • Space?? O( bd1 ) (keep every node in memory)
  • Optimal??

33
Properties of Breadth-First Search
  • Complete?? Yes (if b is finite)
  • Time?? 1 b b2 b3 bd b(bd 1) O(
    bd1 ), ie, exp. in d
  • Space?? O( bd1 ) (keep every node in memory)
  • Optimal?? Yes (if cost 1 per step) not optimal
    in general
  • Space is the big problem can easily generate
    nodes at 10MB/sec, so 24hours 860GB.

34
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

35
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

36
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

37
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

38
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

39
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

40
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

41
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

42
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

43
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

44
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

45
Depth-First Search
  • Expand deepest unexpanded nodeImplementation f
    ringe LIFO queue, I.e., put successors
    at front

46
Properties of Depth-first Search
  • Complete??

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
  • 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
  • Time?? O(bm) terrible if m is much larger than
    dbut if solutions are dense, may be much faster
    than breadth-first
  • Space??

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
  • 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!
  • Optimal??

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
  • 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!
  • Optimal?? No.
Write a Comment
User Comments (0)
About PowerShow.com