introduction to artificial intelligence problem solving and...

112
Introduction to Artificial Intelligence Problem Solving and Search Bernhard Beckert U NIVERSITÄT KOBLENZ -L ANDAU Wintersemester 2003/2004 B. Beckert: Einführung in die KI / KI für IM – p.1

Upload: others

Post on 24-Sep-2019

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Introduction to Artificial Intelligence

Problem Solving and Search

Bernhard Beckert

UNIVERSITÄT KOBLENZ-LANDAU

Wintersemester 2003/2004

B. Beckert: Einführung in die KI / KI für IM – p.1

Page 2: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Outline

Problem solving

Problem types

Problem formulation

Example problems

Basic search algorithms

B. Beckert: Einführung in die KI / KI für IM – p.2

Page 3: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Problem solving

Offline problem solving

Acting only with complete knowledge of problem and solution

Online problem solving

Acting without complete knowledge

Here

Here we are concerned with offline problem solving only

B. Beckert: Einführung in die KI / KI für IM – p.3

Page 4: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Travelling in Romania

Scenario

On holiday in Romania; currently in AradFlight leaves tomorrow from Bucharest

Goal

Be in Bucharest

Formulate problem

States: various citiesActions: drive between cities

Solution

Appropriate sequence of citiese.g.: Arad, Sibiu, Fagaras, Bucharest

B. Beckert: Einführung in die KI / KI für IM – p.4

Page 5: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Travelling in Romania

Scenario

On holiday in Romania; currently in AradFlight leaves tomorrow from Bucharest

Goal

Be in Bucharest

Formulate problem

States: various citiesActions: drive between cities

Solution

Appropriate sequence of citiese.g.: Arad, Sibiu, Fagaras, Bucharest

B. Beckert: Einführung in die KI / KI für IM – p.4

Page 6: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Travelling in Romania

Scenario

On holiday in Romania; currently in AradFlight leaves tomorrow from Bucharest

Goal

Be in Bucharest

Formulate problem

States: various citiesActions: drive between cities

Solution

Appropriate sequence of citiese.g.: Arad, Sibiu, Fagaras, Bucharest

B. Beckert: Einführung in die KI / KI für IM – p.4

Page 7: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Travelling in Romania

Scenario

On holiday in Romania; currently in AradFlight leaves tomorrow from Bucharest

Goal

Be in Bucharest

Formulate problem

States: various citiesActions: drive between cities

Solution

Appropriate sequence of citiese.g.: Arad, Sibiu, Fagaras, Bucharest

B. Beckert: Einführung in die KI / KI für IM – p.4

Page 8: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Travelling in Romania

Giurgiu

UrziceniHirsova

Eforie

Neamt

Oradea

Zerind

Arad

Timisoara

Lugoj

Mehadia

Dobreta

Craiova

Sibiu Fagaras

Pitesti

Vaslui

Iasi

Rimnicu Vilcea

Bucharest

B. Beckert: Einführung in die KI / KI für IM – p.5

Page 9: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Problem types

Single-state problem

– observable (at least the initial state)– deterministic– static– discrete

Multiple-state problem

– partially observable (initial state not observable)– deterministic– static– discrete

Contingency problem

– partially observable (initial state not observable)– non-deterministic

B. Beckert: Einführung in die KI / KI für IM – p.6

Page 10: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: vacuum-cleaner world

Single-state

Start in: 5

Solution:

[right, suck ]

Multiple-state

Start in: {1,2,3,4,5,6,7,8}

Solution: [right, suck, left, suck ]

right → {2,4,6,8}

suck → {4,8}

left → {3,7}

suck → {7}

1 2

3 4

5 6

7 8

B. Beckert: Einführung in die KI / KI für IM – p.7

Page 11: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: vacuum-cleaner world

Single-state

Start in: 5

Solution: [right, suck ]

Multiple-state

Start in: {1,2,3,4,5,6,7,8}

Solution: [right, suck, left, suck ]

right → {2,4,6,8}

suck → {4,8}

left → {3,7}

suck → {7}

1 2

3 4

5 6

7 8

B. Beckert: Einführung in die KI / KI für IM – p.7

Page 12: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: vacuum-cleaner world

Single-state

Start in: 5

Solution: [right, suck ]

Multiple-state

Start in: {1,2,3,4,5,6,7,8}

Solution:

[right, suck, left, suck ]

right → {2,4,6,8}

suck → {4,8}

left → {3,7}

suck → {7}

1 2

3 4

5 6

7 8

B. Beckert: Einführung in die KI / KI für IM – p.7

Page 13: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: vacuum-cleaner world

Single-state

Start in: 5

Solution: [right, suck ]

Multiple-state

Start in: {1,2,3,4,5,6,7,8}

Solution: [right, suck, left, suck ]

right → {2,4,6,8}

suck → {4,8}

left → {3,7}

suck → {7}

1 2

3 4

5 6

7 8

B. Beckert: Einführung in die KI / KI für IM – p.7

Page 14: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: vacuum-cleaner world

Contingency

Murphy’s Law:suck can dirty a clean carpet

Local sensing:dirty /not dirty at location only

Start in: {1,3}

Solution:

[suck, right, suck ]

suck → {5,7}

right → {6,8}

suck → {6,8}

Improvement: [suck, right, if dirt then suck ](decide whether in 6 or 8 using local sensing)

1 2

3 4

5 6

7 8

B. Beckert: Einführung in die KI / KI für IM – p.8

Page 15: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: vacuum-cleaner world

Contingency

Murphy’s Law:suck can dirty a clean carpet

Local sensing:dirty /not dirty at location only

Start in: {1,3}

Solution: [suck, right, suck ]

suck → {5,7}

right → {6,8}

suck → {6,8}

Improvement: [suck, right, if dirt then suck ](decide whether in 6 or 8 using local sensing)

1 2

3 4

5 6

7 8

B. Beckert: Einführung in die KI / KI für IM – p.8

Page 16: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Single-state problem formulation

Defined by the following four items

1. Initial state

Example: Arad

2. Successor function S

Example: S(Arad) = { 〈goZerind,Zerind〉, 〈goSibiu,Sibiu〉, . . . }

3. Goal test

Example: x = Bucharest (explicit test)

noDirt(x) (implicit test)

4. Path cost (optional)

Example: sum of distances, number of operators executed, etc.

B. Beckert: Einführung in die KI / KI für IM – p.9

Page 17: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Single-state problem formulation

Solution

A sequence of operatorsleading from the initial state to a goal state

B. Beckert: Einführung in die KI / KI für IM – p.10

Page 18: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Selecting a state space

Abstraction

Real world is absurdly complexState space must be abstracted for problem solving

(Abstract) state

Set of real states

(Abstract) operator

Complex combination of real actionsExample: Arad→ Zerind represents complex set of possible routes

(Abstract) solution

Set of real paths that are solutions in the real world

B. Beckert: Einführung in die KI / KI für IM – p.11

Page 19: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: The 8-puzzle

2

Start State Goal State

51 3

4 6

7 8

5

1

2

3

4

6

7

8

5

States

integer locations of tiles

Actions

left, right, up, down

Goal test

= goal state?

Path cost

1 per move

B. Beckert: Einführung in die KI / KI für IM – p.12

Page 20: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: The 8-puzzle

2

Start State Goal State

51 3

4 6

7 8

5

1

2

3

4

6

7

8

5

States integer locations of tiles

Actions

left, right, up, down

Goal test

= goal state?

Path cost

1 per move

B. Beckert: Einführung in die KI / KI für IM – p.12

Page 21: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: The 8-puzzle

2

Start State Goal State

51 3

4 6

7 8

5

1

2

3

4

6

7

8

5

States integer locations of tiles

Actions left, right, up, down

Goal test

= goal state?

Path cost

1 per move

B. Beckert: Einführung in die KI / KI für IM – p.12

Page 22: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: The 8-puzzle

2

Start State Goal State

51 3

4 6

7 8

5

1

2

3

4

6

7

8

5

States integer locations of tiles

Actions left, right, up, down

Goal test = goal state?

Path cost

1 per move

B. Beckert: Einführung in die KI / KI für IM – p.12

Page 23: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: The 8-puzzle

2

Start State Goal State

51 3

4 6

7 8

5

1

2

3

4

6

7

8

5

States integer locations of tiles

Actions left, right, up, down

Goal test = goal state?

Path cost 1 per move

B. Beckert: Einführung in die KI / KI für IM – p.12

Page 24: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Vacuum-cleaner

R

L

S S

S S

R

L

R

L

R

L

S

SS

S

L

L

LL R

R

R

R

States

integer dirt and robot locations

Actions

left, right, suck, noOp

Goal test

not dirty?

Path cost

1 per operation (0 for noOp)

B. Beckert: Einführung in die KI / KI für IM – p.13

Page 25: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Vacuum-cleaner

R

L

S S

S S

R

L

R

L

R

L

S

SS

S

L

L

LL R

R

R

R

States integer dirt and robot locations

Actions

left, right, suck, noOp

Goal test

not dirty?

Path cost

1 per operation (0 for noOp)

B. Beckert: Einführung in die KI / KI für IM – p.13

Page 26: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Vacuum-cleaner

R

L

S S

S S

R

L

R

L

R

L

S

SS

S

L

L

LL R

R

R

R

States integer dirt and robot locations

Actions left, right, suck, noOp

Goal test

not dirty?

Path cost

1 per operation (0 for noOp)

B. Beckert: Einführung in die KI / KI für IM – p.13

Page 27: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Vacuum-cleaner

R

L

S S

S S

R

L

R

L

R

L

S

SS

S

L

L

LL R

R

R

R

States integer dirt and robot locations

Actions left, right, suck, noOp

Goal test not dirty?

Path cost

1 per operation (0 for noOp)

B. Beckert: Einführung in die KI / KI für IM – p.13

Page 28: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Vacuum-cleaner

R

L

S S

S S

R

L

R

L

R

L

S

SS

S

L

L

LL R

R

R

R

States integer dirt and robot locations

Actions left, right, suck, noOp

Goal test not dirty?

Path cost 1 per operation (0 for noOp)

B. Beckert: Einführung in die KI / KI für IM – p.13

Page 29: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Robotic assembly

R

RRP

R R

States

real-valued coordinates of

robot joint angles and parts of the object to be assembled

Actions

continuous motions of robot joints

Goal test

assembly complete?

Path cost

time to execute

B. Beckert: Einführung in die KI / KI für IM – p.14

Page 30: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Robotic assembly

R

RRP

R R

States real-valued coordinates of

robot joint angles and parts of the object to be assembled

Actions

continuous motions of robot joints

Goal test

assembly complete?

Path cost

time to execute

B. Beckert: Einführung in die KI / KI für IM – p.14

Page 31: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Robotic assembly

R

RRP

R R

States real-valued coordinates of

robot joint angles and parts of the object to be assembled

Actions continuous motions of robot joints

Goal test

assembly complete?

Path cost

time to execute

B. Beckert: Einführung in die KI / KI für IM – p.14

Page 32: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Robotic assembly

R

RRP

R R

States real-valued coordinates of

robot joint angles and parts of the object to be assembled

Actions continuous motions of robot joints

Goal test assembly complete?

Path cost

time to execute

B. Beckert: Einführung in die KI / KI für IM – p.14

Page 33: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Example: Robotic assembly

R

RRP

R R

States real-valued coordinates of

robot joint angles and parts of the object to be assembled

Actions continuous motions of robot joints

Goal test assembly complete?

Path cost time to executeB. Beckert: Einführung in die KI / KI für IM – p.14

Page 34: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Tree search algorithms

Offline

Simulated exploration of state space in a search treeby generating successors of already-explored states

function TREE-SEARCH( problem, strategy) returns a solution or failure

initialize the search tree using the initial state of problem

loop do

if there are no candidates for expansion then return failure

choose a leaf node for expansion according to strategy

if the node contains a goal state then

return the corresponding solution

else

expand the node and add the resulting nodes to the search tree

end

B. Beckert: Einführung in die KI / KI für IM – p.15

Page 35: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Tree search: Example

Rimnicu Vilcea Lugoj

ZerindSibiu

Arad Fagaras Oradea

Timisoara

AradArad Oradea

Arad

B. Beckert: Einführung in die KI / KI für IM – p.16

Page 36: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Tree search: Example

Rimnicu Vilcea LugojArad Fagaras Oradea AradArad Oradea

Zerind

Arad

Sibiu Timisoara

B. Beckert: Einführung in die KI / KI für IM – p.16

Page 37: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Tree search: Example

Lugoj AradArad OradeaRimnicu Vilcea

Zerind

Arad

Sibiu

Arad Fagaras Oradea

Timisoara

B. Beckert: Einführung in die KI / KI für IM – p.16

Page 38: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Implementation: States vs. nodes

State

A (representation of) a physical configuration

Node

A data structure constituting part of a search tree(includes parent, children, depth, path cost, etc.)

1

23

45

6

7

81

23

45

6

7

8

State Node

parent

depth = 6g = 6

childrenstate

B. Beckert: Einführung in die KI / KI für IM – p.17

Page 39: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Implementation of search algorithms

function TREE-SEARCH( problem, fringe) returns a solution or failure

fringe← INSERT(MAKE-NODE(INITIAL-STATE[problem]),fringe)

loop do

if fringe is empty then return failure

node← REMOVE-FIRST(fringe)

if GOAL-TEST[problem] applied to STATE(node) succeeds then

return node

else

fringe← INSERT-ALL(EXPAND(node, problem), fringe)

end

fringe queue of nodes not yet consideredState gives the state that is represented by nodeExpand creates new nodes by applying possible actions to node

B. Beckert: Einführung in die KI / KI für IM – p.18

Page 40: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Search strategies

Strategy

Defines the order of node expansion

Important properties of strategies

completeness does it always find a solution if one exists?

time complexity number of nodes generated/expanded

space complexity maximum number of nodes in memory

optimality does it always find a least-cost solution?

Time and space complexity measured in terms of

b maximum branching factor of the search tree

d depth of a solution with minimal distance to root

m maximum depth of the state space (may be ∞)

B. Beckert: Einführung in die KI / KI für IM – p.19

Page 41: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Uninformed search strategies

Uninformed search

Use only the information available in the problem definition

Frequently used strategies

Breadth-first search

Uniform-cost search

Depth-first search

Depth-limited search

Iterative deepening search

B. Beckert: Einführung in die KI / KI für IM – p.20

Page 42: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search

Idea

Expand shallowest unexpanded node

Implementation

fringe is a FIFO queue, i.e. successors go in at the end of the queue

A

B C

D E F GB. Beckert: Einführung in die KI / KI für IM – p.21

Page 43: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search

Idea

Expand shallowest unexpanded node

Implementation

fringe is a FIFO queue, i.e. successors go in at the end of the queue

A

B C

D E F GB. Beckert: Einführung in die KI / KI für IM – p.21

Page 44: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search

Idea

Expand shallowest unexpanded node

Implementation

fringe is a FIFO queue, i.e. successors go in at the end of the queue

A

B C

D E F GB. Beckert: Einführung in die KI / KI für IM – p.21

Page 45: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search

Idea

Expand shallowest unexpanded node

Implementation

fringe is a FIFO queue, i.e. successors go in at the end of the queue

A

B C

D E F GB. Beckert: Einführung in die KI / KI für IM – p.21

Page 46: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search: Example Romania

Arad

B. Beckert: Einführung in die KI / KI für IM – p.22

Page 47: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search: Example Romania

Zerind Sibiu Timisoara

Arad

B. Beckert: Einführung in die KI / KI für IM – p.22

Page 48: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search: Example Romania

Arad Oradea

Zerind Sibiu Timisoara

Arad

B. Beckert: Einführung in die KI / KI für IM – p.22

Page 49: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search: Example Romania

Arad Oradea Rimnicu VilceaFagaras Arad LugojArad Oradea

Zerind Sibiu Timisoara

Arad

B. Beckert: Einführung in die KI / KI für IM – p.22

Page 50: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search: Properties

Complete

Yes (if b is finite)

Time

1+b+b2 +b3 + . . .+bd +b(bd−1) ∈ O(bd+1)

i.e. exponential in d

Space

O(bd+1)

keeps every node in memory

Optimal

Yes (if cost = 1 per step), not optimal in general

Disadvantage

Space is the big problem(can easily generate nodes at 5MB/sec so 24hrs = 430GB)

B. Beckert: Einführung in die KI / KI für IM – p.23

Page 51: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search: Properties

Complete Yes (if b is finite)

Time

1+b+b2 +b3 + . . .+bd +b(bd−1) ∈ O(bd+1)

i.e. exponential in d

Space

O(bd+1)

keeps every node in memory

Optimal

Yes (if cost = 1 per step), not optimal in general

Disadvantage

Space is the big problem(can easily generate nodes at 5MB/sec so 24hrs = 430GB)

B. Beckert: Einführung in die KI / KI für IM – p.23

Page 52: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search: Properties

Complete Yes (if b is finite)

Time 1+b+b2 +b3 + . . .+bd +b(bd−1) ∈ O(bd+1)

i.e. exponential in d

Space

O(bd+1)

keeps every node in memory

Optimal

Yes (if cost = 1 per step), not optimal in general

Disadvantage

Space is the big problem(can easily generate nodes at 5MB/sec so 24hrs = 430GB)

B. Beckert: Einführung in die KI / KI für IM – p.23

Page 53: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search: Properties

Complete Yes (if b is finite)

Time 1+b+b2 +b3 + . . .+bd +b(bd−1) ∈ O(bd+1)

i.e. exponential in d

Space O(bd+1)

keeps every node in memory

Optimal

Yes (if cost = 1 per step), not optimal in general

Disadvantage

Space is the big problem(can easily generate nodes at 5MB/sec so 24hrs = 430GB)

B. Beckert: Einführung in die KI / KI für IM – p.23

Page 54: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search: Properties

Complete Yes (if b is finite)

Time 1+b+b2 +b3 + . . .+bd +b(bd−1) ∈ O(bd+1)

i.e. exponential in d

Space O(bd+1)

keeps every node in memory

Optimal Yes (if cost = 1 per step), not optimal in general

Disadvantage

Space is the big problem(can easily generate nodes at 5MB/sec so 24hrs = 430GB)

B. Beckert: Einführung in die KI / KI für IM – p.23

Page 55: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Breadth-first search: Properties

Complete Yes (if b is finite)

Time 1+b+b2 +b3 + . . .+bd +b(bd−1) ∈ O(bd+1)

i.e. exponential in d

Space O(bd+1)

keeps every node in memory

Optimal Yes (if cost = 1 per step), not optimal in general

Disadvantage

Space is the big problem(can easily generate nodes at 5MB/sec so 24hrs = 430GB)

B. Beckert: Einführung in die KI / KI für IM – p.23

Page 56: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Romania with step costs in km

Bucharest

Giurgiu

Urziceni

Hirsova

Eforie

NeamtOradea

Zerind

Arad

Timisoara

LugojMehadia

DobretaCraiova

Sibiu

Fagaras

PitestiRimnicu Vilcea

Vaslui

Iasi

Straight−line distanceto Bucharest

0160242161

77151

241

366

193

178

253329

80199

244

380

226

234

374

98

Giurgiu

UrziceniHirsova

Eforie

Neamt

Oradea

Zerind

Arad

Timisoara

Lugoj

Mehadia

Dobreta

Craiova

Sibiu Fagaras

Pitesti

Vaslui

Iasi

Rimnicu Vilcea

Bucharest

71

75

118

111

70

75120

151

140

99

80

97

101

211

138

146 85

90

98

142

92

87

86

B. Beckert: Einführung in die KI / KI für IM – p.24

Page 57: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Uniform-cost search

Idea

Expand least-cost unexpanded node(costs added up over paths from root to leafs)

Implementation

fringe is queue ordered by increasing path cost

Note

Equivalent to depth-first search if all step costs are equal

B. Beckert: Einführung in die KI / KI für IM – p.25

Page 58: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Uniform-cost search

Arad

B. Beckert: Einführung in die KI / KI für IM – p.26

Page 59: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Uniform-cost search

Zerind Sibiu Timisoara

75 140 118

Arad

B. Beckert: Einführung in die KI / KI für IM – p.26

Page 60: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Uniform-cost search

Arad Oradea

75 71

Zerind Sibiu Timisoara

75 140 118

Arad

B. Beckert: Einführung in die KI / KI für IM – p.26

Page 61: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Uniform-cost search

Arad Lugoj

118 111

Arad Oradea

75 71

Zerind Sibiu Timisoara

75 140 118

Arad

B. Beckert: Einführung in die KI / KI für IM – p.26

Page 62: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Uniform-cost search: Properties

Complete

Yes (if step costs positive)

Time

# of nodes with past-cost less than that of optimal solution

Space

# of nodes with past-cost less than that of optimal solution

Optimal

Yes

B. Beckert: Einführung in die KI / KI für IM – p.27

Page 63: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Uniform-cost search: Properties

Complete Yes (if step costs positive)

Time

# of nodes with past-cost less than that of optimal solution

Space

# of nodes with past-cost less than that of optimal solution

Optimal

Yes

B. Beckert: Einführung in die KI / KI für IM – p.27

Page 64: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Uniform-cost search: Properties

Complete Yes (if step costs positive)

Time # of nodes with past-cost less than that of optimal solution

Space

# of nodes with past-cost less than that of optimal solution

Optimal

Yes

B. Beckert: Einführung in die KI / KI für IM – p.27

Page 65: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Uniform-cost search: Properties

Complete Yes (if step costs positive)

Time # of nodes with past-cost less than that of optimal solution

Space # of nodes with past-cost less than that of optimal solution

Optimal

Yes

B. Beckert: Einführung in die KI / KI für IM – p.27

Page 66: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Uniform-cost search: Properties

Complete Yes (if step costs positive)

Time # of nodes with past-cost less than that of optimal solution

Space # of nodes with past-cost less than that of optimal solution

Optimal Yes

B. Beckert: Einführung in die KI / KI für IM – p.27

Page 67: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

Idea

Expand deepest unexpanded node

Implementation

fringe is a LIFO queue (a stack), i.e. successors go in at front of queue

Note

Depth-first search can perform infinite cyclic excursions

Need a finite, non-cyclic search space (or repeated-state checking)

B. Beckert: Einführung in die KI / KI für IM – p.28

Page 68: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N O

B. Beckert: Einführung in die KI / KI für IM – p.29

Page 69: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N O

B. Beckert: Einführung in die KI / KI für IM – p.29

Page 70: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N OB. Beckert: Einführung in die KI / KI für IM – p.29

Page 71: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N O

B. Beckert: Einführung in die KI / KI für IM – p.29

Page 72: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N O

B. Beckert: Einführung in die KI / KI für IM – p.29

Page 73: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N OB. Beckert: Einführung in die KI / KI für IM – p.29

Page 74: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N O

B. Beckert: Einführung in die KI / KI für IM – p.29

Page 75: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N O

B. Beckert: Einführung in die KI / KI für IM – p.29

Page 76: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N O

B. Beckert: Einführung in die KI / KI für IM – p.29

Page 77: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N OB. Beckert: Einführung in die KI / KI für IM – p.29

Page 78: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N OB. Beckert: Einführung in die KI / KI für IM – p.29

Page 79: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search

A

B C

D E F G

H I J K L M N OB. Beckert: Einführung in die KI / KI für IM – p.29

Page 80: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search: Example Romania

Arad

B. Beckert: Einführung in die KI / KI für IM – p.30

Page 81: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search: Example Romania

Zerind Sibiu Timisoara

Arad

B. Beckert: Einführung in die KI / KI für IM – p.30

Page 82: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search: Example Romania

Arad Oradea

Zerind Sibiu Timisoara

Arad

B. Beckert: Einführung in die KI / KI für IM – p.30

Page 83: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search: Example Romania

Zerind Sibiu Timisoara

Arad Oradea

Zerind Sibiu Timisoara

Arad

B. Beckert: Einführung in die KI / KI für IM – p.30

Page 84: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search: Properties

Complete

Yes: if state space finite

No: if state contains infinite paths or loops

Time

O(bm)

Space

O(bm) (i.e. linear space)

Optimal

No

Disadvantage

Time terrible if m much larger than d

Advantage

Time may be much less than breadth-first search if solutions are dense

B. Beckert: Einführung in die KI / KI für IM – p.31

Page 85: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search: Properties

Complete Yes: if state space finite

No: if state contains infinite paths or loops

Time

O(bm)

Space

O(bm) (i.e. linear space)

Optimal

No

Disadvantage

Time terrible if m much larger than d

Advantage

Time may be much less than breadth-first search if solutions are dense

B. Beckert: Einführung in die KI / KI für IM – p.31

Page 86: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search: Properties

Complete Yes: if state space finite

No: if state contains infinite paths or loops

Time O(bm)

Space

O(bm) (i.e. linear space)

Optimal

No

Disadvantage

Time terrible if m much larger than d

Advantage

Time may be much less than breadth-first search if solutions are dense

B. Beckert: Einführung in die KI / KI für IM – p.31

Page 87: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search: Properties

Complete Yes: if state space finite

No: if state contains infinite paths or loops

Time O(bm)

Space O(bm) (i.e. linear space)

Optimal

No

Disadvantage

Time terrible if m much larger than d

Advantage

Time may be much less than breadth-first search if solutions are dense

B. Beckert: Einführung in die KI / KI für IM – p.31

Page 88: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search: Properties

Complete Yes: if state space finite

No: if state contains infinite paths or loops

Time O(bm)

Space O(bm) (i.e. linear space)

Optimal No

Disadvantage

Time terrible if m much larger than d

Advantage

Time may be much less than breadth-first search if solutions are dense

B. Beckert: Einführung in die KI / KI für IM – p.31

Page 89: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Depth-first search: Properties

Complete Yes: if state space finite

No: if state contains infinite paths or loops

Time O(bm)

Space O(bm) (i.e. linear space)

Optimal No

Disadvantage

Time terrible if m much larger than d

Advantage

Time may be much less than breadth-first search if solutions are dense

B. Beckert: Einführung in die KI / KI für IM – p.31

Page 90: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search

Depth-limited search

Depth-first search with depth limit

Iterative deepening search

Depth-limit search with ever increasing limits

function ITERATIVE-DEEPENING-SEARCH( problem) returns a solution or failure

inputs: problem /* a problem */

for depth← 0 to ∞ do

result← DEPTH-LIMITED-SEARCH( problem, depth)

if result 6= cutoff then return result

end

B. Beckert: Einführung in die KI / KI für IM – p.32

Page 91: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search

Depth-limited search

Depth-first search with depth limit

Iterative deepening search

Depth-limit search with ever increasing limits

function ITERATIVE-DEEPENING-SEARCH( problem) returns a solution or failure

inputs: problem /* a problem */

for depth← 0 to ∞ do

result← DEPTH-LIMITED-SEARCH( problem, depth)

if result 6= cutoff then return result

end

B. Beckert: Einführung in die KI / KI für IM – p.32

Page 92: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search with depth limit 0

Limit = 0 A A

B. Beckert: Einführung in die KI / KI für IM – p.33

Page 93: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search with depth limit 1

Limit = 1 A

B C

A

B C

A

B C

A

B C

B. Beckert: Einführung in die KI / KI für IM – p.34

Page 94: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search with depth limit 2

Limit = 2 A

B C

D E F G

A

B C

D E F G

A

B C

D E F G

A

B C

D E F G

A

B C

D E F G

A

B C

D E F G

A

B C

D E F G

A

B C

D E F G

B. Beckert: Einführung in die KI / KI für IM – p.35

Page 95: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search with depth limit 3

Limit = 3

A

B C

D E F G

H I J K L M N O

A

B C

D E F G

H I J K L M N O

A

B C

D E F G

H I J K L M N O

A

B C

D E F G

H I J K L M N O

A

B C

D E F G

H I J K L M N O

A

B C

D E F G

H I J K L M N O

A

B C

D E F G

H I J K L M N O

A

B C

D E F G

H I J K L M N O

A

B C

D E F G

H I J K L M N O

A

B C

D E F G

H I J K L M N O

A

B C

D E F G

H J K L M N OI

A

B C

D E F G

H I J K L M N O

B. Beckert: Einführung in die KI / KI für IM – p.36

Page 96: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Example Romania with l = 0

Arad

B. Beckert: Einführung in die KI / KI für IM – p.37

Page 97: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Example Romania with l = 1

Arad

B. Beckert: Einführung in die KI / KI für IM – p.38

Page 98: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Example Romania with l = 1

Zerind Sibiu Timisoara

Arad

B. Beckert: Einführung in die KI / KI für IM – p.38

Page 99: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Example Romania with l = 2

Arad

B. Beckert: Einführung in die KI / KI für IM – p.39

Page 100: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Example Romania with l = 2

Zerind Sibiu Timisoara

Arad

B. Beckert: Einführung in die KI / KI für IM – p.39

Page 101: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Example Romania with l = 2

Arad Oradea

Zerind Sibiu Timisoara

Arad

B. Beckert: Einführung in die KI / KI für IM – p.39

Page 102: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Example Romania with l = 2

Arad Oradea Rimnicu VilceaFagarasArad Oradea

Zerind Sibiu Timisoara

Arad

B. Beckert: Einführung in die KI / KI für IM – p.39

Page 103: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Example Romania with l = 2

Arad LugojArad Oradea Rimnicu VilceaFagarasArad Oradea

Zerind Sibiu Timisoara

Arad

B. Beckert: Einführung in die KI / KI für IM – p.39

Page 104: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Properties

Complete

Yes

Time

(d +1)b0 +db1 +(d−1)b2 + . . .+bd ∈ O(bd+1)

Space

O(bd)

Optimal

Yes (if step cost = 1)

(Depth-First) Iterative-Deepening Search often used in practice for

search spaces of large, infinite, or unknown depth.

B. Beckert: Einführung in die KI / KI für IM – p.40

Page 105: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Properties

Complete Yes

Time

(d +1)b0 +db1 +(d−1)b2 + . . .+bd ∈ O(bd+1)

Space

O(bd)

Optimal

Yes (if step cost = 1)

(Depth-First) Iterative-Deepening Search often used in practice for

search spaces of large, infinite, or unknown depth.

B. Beckert: Einführung in die KI / KI für IM – p.40

Page 106: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Properties

Complete Yes

Time (d +1)b0 +db1 +(d−1)b2 + . . .+bd ∈ O(bd+1)

Space

O(bd)

Optimal

Yes (if step cost = 1)

(Depth-First) Iterative-Deepening Search often used in practice for

search spaces of large, infinite, or unknown depth.

B. Beckert: Einführung in die KI / KI für IM – p.40

Page 107: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Properties

Complete Yes

Time (d +1)b0 +db1 +(d−1)b2 + . . .+bd ∈ O(bd+1)

Space O(bd)

Optimal

Yes (if step cost = 1)

(Depth-First) Iterative-Deepening Search often used in practice for

search spaces of large, infinite, or unknown depth.

B. Beckert: Einführung in die KI / KI für IM – p.40

Page 108: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Properties

Complete Yes

Time (d +1)b0 +db1 +(d−1)b2 + . . .+bd ∈ O(bd+1)

Space O(bd)

Optimal Yes (if step cost = 1)

(Depth-First) Iterative-Deepening Search often used in practice for

search spaces of large, infinite, or unknown depth.

B. Beckert: Einführung in die KI / KI für IM – p.40

Page 109: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Iterative deepening search: Properties

Complete Yes

Time (d +1)b0 +db1 +(d−1)b2 + . . .+bd ∈ O(bd+1)

Space O(bd)

Optimal Yes (if step cost = 1)

(Depth-First) Iterative-Deepening Search often used in practice for

search spaces of large, infinite, or unknown depth.

B. Beckert: Einführung in die KI / KI für IM – p.40

Page 110: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Comparison

CriterionBreadth-

firstUniform-

costDepth-

firstIterative

deepening

Complete? Yes∗ Yes∗ No Yes

Time bd+1 ≈ bd bm bd

Space bd+1 ≈ bd bm bd

Optimal? Yes∗ Yes No Yes

B. Beckert: Einführung in die KI / KI für IM – p.41

Page 111: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Comparison

Breadth-first search Iterative deepening search

B. Beckert: Einführung in die KI / KI für IM – p.42

Page 112: Introduction to Artificial Intelligence Problem Solving and ...beckert/teaching/Einfuehrung-KI-WS0304/04... · Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara

Summary

Problem formulation usually requires abstracting away real-world detailsto define a state space that can feasibly be explored

Variety of uninformed search strategies

Iterative deepening search uses only linear spaceand not much more time than other uninformed algorithms

B. Beckert: Einführung in die KI / KI für IM – p.43