Un Unin info form rmed ed Se Sear arch ch Computer ter Sc - - PowerPoint PPT Presentation

un unin info form rmed ed se sear arch ch
SMART_READER_LITE
LIVE PREVIEW

Un Unin info form rmed ed Se Sear arch ch Computer ter Sc - - PowerPoint PPT Presentation

Un Unin info form rmed ed Se Sear arch ch Computer ter Sc Science ce cpsc3 c322 22, , Lectur ture e 5 (Te Textb xtbook ok Ch Chpt 3.5) January, ary, 13, 2010 CPSC 322, Lecture 5 Slide 1 Of Offi fice ce Hours rs


slide-1
SLIDE 1

CPSC 322, Lecture 5 Slide 1

Un Unin info form rmed ed Se Sear arch ch

Computer ter Sc Science ce cpsc3 c322 22, , Lectur ture e 5 (Te Textb xtbook

  • k Ch

Chpt 3.5)

January, ary, 13, 2010

slide-2
SLIDE 2

CPSC 322, Lecture 1 Slide 2

Of Offi fice ce Hours rs

  • Giuse

sepp ppe e Ca Carenini ( carenini@cs.ubc.ca; office CICSR 129)

Te Teachin hing g As Assista stants nts

  • Ha

Hammad ad Ali Ali hammada@cs.ubc.ca

  • Ke

Kenneth eth Al Alton kalton@cs.ubc.ca (will be starting Jan 18)

  • Scott

tt He Helmer shelmer@cs.ubc.ca

  • Sunjeet

et Singh sstatla@cs.ubc.ca

slide-3
SLIDE 3

CPSC 322, Lecture 4 Slide 3

  • Search is a key computational mechanism in

many AI agents

  • We will study the basic principles of search on the

simple determ rmini inistic stic planning ing agent t model Generic ric search ch approac ach:

  • define a search space graph,
  • start from current state,
  • incrementally explore paths from current state until goal

state is reached.

Recap cap

slide-4
SLIDE 4

CPSC 322, Lecture 5 Slide 4

Se Search chin ing: g: Graph Se Search Al Algorithm thm with three e bugs 

Input: a graph, a start node, Boolean procedure goal(n) that tests if n is a goal node. frontier := { g: g is a goal node }; while le frontier is not empty: selec lect and remov move path n0, n1, …, nk from frontier; if if goal(nk) return turn nk ; for ever ery neighbor n of nk add add  n0, n1, …, nk  to frontier; end d while

  • The goal

function defines what is a solution.

  • The neighbor relationship defines the graph.
  • Which path is selected from the frontier defines the

search strategy.

slide-5
SLIDE 5

CPSC 322, Lecture 5 Slide 5

Lecture cture Ov Overview view

  • Re

Recap ap

  • Criteria to compare Search Strategies
  • Simple (Uninformed) Search

Strategies

  • Depth First
  • Breadth First
slide-6
SLIDE 6

CPSC 322, Lecture 5 Slide 6

Com

  • mpa

paring ring Sea earchi hing ng Alg lgor

  • rit

ithms: hms: wil ill l it it fi find nd a a sol

  • lut

ution ion? ? th the bes e best t on

  • ne?

e?

De Def. . (complet lete): e): A search algorithm is complete ete if, whenever at least one solution exists, the algorithm is guarante nteed d to find a solutio tion within a finite amount of time. De Def. . (optim imal) al): : A search algorithm is optimal al if, when it finds a solution , it is the best solution

slide-7
SLIDE 7

CPSC 322, Lecture 5 Slide 7

Com

  • mpa

paring ring Se Sear archi hing ng Al Algo gorit ithms: hms: Com

  • mpl

plex exity ity

De Def. . (time me complexity) xity) The time complexity xity of a search algorithm is an expression for the wo worst-case case amount of time it will take to run,

  • expressed in terms of the maximum

um path length m and the maximum mum branchin hing g factor tor b. De Def. . (space ce comple lexity) xity) : The space comple lexity xity of a search algorithm is an expression for the wo worst-case case amount of memory that the algorithm will use (number of nodes),

  • Also expressed in terms of m and

and b.

slide-8
SLIDE 8

CPSC 322, Lecture 5 Slide 8

Lecture cture Ov Overview view

  • Re

Recap ap

  • Criteria to compare Search Strategies
  • Simple (Uninformed) Search

Strategies

  • Depth First
  • Breadth First
slide-9
SLIDE 9

CPSC 322, Lecture 5 Slide 9

Depth pth-first first Search: rch: DFS FS

  • Depth-fir

first st search ch treats the frontier as a stack ck

  • It always selects one of the last elements added

to the frontier. Example:

  • the frontier is [p1, p2, …, pr]
  • neighbors of last node of p1 (its end) are {n1, …, nk}
  • What happens?
  • p1 is selected, and its end is tested for being a goal.
  • New paths are created attaching {n1, …, nk} to p1
  • These “replace” p1 at the beginning of the frontier.
  • Thus, the frontier is now [(p1, n1), …, (p1, nk), p2, …, pr] .
  • NOTE: p2 is only selected when all paths extending p1 have been

explored.

slide-10
SLIDE 10

CPSC 322, Lecture 5 Slide 10

Dept pth-first irst sear arch: ch: Illustrat trative ive Graph ph ---

  • -- Depth-first

irst Searc rch Front ntier ier

slide-11
SLIDE 11

CPSC 322, Lecture 5 Slide 11

Depth-fir first st Se Search: h: An Analysi sis s of DFS FS

  • Is DFS complete?
  • Depth-first search isn't guaranteed to halt on graphs with cycles.
  • However, DFS is

is complete for finite acyclic graphs.

  • Is DFS optimal?
  • What is the time complexity, if the maximum path length is m

and the maximum branching factor is b ?

  • The time complexity is ? ?: must examine every node in the

tree.

  • Search is unconstrained by the goal until it happens to stumble on the

goal.

  • What is the space complexity?
  • Space complexity is ? ? the longest possible path is m, and for

every node in that path must maintain a fringe of size b.

slide-12
SLIDE 12

CPSC 322, Lecture 5 Slide 12

Appropri

  • priate

ate

  • Space is restricted (complex state representation e.g.,

robotics)

  • There are many solutions, perhaps with long path lengths,

particularly for the case in which all paths lead to a solution

Dep epth th-firs first t Sea earch: h: Whe hen it n it is is ap appr prop

  • pria

iate? te?

Inappropriate propriate

  • Cycles
  • There are shallow solutions
slide-13
SLIDE 13

CPSC 322, Lecture 5 Slide 13

Why hy D DFS ne need ed to to be be s stu tudi died ed an and und d under ersto tood

  • d?
  • It is simple enough to allow you to learn the basic

aspects of searching (When compared with breadth first)

  • It is the basis for a number of more sophisticated /

useful search algorithms

slide-14
SLIDE 14

CPSC 322, Lecture 5 Slide 14

Lecture cture Ov Overview view

  • Re

Recap ap

  • Simple (Uninformed) Search

Strategies

  • Depth First
  • Breadth First
slide-15
SLIDE 15

CPSC 322, Lecture 5 Slide 15

Breadth eadth-first first Search: rch: BFS FS

  • Breadth-first search treats the frontier as a queue

queue

  • it always selects one of the earliest elements added to the frontier.

Example:

  • the frontier is [p1,p2, …, pr]
  • neighbors of the last node of p1 are {n1, …, nk}
  • What happens?
  • p1 is selected, and its end tested for being a path to the goal.
  • New paths are created attaching {n1, …, nk} to p1
  • These follow pr at the end of the frontier.
  • Thus, the frontier is now [p2, …, pr, (p1, n1), …, (p1, nk)].
  • p2 is selected next.
slide-16
SLIDE 16

CPSC 322, Lecture 5 Slide 16

Il Illust lustrat rative ive Gr Graph h - Breadth adth-first first Search rch

slide-17
SLIDE 17

CPSC 322, Lecture 5 Slide 17

Analysi alysis s of f Breadth adth-First First Search rch

  • Is BFS complete?
  • Yes
  • In fact, BFS is guaranteed to find the path that involves the fewest

arcs (why?)

  • What is the time complexity, if the maximum path length is

m and the maximum branching factor is b?

  • The time complexity is ? ? must examine every node in the

tree.

  • The order in which we examine nodes (BFS or DFS) makes no

difference to the worst case: search is unconstrained by the goal.

  • What is the space complexity?
  • Space complexity is ? ?
slide-18
SLIDE 18

CPSC 322, Lecture 5 Slide 18

Using ing Breadth adth-first first Search rch

  • When is BFS appropriate?
  • space is not a problem
  • it's necessary to find the solution with the fewest arcs
  • although all solutions may not be shallow, at least some

are

  • When is BFS inappropriate?
  • space is limited
  • all solutions tend to be located deep in the tree
  • the branching factor is very large
slide-19
SLIDE 19

CPSC 322, Lecture 5 Slide 19

What t have e we done e so fa far?

AI agents can be very complex and sophisticated Let’s start from a very simple one, the determin inis istic ic, , goal goal-dri drive ven n agent for which: he sequence of actions and their appropriate ordering is the solution GO GOAL AL: study dy search ch, , a set of basic ic methods ds underly rlyin ing g many intell llig igen ent t agents ts We have looked d at two search ch strate ategi gies es DFS FS and BF BFS: S:

  • To understand key properties of a search strategy
  • They represent the basis for more sophisticated

(heuristic / intelligent) search

slide-20
SLIDE 20
  • Apply basic properties of search algorithms:

completeness, optimality, time and space complexity of search algorithms.

  • Select the most appropriate search algorithms for

specific problems.

  • BFS vs DFS vs IDS vs BidirS-
  • LCFS vs. BFS –
  • A* vs. B&B vs IDA* vs MBA*

CPSC 322, Lecture 5 Slide 20

Learning Goals for today’s class

slide-21
SLIDE 21

CPSC 322, Lecture 5 Slide 21

Next xt Class ss

  • Search with cost
  • Start Heuristic Search

(textbook.: start 3.6)

slide-22
SLIDE 22

CPSC 322, Lecture 5 Slide 22

Heu euristics istics Dep epth th-firs first t Sea earch

  • What is still left unspecified by DFS?

1 3 8 2 4 7 6 5 1 3 8 2 4 7 6 5 8 1 3 2 4 7 6 5