Solving problems by searching - PowerPoint PPT Presentation

1 / 45
About This Presentation
Title:

Solving problems by searching

Description:

Solving problems by searching Chapter 3, part 2 Modified by Vali Derhami */45 Iterative deepening search l =3 */45 Iterative deepening search Number of nodes ... – PowerPoint PPT presentation

Number of Views:70
Avg rating:3.0/5.0
Slides: 46
Provided by: MinY236
Category:

less

Transcript and Presenter's Notes

Title: Solving problems by searching


1
Solving problems by searching
  • Chapter 3, part 2
  • Modified by Vali Derhami

2
Implementation general tree search
  • ?????? ??? ?? ?????? ??? ???? ????? ?? ????
    ???????? ?????.
  • ????? ????? ?? ??? ???? ??? ???????.
  • ??? ??? ??????? ? ??? ?? ??

3
Implementation general tree search
  • The operations on a queue are as follows
  • MAKE-QUEUE(elemen,...) creates a queue with the
    given element(s).
  • EMPTY?(queue) returns true only if there are no
    more elements in the queue.
  • FlRST(queue) returns the first element of the
    queue.
  • REMOVE-FiRST (queue) returns First(queue) and
    removes it from the queue.
  • lNSERT(element, queue) inserts an element into
    the queue and returns the resulting queue. (We
    will see that different types of queues insert
    elements in different orders.)
  • Insert- ALL(elements, queue) inserts a set of
    elements into the queue and returns the resulting
    queue.

4
Implementation general tree search
5
Search strategies
  • A search 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 How long does it take to find
    solution (number of nodes generated)
  • space complexity How much memory is needed to
    perform the search? maximum number of nodes in
    memory
  • optimality does it always find a optimal
    solution?
  • Time and space complexity are measured in terms
    of
  • b maximum branching factor of the search tree
  • ?????? ????? ???? ??? ?? ????
  • d depth of the least-cost solution
  • ?? ???? ??? ???.
  • m maximum depth of the state space (may be 8)
  • ?????? ???? ???? ?? ???? ????

6
Uninformed search strategies
  • Uninformed search strategies use only the
    information available in the problem definition
    Breadth-first search Uniform-cost search Depth-fir
    st search Depth-limited search Iterative deepening
    search

7
Breadth-first search?????? ??? ???
  • Expand shallowest unexpanded node
  • ????? ???? ???? ???? ??? ??? ????? ??????
  • Implementation
  • fringe is a FIFO queue, i.e., new successors go
    at end

8
Breadth-first search?????? ??? ???
  • Expand shallowest unexpanded node
  • ????? ???? ???? ???? ??? ??? ????? ??????
  • Implementation
  • fringe is a FIFO queue, i.e., new successors go
    at end

9
Breadth-first search?????? ??? ???
  • Expand shallowest unexpanded node
  • ????? ???? ???? ???? ??? ??? ????? ??????
  • Implementation
  • fringe is a FIFO queue, i.e., new successors go
    at end

10
Breadth-first search?????? ??? ???
  • Expand shallowest unexpanded node
  • ????? ???? ???? ???? ??? ??? ????? ??????
  • Implementation
  • fringe is a FIFO queue, i.e., new successors go
    at end

11
Properties of breadth-first search
  • Complete? Yes (if b is finite)
  • Time?
  • ????? ??? ??? ????? ???bb2b3 bd b(bd-1)
    O(bd1)
  • Space? O(bd1) (keeps every node in memory)
    Optimal? Yes (if cost 1 per step)
  • Space is the bigger problem (more than time)
    ????? ?? ?????? ??????? ????? ?? ?? ???? ?????
    ??? ???? ???? ?????? ????????? ???? ?? ??????

12
(No Transcript)
13
Uniform-cost search?????? ????? ???????
  • Expand least-cost unexpanded nodeImplementation
  • fringe queue ordered by path cost
  • Equivalent to breadth-first if step costs all
    equal Complete? Yes, if step cost e Time? of n
    odes with g cost of optimal solution,
    O(b1(C/ e)) where C is the cost of the
    optimal solution
  • O(b1(C/ e)) can be much greater than O(bd)
  • Space? of nodes with g cost of optimal
    solution,
  • O(b (C/ e))Optimal? Yes if step cost e

14
Depth-first search?????? ??? ???
  • Expand deepest unexpanded node ????? ???? ???? ???
    ????? ??????
  • Implementation
  • fringe LIFO queue, i.e., put successors at
    front

15
Depth-first search
  • Expand deepest unexpanded nodeImplementation
  • fringe LIFO queue, i.e., put successors at
    front

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
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 d
  • m?????? ??? ?? ???
  • but if solutions are dense, may be much faster
    than breadth-first
  • Space? bm1, O(bm), i.e., linear space!
    Optimal? No

27
Depth-first search
  • Back tracking search A type of Depth- firt
    search
  • Back Traking only one successor is generated at
    a time rather than all successors
  • Space O(m)

28
Depth-limited search
  • depth-first search with depth limit l,i.e.,
    nodes at depth l
  • ??? dgtl ????? ???? ???? ??? ??? m ????? ????
  • ??? dltl ?????? ??? ??? ????? ???.
  • Time? O(b l ),
  • Space? bl1, O(bl),
  • L8 gt Depth firth

29
Depth-limited search
  • Recursive implementation

30
Iterative deepening search?????? ???? ?????
??????
?????? ??? ??? ?? ?????? ??????? ??? ?? ?? ??????
?????? ??????? ?? ????? ?? ?? ??? ??? ??? ????.
?????? ?? ?? ??? ??? ??? ? ?????? ??? ???.
31
Iterative deepening search l 0
32
Iterative deepening search l 1
33
Iterative deepening search l 2
34
Iterative deepening search l 3
35
Iterative deepening search
  • Number of nodes generated in a depth-limited
    search to depth d with branching factor b
  • NDLS b1 b2 bd-2 bd-1 bd
  • Number of nodes generated in an iterative
    deepening search to depth d with branching factor
    b
  • NIDS d b1 (d-1)b2 3bd-2 2bd-1 1bd
  • For b 10, d 5,
  • NIDS 50 400 3,000 20,000 100,000
    123,450
  • NBFS 10 100 1,000 10,000 100,000
    999,990 1,111,100.
  • Overhead (123,456 - 111,111)/111,111 11

36
Properties of iterative deepening search
  • Complete? Yes
  • Time? d b1 (d-1)b2 bd O(bd)
  • Space? O(bd)
  • Optimal? Yes, if step cost 1

37
Bidirectional search?????? ?? ????
  • ????? ?????? ?????? ??? ?? ???? ????? ?? ??? ???
    ? ????? ?? ??? ?? ??? ???
  • ???? ???? ?? ?? ????? ?? ?? ?? ????.
  • Time O(bd/2) O(bd/2) O(bd/2) ltlt O(bd)
  • Space O(bd/2)
  • ??????? ??? ?? ??? ???? ?? ??? ???.
  • Complete and optimal (for uniform step costs) if
    both searches are breadth-first other
    combinations may sacrifice completeness,
    optimality, or both.

38
Summary of algorithms
39
Repeated states
  • Failure to detect repeated states can turn a
    linear problem into an exponential one!

40
Graph search
41
????? ?????
  • 1- ????? ?? ?????
  • ?? ???? ??? ???? ? ????? ???? ???? Deterministic,
    fully observable
  • ???? ??????? ???? (Global information)?? ???? ?
    ??? ?????? ??? ?? ?? ????.
  • 2- ????? ???? ?? ?? (?????) (??? ????? ?? ??????
    ?? ???.)
  • ?? ??????? ????
  • ???? ????? ???? ??? ?? ??????? ??? ??? ?????? ???
    ?? ?? ????.
  • 3- ????? ??????? Contingency
  • ???? ???? ???? ???? ? ?? ??? ????
  • ???? ??? ?????? ??? ?? ??? ????.
  • ??? ??????? ???? ?? ????? ???? ???? ????? ??
    ?????? (Adversarial) ?????.
  • 4- ????? ??????? exploration Problem
  • ?????? ? ??????? ????????

42
Example vacuum world
  • Single-state, start in 5. Solution?

43
Example vacuum world
  • Single-state, start in 5. Solution? Right,
    Suck
  • Sensorless, start in 1,2,3,4,5,6,7,8 e.g.,
    Right goes to 2,4,6,8 Solution?

44
Example vacuum world
  • Sensorless, start in 1,2,3,4,5,6,7,8 e.g.,
    Right goes to 2,4,6,8 Solution?
    Right,Suck,Left,Suck
  • Contingency
  • Nondeterministic Suck may dirty a clean carpet
  • Partially observable location, dirt at current
    location.
  • Percept L, Clean, i.e., start in 5 or
    7Solution?

45
Example vacuum world
  • Sensorless, start in 1,2,3,4,5,6,7,8 e.g.,
    Right goes to 2,4,6,8 Solution?
    Right,Suck,Left,Suck
  • Contingency
  • Nondeterministic Suck may dirty a clean carpet
  • Partially observable location, dirt at current
    location.
  • Percept L, Clean, i.e., start in 5 or
    7Solution? Right, if dirt then Suck
Write a Comment
User Comments (0)
About PowerShow.com