Graduate AI Lecture 2: Search I Instructors: Nihar B. Shah (this - - PowerPoint PPT Presentation

graduate ai
SMART_READER_LITE
LIVE PREVIEW

Graduate AI Lecture 2: Search I Instructors: Nihar B. Shah (this - - PowerPoint PPT Presentation

Graduate AI Lecture 2: Search I Instructors: Nihar B. Shah (this time) J. Zico Kolter E XAMPLE : P ATHFINDING Best route? 2 E XAMPLE : 8-P UZZLE Fewest moves? 5 2 1 2 3 6 1 3 4 5 6 7 8 4 7 8 15780 Spring 2019: Lecture 2


slide-1
SLIDE 1

Graduate AI

Lecture 2: Search I

Instructors: Nihar B. Shah (this time)

  • J. Zico Kolter
slide-2
SLIDE 2

EXAMPLE: PATHFINDING

2

Best route?

slide-3
SLIDE 3

15780 Spring 2019: Lecture 2

EXAMPLE: 8-PUZZLE

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

Fewest “moves”?

slide-4
SLIDE 4

15780 Spring 2019: Lecture 2

SEARCH PROBLEMS

  • A search problem has:
  • States (configurations)
  • Start state and goal states
  • Successors: mapping of states to

(action,state,cost) triples

4

High-level objective: Find minimum-cost path from s to t in a computationally efficient manner

slide-5
SLIDE 5

EXAMPLE: PATHFINDING

5

! "

slide-6
SLIDE 6

EXAMPLE: PATHFINDING

6

! "

slide-7
SLIDE 7

EXAMPLE: PATHFINDING

7

! "

slide-8
SLIDE 8

EXAMPLE: PATHFINDING

8

! " 3 2 4 1

slide-9
SLIDE 9

15780 Spring 2019: Lecture 2

GRAPH REPRESENTATION

Cost ≥ 0 between each pair of vertices x & y

9

# $ % & '

1 3 2 5 1 1 1

! "

High-level objective: Find minimum-cost path from s to t in a computationally efficient manner

starting state goal

slide-10
SLIDE 10

15780 Spring 2019: Lecture 2

EXAMPLE: 8-PUZZLE

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

s t

1 1

slide-11
SLIDE 11

15780 Spring 2019: Lecture 2

TREE SEARCH

Inputs:

  • Problem instance
  • “Expansion strategy”

Output:

  • Path from s to t

11

slide-12
SLIDE 12

15780 Spring 2019: Lecture 2

RECALL: BREADTH FIRST SEARCH

  • Graph with each cost 1

12

# $ % & '

1 1 1 1 1 1

, = 0 , = 1

#

, = 2

$

, = 2

&

, = 2

'

1

#1 #2 #3

! " !

  • Define , 0 = cost till 0
  • Expansion strategy: Expand node with minimum g

, = 3

%

slide-13
SLIDE 13

15780 Spring 2019: Lecture 2

TREE SEARCH

function TREE-SEARCH(problem, strategy) set of frontier nodes contains the start state of problem loop

  • if there are no frontier nodes then return failure
  • choose a frontier node for expansion using strategy
  • if the chosen node is t then return the corresponding solution
  • else expand the node and add the resulting nodes to the set
  • f frontier nodes

13

slide-14
SLIDE 14

15780 Spring 2019: Lecture 2

UNIFORM COST SEARCH ALGORITHM

Define , 0 = cost till 0 Strategy: Expand node with smallest ,

14

# $ % & '

1 3 2 5 1 1

, = 0 , = 1

#

, = 2

$

, = 4

&

, = 6

'

, = 3

%

, = 6

1

, = 7

&

#1 #2 #3 #4 #5 #6 #7

! " ! "

s a d s a e d Frontier:

slide-15
SLIDE 15

15780 Spring 2019: Lecture 2

UNINFORMED VS. INFORMED

  • Uniform cost search uses no information about

the problem other than the edge costs

  • “Uninformed” search
  • Often we may have more information…
  • “Informed” search

15

slide-16
SLIDE 16

EXAMPLE: PATHFINDING

16

! "

“Going this direction is generally a good idea”

slide-17
SLIDE 17

15780 Spring 2019: Lecture 2

EXAMPLE: 8-PUZZLE

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

“Having more blocks in their correct position is generally a good idea”

slide-18
SLIDE 18

15780 Spring 2019: Lecture 2

INFORMED SEARCH

  • Additional information: For each vertex 0, given

ℎ 0 = heuristic evaluation of cost from 0 to t

  • ℎ " = 0

18

# $ % & '

1 3 2 5 1 1 1

ℎ = 6 ℎ = 5 ℎ = 2 ℎ = 0 ℎ = 1 ℎ = 6 ℎ = 7

! "

slide-19
SLIDE 19

15780 Spring 2019: Lecture 2

GREEDY SEARCH USING HEURISTIC

  • Strategy: Expand node with min. value of ℎ

19

# $ % & '

1 3 2 5 1 1

ℎ = 6 ℎ = 5

#

ℎ = 6

$

ℎ = 2

&

ℎ = 1

'

ℎ = 2

&

ℎ = 0

1

#1 #2 #3 #4 #5

ℎ = 6 ℎ = 5 ℎ = 2 ℎ = 0 ℎ = 1 ℎ = 6 ℎ = 7

! " ! "

slide-20
SLIDE 20

15780 Spring 2019: Lecture 2

A* TREE SEARCH

  • Strategy: Expand node with min. value of

6 0 = , 0 + ℎ 0

20

# $ % & '

1 3 2 5 1 1 1

ℎ = 6 ℎ = 5 ℎ = 2 ℎ = 0 ℎ = 1 ℎ = 6 ℎ = 7

! "

6 = 6 6 = 6

#

6 = 8

$

6 = 6

&

6 = 7

'

6 = 6

"

#1 #2 #3 #4

!

  • Question: Which node is expanded fourth?
slide-21
SLIDE 21

15780 Spring 2019: Lecture 2

A* TREE SEARCH

  • Should we stop when we discover a goal?

21

# $

2 2

ℎ = 3 ℎ = 2 ℎ = 0 ℎ = 1

2 3

Slide adapted from Dan Klein

! "

  • No: Only stop when we expand a goal

6 = 3 6 = 4

#

6 = 3

$

6 = 5

"

6 = 4

"

#1 #2 #4

!

#3

slide-22
SLIDE 22

15780 Spring 2019: Lecture 2

A* PERFORMANCE

Find minimum-cost path from s to t in a computationally efficient manner

22

today

slide-23
SLIDE 23

15780 Spring 2019: Lecture 2

A* DOESN’T ALWAYS WORK

  • Issue: Good path has pessimistic estimate
  • Circumvent this issue by being optimistic!

23

#

5 1

ℎ = 7 ℎ = 0 ℎ = 6

3

Slide adapted from Dan Klein

! "

6 = 7 6 = 7

#

6 = 5

"

#1 #2

!

slide-24
SLIDE 24

15780 Spring 2019: Lecture 2

ADMISSIBLE HEURISTICS

ℎ is admissible if for all 0, ℎ 0 ≤ ℎ∗ 0 , where ℎ∗ is the cost of the optimal path from 0 to "

24

# $

2 2

ℎ = 3 ℎ = 2 ℎ = 0 ℎ = 1

2 3

! "

§ Aerial distance in pathfinding § ℎ ≡ 0

#

5 1

ℎ = 7 ℎ = 0 ℎ = 6

3

! "

§ §

✅ ❌ ✅ ✅

slide-25
SLIDE 25

15780 Spring 2019: Lecture 2

OPTIMALITY OF A* TREE SEARCH

Theorem: If the heuristic is admissible, then the path returned by A* tree search has minimum cost.

25

slide-26
SLIDE 26

PROOF

  • Recall: A* stops when goal " is expanded
  • For contradiction, assume " with suboptimal path

is expanded before " with optimal path

  • There is a node 0 on the optimal path to " that has

been discovered but not expanded

  • 0 should have been expanded before "! ∎

26

Adapted from Dan Klein

  • 6 0 = , 0 + ℎ 0

≤ , 0 + ℎ∗ 0 = , ">?@ < , "BC?DEFBF = 6("BC?DEFBF)

slide-27
SLIDE 27

15780 Spring 2019: Lecture 2

8-PUZZLE HEURISTICS

  • ℎ1: #tiles in wrong position
  • ℎ2: sum of Manhattan distances of

tiles from goal

  • Question: Which of these is

admissible?

  • Answer: Both
  • Heuristic for designing admissible

heuristics: relax the problem!

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

Example state Goal state

slide-28
SLIDE 28

15780 Spring 2019: Lecture 2

DOMINANCE OF HEURISTICS

  • ℎ dominates ℎ′ iff ∀0, ℎ 0 ≥ ℎ′(0)
  • ℎ1: #tiles in wrong position
  • ℎ2: sum of Manhattan distances of

tiles from goal

  • Question: What is the dominance

relation between ℎL and ℎM?

  • Answer: ℎM dominates ℎL

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

Example state Goal state

slide-29
SLIDE 29

15780 Spring 2019: Lecture 2

8-PUZZLE HEURISTICS

  • The following table gives the number of nodes

expanded by A* with the two heuristics, averaged

  • ver random 8-puzzles, for various solution lengths
  • Moral: Good heuristics are crucial!

29

Length N∗(OP) N∗(OQ) 16 1301 211 18 3056 363 20 7276 676 22 18094 1219 24 39135 1641

slide-30
SLIDE 30

15780 Spring 2019: Lecture 2

TREE SEARCH

  • Tree search can expand many nodes

corresponding to the same state

  • In a rectangular grid:
  • Search tree of depth & has 4R leaves
  • There are only 4& states at Manhattan

distance exactly & from any given state

30

slide-31
SLIDE 31

15780 Spring 2019: Lecture 2

GRAPH SEARCH

function GRAPH-SEARCH(problem, strategy) set of frontier nodes contains the start state of problem loop

  • if there are no unexpanded frontier nodes then return failure
  • choose an unexpanded frontier node for expansion using strategy,

and add it to the expanded set

  • if the node contains a goal then return the corresponding solution
  • else expand the node and add the resulting nodes to the set of

frontier nodes, only if not in the expanded set

31

Graph search is the same as tree search, except that it never expands a node twice

slide-32
SLIDE 32

15780 Spring 2019: Lecture 2

A* GRAPH SEARCH

  • Does A* graph search always find the
  • ptimal path under an admissible heuristic?

32

# $

1 1

ℎ = 2 ℎ = 4 ℎ = 1 ℎ = 1

1 2

%

3

ℎ = 0

Adapted from Dan Klein

! "

6 = 2 6 = 5

#

6 = 2

$

#1 #2

!

6 = 4

%

6 = 6

"

#3 #4

6 = 3

%

#5

  • No!
slide-33
SLIDE 33

15780 Spring 2019: Lecture 2

CONSISTENT HEURISTICS

  • % 0, S = cost of cheapest path from 0 to S
  • ℎ is consistent if for every two nodes 0, S,

ℎ 0 ≤ %(0, S) + ℎ(S)

  • Question: What is the relation between

admissibility and consistency?

1.

Admissible ⇒ consistent

2.

Consistent ⇒ admissible

3.

They are equivalent

4.

They are incomparable

33

S "

  • Set y = " above
  • Graph in previous slide
slide-34
SLIDE 34

15780 Spring 2019: Lecture 2

8-PUZZLE HEURISTICS, CONSISTENT?

  • ℎ1: #tiles in wrong position
  • ℎ2: sum of Manhattan distances of

tiles from goal

  • Poll: Which of these is consistent?
  • Answer: Both
  • Heuristic for designing admissible

heuristics: relax the problem!

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

Example state Goal state

Consistent heuristics yield guarantees for A*graph search (next class)

slide-35
SLIDE 35

15780 Spring 2019: Lecture 2

SUMMARY

  • Terminology and algorithms:
  • Search problems
  • Uninformed vs. informed search
  • Tree search, graph search,

uniform cost search, greedy, A*

  • Admissible and consistent heuristics
  • Theorems:
  • A* tree search is optimal with admissible ℎ
  • A* graph search is optimal with consistent ℎ
  • Big ideas:
  • Don’t be too pessimistic!

35