cs b551: elements of artificial intelligence

52
CS B551: ELEMENTS OF ARTIFICIAL INTELLIGENCE Instructor: Kris Hauser http://cs.indiana.edu/~hauserk 1

Upload: breanna-leach

Post on 31-Dec-2015

31 views

Category:

Documents


0 download

DESCRIPTION

CS B551: Elements of Artificial Intelligence. Instructor: Kris Hauser http://cs.indiana.edu/~hauserk. Recap. http://www.cs.indiana.edu/classes/b551 Brief history and philosophy of AI What is intelligence? Can a machine act/think intelligently? Turing machine, Chinese room. Agenda. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CS B551: Elements of Artificial Intelligence

CS B551: ELEMENTS OF ARTIFICIAL INTELLIGENCEInstructor: Kris Hauser

http://cs.indiana.edu/~hauserk

1

Page 2: CS B551: Elements of Artificial Intelligence

RECAP

http://www.cs.indiana.edu/classes/b551 Brief history and philosophy of AI What is intelligence? Can a machine

act/think intelligently? Turing machine, Chinese room

2

Page 3: CS B551: Elements of Artificial Intelligence

AGENDA

Problem Solving using Search Search Algorithms

3

Page 4: CS B551: Elements of Artificial Intelligence

EXAMPLE: 8-PUZZLE

4

1

2

3 4

5 6

7

8 1 2 3

4 5 6

7 8

Initial state Goal state

State: Any arrangement of 8 numbered tiles and an empty tile on a 3x3 board

Page 5: CS B551: Elements of Artificial Intelligence

SUCCESSOR FUNCTION: 8-PUZZLE

5

1

2

3 4

5 6

7

8

1

2

3 4

5

6

78

1

2

3 4

5 6

78

1

2

3 4

5 6

78

SUCC(state) subset of states

The successor function is knowledgeabout the 8-puzzle game, but it does not tell us which outcome to use, nor towhich state of the board to apply it.

Page 6: CS B551: Elements of Artificial Intelligence

6

Across history, puzzles and games requiring the exploration of alternatives have been considered a challenge for human intelligence:

Chess originated in Persia and India about 4000 years ago

Checkers appear in 3600-year-old Egyptian paintings

Go originated in China over 3000 years ago

So, it’s not surprising that AI uses games to design and test algorithms

Page 7: CS B551: Elements of Artificial Intelligence

EXPLORING ALTERNATIVES

Problems that seem to require intelligence usually require exploring multiple alternatives

Search: a systematic way of exploring alternatives

7

Page 8: CS B551: Elements of Artificial Intelligence

WHAT IS A STATE?

A state does: Represent all information meaningful to the

problem at a given “instant in time” – usually in the future

Exist in an abstract, mathematical sense A state DOES NOT:

Necessarily exist in the computer’s memory Tell the computer how it arrived at the state Tell the computer how to choose the next action Need to be a unique representation

8

Page 9: CS B551: Elements of Artificial Intelligence

8-QUEENS PROBLEM

State repr. 1 Any non-conflicting

placement of 0-8 queens

State repr. 2 Any placement of 8

queens

9

Page 10: CS B551: Elements of Artificial Intelligence

DEFINING A SEARCH PROBLEM

10

State space S Successor function: x S SUCC(x) 2S

Initial state s0

Goal test: xS GOAL?(x) =T or F Arc cost

S

Page 11: CS B551: Elements of Artificial Intelligence

STATE GRAPH

11

Each state is represented by a distinct node

An arc (or edge) connects a node s to a node s’ if s’ SUCC(s)

The state graph may contain more than one connected component

Page 12: CS B551: Elements of Artificial Intelligence

SOLUTION TO THE SEARCH PROBLEM A solution is a path

connecting the initial node to a goal node (any one)

The cost of a path is the sum of the arc costs along this path

An optimal solution is a solution path of minimum cost

There might be no solution !

12

I

G

Page 13: CS B551: Elements of Artificial Intelligence

PATHLESS PROBLEMS Sometimes the path

doesn’t matter A solution is any

goal node Arcs represent

potential state transformations

E.g. 8-queens, Simplex for LPs, Map coloring

13

I

G

Page 14: CS B551: Elements of Artificial Intelligence

REPRESENTATION 1 State: any placement of

0-8 queens Initial state: 0 queens Successor function:

Place queen in empty square

Goal test: Non-conflicting placement

of 8 queens # of states ~ 64x63x…

x57 ~ 3x1014

14

Page 15: CS B551: Elements of Artificial Intelligence

15

REPRESENTATION 2

State: any placement of non-conflicting 0-8 queens in columns starting from left

Initial state: 0 queens Successor function:

A queen placed in leftmost empty column such that it causes no conflicts

Goal test: Any state with 8 queens

# of states = 2057

Page 16: CS B551: Elements of Artificial Intelligence

PATH PLANNING

16What is the state space?

Page 17: CS B551: Elements of Artificial Intelligence

FORMULATION #1

17Cost of one horizontal/vertical step = 1Cost of one diagonal step = 2

Page 18: CS B551: Elements of Artificial Intelligence

OPTIMAL SOLUTION

18This path is the shortest in the discretized state space, but not in the original continuous space

Page 19: CS B551: Elements of Artificial Intelligence

FORMULATION #2

19Cost of one step: length of segment

Page 20: CS B551: Elements of Artificial Intelligence

FORMULATION #2

20Cost of one step: length of segment

Visibility graph

Page 21: CS B551: Elements of Artificial Intelligence

SOLUTION PATH

21The shortest path in this state space is also the shortest in the original continuous space

Page 22: CS B551: Elements of Artificial Intelligence

5-MINUTE QUIZ

Formulate 2x2 Tic-Tac-Toe as a search problem. Assume you choose both X and O’s actions, and O goes first. Draw entire state graph. For compactness’s

sake, eliminate symmetrical states Indicate initial and goal states on this graph

Suppose one side is allowed to pass. How does the state graph change? Do you need to change anything to the problem definition?

22

Page 23: CS B551: Elements of Artificial Intelligence

EXAMPLE: 8-PUZZLE

23

1

2

3 4

5 6

7

8 1 2 3

4 5 6

7 8

Initial state Goal state

State: Any arrangement of 8 numbered tiles and an empty tile on a 3x3 board

Page 24: CS B551: Elements of Artificial Intelligence

15-PUZZLE Introduced (?) in 1878 by Sam Loyd,

who dubbed himself “America’s greatest puzzle-expert”

24

Page 25: CS B551: Elements of Artificial Intelligence

15-PUZZLE

Sam Loyd offered $1,000 of his own money to the first person who would solve the following problem:

25

12

14

11

15

10

13

9

5 6 7 8

4321

12

15

11

14

10

13

9

5 6 7 8

4321

?

Page 26: CS B551: Elements of Artificial Intelligence

But no one ever won the prize !!26

Page 27: CS B551: Elements of Artificial Intelligence

HOW BIG IS THE STATE SPACE OF THE (N2-1)-PUZZLE?

8-puzzle ?? states

27

Page 28: CS B551: Elements of Artificial Intelligence

HOW BIG IS THE STATE SPACE OF THE (N2-1)-PUZZLE?

8-puzzle 9! = 362,880 states 15-puzzle 16! ~ 2.09 x 1013 states 24-puzzle 25! ~ 1025 states

But only half of these states are reachable from any given state(but you may not know that in advance)

28

Page 29: CS B551: Elements of Artificial Intelligence

PERMUTATION INVERSIONS Wlg, let the goal be:

A tile j appears after a tile i if either j appears on the same row as i to the right of i, or on another row below the row of i.

For every i = 1, 2, ..., 15, let ni be the number of tiles j < i that appear after tile i (permutation inversions)

N = n2 + n3 + + n15 + row number of empty tile

29

12

15

11

14

10

13

9

5 6 7 8

4321

12

15

11

14

6

13

9

5 10 7 8

4321 n2 = 0 n3 = 0 n4 = 0n5 = 0 n6 = 0 n7 = 1n8 = 1 n9 = 1 n10 = 4n11 = 0n12 = 0n13 = 0n14 = 0n15 = 0

N = 7 + 4

Page 30: CS B551: Elements of Artificial Intelligence

Proposition: (N mod 2) is invariant under any legal move of the empty tile

Proof: Any horizontal move of the empty tile leaves N

unchanged A vertical move of the empty tile changes N by

an even increment ( 1 1 1 1)

301215

11

14

10

13

9

5 6 7

8

4321

s =

1215

11

14

10

13

9

5 6 7

8

4321

s’ = N(s’) = N(s) + 3 + 1

Page 31: CS B551: Elements of Artificial Intelligence

Proposition: (N mod 2) is invariant under any legal move of the empty tile

For a goal state g to be reachable from a state s, a necessary condition is that N(g) and N(s) have the same parity

It can be shown that this is also a sufficient condition

The state graph consists of two connected components of equal size

31

Page 32: CS B551: Elements of Artificial Intelligence

SEARCHING THE STATE SPACE

It is often not feasible (or too expensive) to build a complete representation of the state graph

32

Page 33: CS B551: Elements of Artificial Intelligence

8-, 15-, 24-PUZZLES

33

8-puzzle 362,880 states

15-puzzle 2.09 x 1013 states

24-puzzle 1025 states

100 millions states/sec

0.036 sec

~ 55 hours

> 109 years

Page 34: CS B551: Elements of Artificial Intelligence

INTRACTABILITY

Constructing the full state graph is intractable for most interesting problems

n-puzzle: (n+1)! states k-queens:

kk states

34

Tractability of search hinges on the ability to explore only a tiny portion

of the state graph!

Page 35: CS B551: Elements of Artificial Intelligence

SEARCHING35

Page 36: CS B551: Elements of Artificial Intelligence

36

SEARCHING THE STATE SPACE

Search tree

Page 37: CS B551: Elements of Artificial Intelligence

37

SEARCHING THE STATE SPACE

Search tree

Page 38: CS B551: Elements of Artificial Intelligence

38

SEARCHING THE STATE SPACE

Search tree

Page 39: CS B551: Elements of Artificial Intelligence

39

SEARCHING THE STATE SPACE

Search tree

Page 40: CS B551: Elements of Artificial Intelligence

40

SEARCHING THE STATE SPACE

Search tree

Page 41: CS B551: Elements of Artificial Intelligence

41

SEARCHING THE STATE SPACE

Search tree

Page 42: CS B551: Elements of Artificial Intelligence

42

SEARCH NODES AND STATES

8

3

5

2

4 7

1 6

8

3

5

2

4 7

1 6

8

3

5

2

4

7

1 6

8

3

5

2

4 7

1 6

8

3

5

24

7

1 6

8

3

5

2

4 7

1 6

If states are allowed to be revisited,the search tree may be infinite even

when the state space is finite

If states are allowed to be revisited,the search tree may be infinite even

when the state space is finite

Page 43: CS B551: Elements of Artificial Intelligence

43

DATA STRUCTURE OF A NODE

PARENT-NODE

8

3

5

2

4 7

1 6

STATE

Depth of a node N = length of path from root to N

(depth of the root = 0)

BOOKKEEPING

5Path-Cost

5Depth

RightAction

Expanded yes...

CHILDREN

Page 44: CS B551: Elements of Artificial Intelligence

44

NODE EXPANSION

The expansion of a node N of the search tree consists of: Evaluating the successor

function on STATE(N) Generating a child of N for

each state returned by the function

node generation node expansion

1

2

3 4

5 6

7

8

N

1

3

5 6

8

1

3

4

5 6

7

82

4 7

2

1

2

3 4

5 6

7

8

Page 45: CS B551: Elements of Artificial Intelligence

FRINGE OF SEARCH TREE

The fringe is the set of all search nodes that haven’t been expanded yet

835

24 71 6

835

24 71 6

835

24

7

1 6

835

24 71 6

835

724

1 6

835

24 71 6

Page 46: CS B551: Elements of Artificial Intelligence

46

Is it identical to the set of leaves?

Page 47: CS B551: Elements of Artificial Intelligence

47

SEARCH STRATEGY

The fringe is the set of all search nodes that haven’t been expanded yet

The fringe is implemented as a priority queue FRINGE INSERT(node,FRINGE) REMOVE(FRINGE)

The ordering of the nodes in FRINGE defines the search strategy

Page 48: CS B551: Elements of Artificial Intelligence

48

SEARCH ALGORITHM #1

SEARCH#11. If GOAL?(initial-state) then return initial-

state2. INSERT(initial-node,FRINGE)3. Repeat:4. If empty(FRINGE) then return failure5. N REMOVE(FRINGE)6. s STATE(N)7. For every state s’ in

SUCCESSORS(s)8. Create a new node N’ as a child

of N9. If GOAL?(s’) then return path or

goal state10. INSERT(N’,FRINGE)

Expansion of N

Page 49: CS B551: Elements of Artificial Intelligence

49

PERFORMANCE MEASURES

CompletenessA search algorithm is complete if it finds a solution whenever one exists[What about the case when no solution exists?]

OptimalityA search algorithm is optimal if it returns a minimum-cost path whenever a solution exists

ComplexityIt measures the time and amount of memory required by the algorithm

Page 50: CS B551: Elements of Artificial Intelligence

TOPICS OF NEXT 3-4 CLASSES

Blind (uninformed) Search Little or no knowledge about how to search

Heuristic (informed) Search How to use extra knowledge about the problem

Local Search With knowledge about goal distribution

50

Page 51: CS B551: Elements of Artificial Intelligence

RECAP

General problem solving framework State space Successor function Goal test => State graph

Search is a methodical way of exploring alternatives

51

Page 52: CS B551: Elements of Artificial Intelligence

HOMEWORK

Register! Readings: R&N Ch. 3.4-3.5 HW1

Class website Writing and programming Due date: 9/15

52