1 / 60

# Course: Engineering Artificial Intelligence - PowerPoint PPT Presentation

Course: Engineering Artificial Intelligence. Dr. Radu Marinescu. Lecture 2. Fundamental issues for most AI problems. Representation Search Inference Planning Learning. Representation. Facts about the world have to be represented in some way, e.g., mathematical logic Deals with:

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Course: Engineering Artificial Intelligence' - zitkalasa-ramirez

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Course:Engineering Artificial Intelligence

Lecture 2

• Representation

• Search

• Inference

• Planning

• Learning

• Facts about the world have to be represented in some way, e.g., mathematical logic

• Deals with:

• What to represent and how to represent?

• How to structure knowledge?

• What is explicit and what must be inferred?

• How to encode “rules”?

• How to deal with incomplete, inconsistent and probabilistic knowledge?

• What kinds of knowledge are required to solve problems?

• Many tasks can be viewed as searching a very large problem space for a solution

• For example, Tic-Tac-Toe has 765 states, Chess has about 250 states, while Go has about 2100 states

• From some facts others can be inferred (related to search)

• For example, knowing "All elephants have trunks" and "Clyde is an elephant," can we answer the question "Does Clyde have a trunk?"

• What about "Peanuts has a trunk, is it an elephant?" Or "Peanuts lives in a tree and has a trunk, is it an elephant?”

• Learning

• Learn new facts about the world: e.g., machine learning

• Planning

• Starting with general facts about the world, facts about the effects of basic actions, facts about a particular situation, and a statement of a goal generate a strategy for achieving that goal in terms of a sequence of primitive steps or actions

• Representation

• Search

• Inference

• Planning

• Learning

• Main idea: Search allows exploring alternatives

• Background

• State space representation

• Uninformed vs. informed

• Any path vs. optimal path

• Implementation and performance

B is parent of C

C is child of B

A is ancestor of C

C is descendant of A

(edge)

root

Tree

A

Terminal

(leaf)

B

C

B is parent of C

C is child of B

A is ancestor of C

C is descendant of A

(edge)

root

Tree

A

Terminal

(leaf)

B

C

Directed

Graph

(one way streets)

B is parent of C

C is child of B

A is ancestor of C

C is descendant of A

(edge)

root

Tree

A

Terminal

(leaf)

B

C

Directed

Graph

(one way streets)

Undirected

Graph

(two way streets)

Airline routes

Boston

San Fran

Wash DC

Dallas

LA

Airline routes

Boston

San Fran

Wash DC

Planning actions

(graph of possible states

of the world)

B

Put B on C

Dallas

LA

C

C

A

A

B

Put C on A

A

B

C

Put C on A

A

Put A on C

C

C

Put C on B

B

B

A

• What are the states? (All relevant aspects of the problem)

• Arrangement of parts (to plan an assembly)

• Positions of trucks (to plan package distribution)

• Cities (to plan a trip)

• Set of facts (e.g., to prove a mathematical theorem)

• What are the actions(operators)? (deterministic, discrete)

• Assemble two parts

• Move a truck to a new position

• Fly to a new city

• Apply a theorem to derive a new fact

• What is the goaltest? (Condition for success)

• All parts in place

• All packages delivered

• Reached destination city

• Derived goal fact

• On vacation in Romania, currently in Arad

• Flight home leaves tomorrow from Bucharest

• Goal

• Be in Bucharest

• State-space

• States: various cities

• Actions: drive between cities

• Solution

• Sequence of actions to destination

Solution: go(Sibiu), go(Fagaras), go(Bucharest)

Cost: 140 + 99 + 211 = 450

• A problem is defined by 4 items:

• Actions or successorfunction: S(X) = set of action-state pairs

• e.g., S(Arad) = {<go(Sibiu), in(Sibiu)>, <go(Zerind), in(Zerind)>, <go(Timisoara), in(Timisoara)>}

• Goaltest: e.g., in(Bucharest)

• e.g., sum of distances to drive

• A solution is a sequence of actions leading from the initial state to a goal state

• States: location of dirt and robot

• Initialstate: any

• Actions: move robot left, right and suck

• Goalstate: no dirt at all locations

• Pathcost: 1 per action

• States:arrangements of n ≤ 8 queens in the leftmost n columns, 1 per column, such that no queen attacks another

• Initialstate:no queens on the board

• Actions: add queen to the leftmost empty column such that it is not attacked by any other queen

• Goalstate:8 queens on the board, none attacked

• Pathcost: 1 per action

• States

• Initialstate

• Actions

• Goalstate

• Pathcost

Try yourselves

• States: locations of tiles

• Initialstate: given (left)

• Actions: move blank left, right, up, down

• Goalstate: given (right)

• Pathcost: 1 per action

• Basic idea

• Exploration of state space graph by generating successors of already-explored states (a.k.a. expanding states)

• Every states is evaluated: is it a goal state?

• State – Used to refer to the vertices in the underlying graph that is being searched, that is states in the problem domain, for example, a city, an arrangement of blocks or the arrangement of parts in a puzzle

• Search node – Refers to the vertices in the searchtree that is being generated by the search algorithm. Each node refers to a state of the world; many nodes may refer to the same state.

• Importantly, a node implicitly represents a path (from the start state of the search tree to the state associated with the node). Because search nodes are part of the search tree, they have a unique ancestor node (except for the root node)

• A state is a (representation of) a physical configuration

• A node is a data structure constituting part of a search tree contains info such as: state, parent node, action, path costg(x), depth

• A search strategy is defined by picking the order of node expansion

• Search strategies are evaluated along the following dimensions:

• completeness: does it always find a solution if one exists?

• timecomplexity: number of nodes generated

• spacecomplexity: maximum number of nodes in memory

• optimality: does it always find a least-cost solution?

• Time and space complexity are measured in terms of

• b: maximum branching factor of the search tree

• d: depth of the search tree

• Any path search

• Uninformed search

• Informed search

• Optimal path search

• Uninformed search

• Informed search

• A search node is a path from some state X to the start state, e.g., (X B A S)

• The state of a search node is the most recent state of the path, e.g., X

• Let Q be a list of search nodes, e.g., ((X B A S) (C B A S) …)

• Let S be the start state

• Initialize Q with search node (S) as only entry, set Visited = (S)

• If Q is empty, fail. Else, pick some node N from Q

• If state(N) is goal, return N (we’ve reached the goal)

• (Otherwise) Remove N from Q

• Find all descendants of state(N) not in Visited and create all the one-step extensions of N to each descendant

• Add the extended paths to Q; add children of state(N) to Visited

• Go to step 2.

• A search node is a path from some state X to the start state, e.g., (X B A S)

• The state of a search node is the most recent state of the path, e.g., X

• Let Q be a list of search nodes, e.g., ((X B A S) (C B A S) …)

• Let S be the start state

• Initialize Q with search node (S) as only entry, set Visited = (S)

• If Q is empty, fail. Else, pick some node N from Q

• If state(N) is goal, return N (we’ve reached the goal)

• (Otherwise) Remove N from Q

• Find all descendants of state(N) not in Visited and create all the one-step extensions of N to each descendant

• Add the extended paths to Q; add children of state(N) to Visited

• Go to step 2.

Critical decisions:

Step 2: picking N from Q

Step 6: adding extensions of N to Q

• Depth-first

• Pick first element of Q

• Add path extensions to front of Q

• Pick first element of Q

• Add path extensions to end of Q

• Visited – a state M is first visited when a path to M first gets added to Q. In general, a state is said to have been visited if it has ever shown up in a search node in Q. The intuition is that we have briefly “visited” them to place them in Q, but we have not yet examined them carefully.

• Expanded – a state M is expanded when it is the state of a search node that is pulled off of Q. At that point, the descendants of M are visited and the path that led to M is extended to the eligible descendants. We sometimes refer to the search node that led to M (instead of M itself) as being expanded. However, once a node is expanded we are done with it; we will not need to expand it again. In fact, we discard it from Q

Pick first element of Q; Add path extensions to front of Q

C

G

A

D

S

B

We show the paths in reversedorder; the node’s state is the first entry

Pick first element of Q; Add path extensions to front of Q

1

C

G

A

D

S

B

We show the paths in reversed order; the node’s state is the first entry

Pick first element of Q; Add path extensions to front of Q

2

1

C

G

A

D

S

B

We show the paths in reversed order; the node’s state is the first entry

Pick first element of Q; Add path extensions to front of Q

3

2

1

C

G

A

D

S

B

We show the paths in reversed order; the node’s state is the first entry

Pick first element of Q; Add path extensions to front of Q

3

2

4

1

C

G

A

D

S

B

We show the paths in reversed order; the node’s state is the first entry

Pick first element of Q; Add path extensions to front of Q

3

5

2

4

1

C

G

A

D

S

B

We show the paths in reversed order; the node’s state is the first entry

Pick first element of Q; Add path extensions to front of Q

3

5

2

4

1

C

G

A

D

S

B

We show the paths in reversed order; the node’s state is the first entry

1

S

B

A

1

C

G

A

D

S

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & Expanded

Gray fill = Visited

B

1

S

2

B

A

2

C

D

1

C

G

A

D

S

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & Expanded

Gray fill = Visited

B

1

S

3

2

B

A

2

3

C

D

1

C

G

A

D

S

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & Expanded

Gray fill = Visited

B

1

S

3

2

B

A

2

3

4

C

D

4

NB: C is not

visited again

1

C

G

C

G

A

D

S

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & Expanded

Gray fill = Visited

B

1

S

3

2

5

B

A

2

3

4

C

D

4

5

1

C

G

C

G

A

D

S

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & Expanded

Gray fill = Visited

B

• Depth-first

• Pick first element of Q

• Add path extensions to front of Q

• Pick first element of Q

• Add path extensions to end of Q

Pick first element of Q; Add path extensions to end of Q

C

G

A

D

S

B

We show the paths in reversedorder; the node’s state is the first entry

Pick first element of Q; Add path extensions to end of Q

1

C

G

A

D

S

B

We show the paths in reversedorder; the node’s state is the first entry

Pick first element of Q; Add path extensions to end of Q

2

1

C

G

A

D

S

B

We show the paths in reversedorder; the node’s state is the first entry

Pick first element of Q; Add path extensions to end of Q

2

1

C

G

3

A

D

S

B

We show the paths in reversedorder; the node’s state is the first entry

* We could have stopped here, when the first path to the goal was generated

Pick first element of Q; Add path extensions to end of Q

4

2

1

C

G

3

A

D

S

B

We show the paths in reversedorder; the node’s state is the first entry

* We could have stopped here, when the first path to the goal was generated

Pick first element of Q; Add path extensions to end of Q

4

2

5

1

C

G

3

A

D

S

B

We show the paths in reversedorder; the node’s state is the first entry

* We could have stopped here, when the first path to the goal was generated

Pick first element of Q; Add path extensions to end of Q

4

6

2

5

1

C

G

3

A

D

S

B

We show the paths in reversedorder; the node’s state is the first entry

* We could have stopped here, when the first path to the goal was generated

Pick first element of Q; Add path extensions to end of Q

4

6

2

5

1

C

G

3

A

D

S

B

We show the paths in reversedorder; the node’s state is the first entry

* We could have stopped here, when the first path to the goal was generated

1

S

4

2

3

6

B

A

2

4

6

5

D

G

C

D

NB: D is not

visited again

5

1

C

G

3

A

D

S

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & Expanded

Gray fill = Visited

B

• The number of states in the search space may be exponential in the some “depth” parameter, e.g. number of actions in a plan, number of moves in a game

• All searches may have to visit each state at least one, in the worst case

• So, all searches will have worst case running times that are at least proportional to the total number of states and therefore exponential in the “depth” parameter

Max Time α Max # Visited

d=0

b=2

d=1

d=2

d is depth

b is branching factor

bd < (bd+1 – 1) / (b - 1) < bd+1

states in tree

Max Q size = Max(#Visited - #Expanded)

visited

expanded

bd

Depth-first max Q size

(b – 1)d ≈ bd

Searching a tree with branching factor b and depth d

(without a Visited list)

* If there are no infinitely long paths in the search space

Worst case time is proportional to the number of nodes added to Q

Worst case space is proportional to the maximal length of Q

• In large search problems, memory is often the limiting factor

• Imagine searching a tree with branching factor 8 and depth 10. Assume a node requires just 8 bytes of storage. The, breadth-first search might require up to

(23)10 x 23 = 233 bytes = 8,000 Mbytes = 8 Gbytes

• One strategy is to trade time for memory. For example, we can emulate breadth-first search by repeated application of depth-first search, each up to a preset depth limit. This is called iterative deepening search (IDS)

• C = 1

• Do DFS to max depth C. If path found, return it

• Otherwise, increment C and go to 2.

• State-space formulation

• Abstract representation of the problem

• Search for a solution

• Depth-first search: exponential time, linear space

• Breadth-first search: exponential time, exponential space, but finds the “shallowest” goal

• Iterative deepening search: trades off time for space (simulates breadth-first search)