Вы находитесь на странице: 1из 23

Example: Romania Artificial Intelligence

Problem: On holiday in Romania; currently in Arad.


Flight leaves tomorrow from Bucharest. Find a short
route to drive to Bucharest. Problem Solving and Search
Formulate problem:
states: various cities
actions: drive between cities Readings: Chapter 3 of Russell & Norvig.
solution: sequence of cities, e.g., Arad, Sibiu,
Fagaras, Bucharest

Artificial Intelligence – p.2/89 Artificial Intelligence – p.1/89

Problem types Example: Romania


Deterministic, fully observable =⇒ single-state problem
Oradea
Agent knows exactly which state it will be in; solution 71
Neamt
is a sequence Zerind 151
87
75
Iasi
Non-observable =⇒ conformant problem Arad 140
92
Agent may have no idea where it is; solution (if any) Sibiu
99 Fagaras
118
is a sequence 80
Vaslui

Timisoara Rimnicu Vilcea


Nondeterministic and/or partially observable =⇒ 142
111 Pitesti 211
contingency problem Lugoj 97
70 98
85 Hirsova
percepts provide new information about current state Mehadia 146 101 Urziceni
75 138 86
solution is a tree or policy Dobreta 120
Bucharest
90
often interleave search, execution Craiova
Giurgiu
Eforie

Unknown state space =⇒ exploration problem (“online”)

Artificial Intelligence – p.4/89 Artificial Intelligence – p.3/89


Example: Vacuum World Problem Solving
1 2 We will start by considering the simpler cases in which the
following holds.
3 4

The agent’s world (environment) is representable by a


5 6 discrete set of states.

7 8 The agent’s actions are representable by a discrete set of


Single-state, operators.
start in #5.
Solution?? The world is static and deterministic.

Artificial Intelligence – p.6/89 Artificial Intelligence – p.5/89

Example: Vacuum World Example: Vacuum World


1 2 1 2

3 4 3 4

5 6 5 6

7 8 7 8
Single-state, start in #5. Single-state, start in #5.
Solution?? [Right, Suck] Solution?? [Right, Suck]
Conformant, start in Conformant, start in
{1, 2, 3, 4, 5, 6, 7, 8} {1, 2, 3, 4, 5, 6, 7, 8}
e.g., Right goes to {2, 4, 6, 8}. e.g., Right goes to
Solution?? {2, 4, 6, 8}.
[Right, Suck, Lef t, Suck] Solution??
Artificial Intelligence – p.8/89 Artificial Intelligence – p.7/89

Contingency, start in #5
Murphy’s Law: can
Single-state problem formulation Example: Vacuum World
A problem is defined by four items: 1 2

initial state e.g., “at Arad”


successor function S(x) = set of action–state pairs 3 4
e.g., S(Arad) = {hArad → Zerind, Zerindi, . . .}
goal test, can be explicit, e.g., x = “at Bucharest” 5 6
implicit, e.g., N oDirt(x)
path cost (additive) e.g., sum of distances, number of 7 8
actions executed, etc. Usually given as c(x, a, y), the Single-state, start in #5.
step cost from x to y by action a, assumed to be ≥ 0. Solution?? [Right, Suck]
A solution is a sequence of actions leading from the Conformant, start in
initial state to a goal state {1, 2, 3, 4, 5, 6, 7, 8}
e.g., Right goes to {2, 4, 6, 8}.
Solution??
[Right, Suck, Lef t, Suck]
Artificial Intelligence – p.10/89 Artificial Intelligence – p.9/89

Contingency, start in #5
Murphy’s Law: can
State space graph of vacuum world Selecting a State Space
L
R
R Real world is absurdly complex ⇒ state space must be
S
L

S
abstracted for problem solving
L
R
R L
R
R
(Abstract) state = set of real states
L
S S
L
(Abstract) action = complex combination of real actions
S S

R
e.g., “Arad → Zerind” represents a complex set of
L

L
R
possible routes, detours, rest stops, etc.
S S
For guaranteed realizability, any real state “in Arad”
states?? must get to some real state “in Zerind”.
actions?? Each abstract action should be “easier” than the
goal test?? original problem!
path cost??
(Abstract) solution = set of real paths that are solutions
in the real world

Artificial Intelligence – p.12/89 Artificial Intelligence – p.11/89


Formulating Problem as a Graph State space graph of vacuum world
In the graph L
R
R

each node represents a possible state; S S

R R
L R L R

a node is designated as the initial state; L


S S
L

S S

one or more nodes represent goal states, states in which L R

L
the agent’s goal is considered accomplished. S S

states??: integer dirt and robot locations (ignore dirt


each edge represents a state transition caused by a
amounts)
specific agent action;
actions??: Lef t, Right, Suck , N oOp
associated to each edge is the cost of performing that goal test??: no dirt
transition. path cost??: 1 per action (0 for N oOp)

Artificial Intelligence – p.14/89 Artificial Intelligence – p.13/89

Problem Solving as Search Search Graph


How do we reach a goal state?
Search space: set of states reachable from an initial state S0 4
initial state
4 C
via a (possibly empty/finite/infinite) sequence of state A B
3
transitions. 7
S 5 5
F
2
To achieve the problem’s goal goal states

4
search the space for a (possibly optimal) sequence of D
2
E
3
G

transitions starting from S0 and leading to a goal state; There may be several possible ways. Or none!
execute (in order) the actions associated to each
transition in the identified sequence. Factors to consider:

Depending on the features of the agent’s world the two steps cost of finding a path;
above can be interleaved. cost of traversing a path.

Artificial Intelligence – p.16/89 Artificial Intelligence – p.15/89


Example: The 8-puzzle Problem Solving as Search

Reduce the original problem to a search problem.


A solution for the search problem is a path initial
state–goal state.
2 8 3
The solution for the original problem is either
1 6 4 the sequence of actions associated with the path or
the description of the goal state.
7 5
It can be generalized to 15-puzzle, 24-puzzle, or
(n2 − 1)-puzzle for n ≥ 6.

Artificial Intelligence – p.18/89 Artificial Intelligence – p.17/89

Example: The 8-puzzle Example: The 8-puzzle


States: configurations of tiles Go from state S to state G.
2 8 3 1 2 3
Operators: move one tile Up/Down/Left/Right 1 6 4 8 4
7 5 7 6 5
(S) (G)

There are 9! = 362, 880 possible states (all permutations


of {⊓
⊔, 1, 2, 3, 4, 5, 6, 7, 8}). 2 8 3
1 6 4
There are 16! possible states for 15-puzzle. 7 5
L
R
Not all states are directly reachable from a given state. L
D U
R
(In fact, exactly half of them are reachable from a given 2 8 3 2 8 3 2 8 3
state.) 1 6 4
7 5
1 4
7 6 5
1 6 4
7 5
R L
D U D U D U
L R
2 8 3 2 8 3 2 3 2 8 3 2 8 3
How can an artificial agent represent the states and the state 6 4 1 4 1 8 4 1 4 1 6
1 7 5 7 6 5 7 6 5 7 6 5 7 5 4
space for this problem? Artificial Intelligence – p.20/89 Artificial Intelligence – p.19/89
Formulating the 8-puzzle Problem Problem Formulation

States: each represented by a 3 × 3 array of numbers in 1. Choose an appropriate data structure to represent the
[0 . . . 8], where value 0 is for the empty cell. world states.
2. Define each operator as a precondition/effects pair
2 8 3 where the
precondition holds exactly in the states the operator
1 6 4
applies to,
7 5 2 8 3 effects describe how a state changes into a
becomes A = 1 6 4 successor state by the application of the operator.
7 0 5 3. Specify an initial state.
4. Provide a description of the goal (used to check if a
reached state is a goal state).

Artificial Intelligence – p.22/89 Artificial Intelligence – p.21/89

Preconditions and Effects Formulating the 8-puzzle Problem


Example: Op (3,2,R)
Operators: 24 operators of the form Op (r,c,d)
2 8 3 2 8 3 where r, c ∈ {1, 2, 3}, d ∈ {L, R, U, D}.
Op (3,2,R)
1 6 4 =⇒ 1 6 4
Op (r,c,d) moves the empty space at position (r, c) in
7 0 5 7 5 0
the direction d.
Preconditions:
( 2] = 0
A[3,
A[3, 2] ← A[3, 3]
Effects: 2 8 3 2 8 3
A[3, 3] ← 0 Op (3,2,L)
1 6 4 =⇒ 1 6 4
7 0 5 0 7 5
We have 24 operators in this problem formulation . . .
20 too many!
Artificial Intelligence – p.24/89 Artificial Intelligence – p.23/89
A Better Formulation A Better Formulation

Operators: 4 operators of the form Op d where States: each represented by a pair (A, (i, j)) where:
d ∈ {L, R, U, D}. A is a 3 × 3 array of numbers in [0 . . . 8]
(i, j) is the position of the empty space (0) in the array.
Op d moves the empty space in the direction d.
2 8 3
2 8 3 2 8 3 1 6 4
Op L
1 6 4 =⇒ 1 6 4 7 5 2 8 3
7 0 5 0 7 5 becomes ( 1 6 4 , (3, 2))
7 0 5

Artificial Intelligence – p.26/89 Artificial Intelligence – p.25/89

Half states are not reachable? Preconditions and Effects


Can this be done? Example: Op L

1 2 3 1 2 3 2 8 3 2 8 3
any steps Op L
4 5 6 =⇒ 4 5 6 ( 1 6 4 , (3, 2)) =⇒ ( 1 6 4 (3, 1))
7 8 8 7 7 0 5 0 7 5

Let (r0 , c0 ) be the position of 0 in A.


$1,000 award for anyone who can do it!
Preconditions: c0 > 1

 A[r0 , c0 ]
 ← A[r0 , c0 − 1]
Effects: A[r0 , c0 − 1] ← 0

 (r , c )
0 0 ← (r0 , c0 − 1)

Artificial Intelligence – p.28/89 Artificial Intelligence – p.27/89


The Water Jugs Problem Half states are not reachable?

a1 a2 a3
3gl 4gl
a4 a5 a6
a7 a8 a9

Let the 8-puzzle be represented by (a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 ). We say


(ai , aj ) is an inversion if neither ai nor aj is blank, i < j and ai > aj .

1 2 3 1 2 3
Get exactly 2 gallons of water into the 4gl jug. 4 5 6 4 5 6
7 8 8 7

The first one has 0 inversions and the second has 1.

Artificial Intelligence – p.30/89


Claim: # of inversions modulo two remains the same after each move.
Artificial Intelligence – p.29/89

The Water Jugs Problem: Operators The Water Jugs Problem


F4: fill jug4 from the pump. States: Determined by the amount of water in each jug.
precond: J4 < 4 effect: J4′ =4
E4: empty jug4 on the ground. State Representation: Two real-valued variables, J3 , J4 ,
precond: J4 > 0 effect: J4′ = 0 indicating the amount of water in the two jugs, with the
E4-3: pour water from jug4 into jug3 until jug3 is full. constraints:
precond: J3 < 3, effect: J3′ = 3,
0 ≤ J3 ≤ 3, 0 ≤ J4 ≤ 4
J4 ≥ 3 − J3 J4′ = J4 − (3 − J3 )
P3-4: pour water from jug3 into jug4 until jug4 is full. Initial State Description
precond: J4 < 4, effect: J4′ = 4, J3 = 0, J4 = 0
J3 ≥ 4 − J4 J3′ = J3 − (4 − J4 )
E3-4: pour water from jug3 into jug4 until jug3 is empty. Goal State Description:
precond: J3 + J4 < 4, effect: J4′ = J3 + J4 ,
J4 = 2 ⇐ non exhaustive description
J3 > 0 J3′ = 0
... Artificial Intelligence – p.32/89 Artificial Intelligence – p.31/89
Real-World Search Problems The Water Jugs Problem

Route Finding Problem Search Graph

(computer networks, airline travel planning system, . . . ) J_3 = 0


J_4 = 0 J_4 = 2 F4
J_3 = 0
J_4 = 0 F3

Travelling Salesman Optimization Problem J_3 = 0


J_4 = 4
J_3 = 3
J_4 = 0
F3 P4-3
(package delivery, automatic drills, . . . ) F4 E3-4

J_3 = 3 J_3 = 3 J_3 = 0 J_3 = 0


J_4 = 4 J_4 = 1 J_4 = 4 J_4 = 3
F3
Layout Problems
... ... ...
(VLSI layout, furniture layout, packaging, . . . ) J_3 = 3
J_4 = 3
P3-4

Assembly Sequencing E4
J_3 = 2
J_4 = 4
...

(assembly of electric motors, . . . ) J_3 = 2


J_4 = 0
E3-4

Task Scheduling J_3 = 0


(manufacturing, timetables, . . . ) J_4 = 2

Artificial Intelligence – p.34/89 Artificial Intelligence – p.33/89

More on Graphs Problem Solution


A graph is a set of notes and edges (arcs) between them. Problems whose solution is a description of how to
C reach a goal state from the initial state:
A B
n-puzzle
S F route-finding problem
assembly sequencing
D E G Problems whose solution is simply a description of the
A graph is directed if an edge can be traversed only in a goal state itself:
specified direction. 8-queen problem
scheduling problems
When an edge is directed from ni to nj
layout problems
it is univocally identified by the pair (ni , nj )
ni is a parent (or predecessor ) of nj
nj is a child (or successor ) of ni
Artificial Intelligence – p.36/89 Artificial Intelligence – p.35/89
From Search Graphs to Search Trees Directed Graphs
C
The set of all possible paths of a graph can be represented A B
as a tree.
S F
A tree is a directed acyclic graph all of whose nodes
have at most one parent. D E G

A root of a tree is a node with no parents. A path, of length k ≥ 0, is a sequence


a
A leaf is a node with no children. h(n1 , n2 ), (n2 , n3 ), . . . , (nk , nk+1 )i of k successive edges.
Ex: hi, h(S, D)i, h(S, D), (D, E), (E, B)i
The branching factor of a node is the number of its
children. For 1 ≤ i < j ≤ k + 1,
Ni is a ancestor of Nj ; Nj is a descendant of Ni .
Graphs can be turned into trees by duplicating nodes and
breaking cyclic paths, if any. A graph is cyclic if it has a path starting from and ending
Artificial Intelligence – p.38/89
into the same node. Ex: h(A, D), (D, E), (E, A)i Artificial Intelligence – p.37/89

a
Note that a path of length k > 0 contains k + 1 nodes.

Tree Search Algorithms From Graphs to Trees


Basic idea: offline, simulated exploration of state space by generating To unravel a graph into a tree choose a root node and trace
successors of already-explored states (a.k.a. expanding states) every path from that node until you reach a leaf node or a
function T REE -S EARCH( problem, strategy) returns
a solution, or failure node already in that path.
initialize the search tree using the initial state of problem S depth 0

loop do C D A depth 1
A B
if there are no candidates for expansion then return failure E D B depth 2
S F
choose a leaf node for expansion according to strategy
A G E F C
if the node contains a goal state then return the solution D E G depth 3

else expand the node and add the resulting nodes to the search tree D ... A G depth 4

end
must remember which nodes have been visited
a node may get duplicated several times in the tree
the tree has infinite paths only if the graph has infinite non-cyclic paths.

Artificial Intelligence – p.40/89 Artificial Intelligence – p.39/89


Tree search example Tree Search Example

Arad Arad

Sibiu Timisoara Zerind Sibiu Timisoara Zerind

Arad Fagaras Oradea Rimnicu Vilcea Arad Lugoj Arad Oradea Arad Fagaras Oradea Rimnicu Vilcea Arad Lugoj Arad Oradea

Artificial Intelligence – p.42/89 Artificial Intelligence – p.41/89

Implementation: states vs. nodes Tree Search Example


A state is a (representation of) a physical configuration
A node is a data structure constituting part of a search tree Arad
includes parent, children, depth, path cost g(x)
States do not have parents, children, depth, or path cost!
Sibiu Timisoara Zerind
parent, action

Arad Fagaras Oradea Rimnicu Vilcea Arad Lugoj Arad Oradea


depth = 6
State 5 4 Node
g=6
6 1 88

state
7 3 22

The E XPAND function creates new nodes, filling in the various


fields and using the S UCCESSOR F N of the problem to create
the corresponding states.

Artificial Intelligence – p.44/89 Artificial Intelligence – p.43/89


Uninformed Search Strategies Search Strategies
A strategy is defined by picking the order of node
expansion. Strategies are evaluated along the following
Uninformed strategies use only the information available dimensions:
in the problem definition
completeness—does it always find a solution if one
Breadth-first search exists?
time complexity—number of nodes
Uniform-cost search
generated/expanded
Depth-first search space complexity—maximum number of nodes in
Depth-limited search memory
Iterative deepening search 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 least-cost solution
m—maximum depth of the state space (may be ∞)
Artificial Intelligence – p.46/89 Artificial Intelligence – p.45/89

Breadth-First Search Breadth-First Search

Expand shallowest unexpanded node Expand shallowest unexpanded node


Implementation: fringe is a FIFO queue, i.e., new Implementation: fringe is a FIFO queue, i.e., new
successors go at end successors go at end

A A

B C B C

D E F G D E F G
Artificial Intelligence – p.48/89 Artificial Intelligence – p.47/89
Breadth-First Search Breadth-First Search

Expand shallowest unexpanded node Expand shallowest unexpanded node


Implementation: fringe is a FIFO queue, i.e., new Implementation: fringe is a FIFO queue, i.e., new
successors go at end successors go at end
A A

B C B C

D E F G
D E F G
Artificial Intelligence – p.50/89 Artificial Intelligence – p.49/89

Properties of Breadth-First Search Properties of Breadth-First Search


Complete??
Complete?? Yes (if b is finite)
Time??

Artificial Intelligence – p.52/89 Artificial Intelligence – p.51/89


Properties of Breadth-First Search Properties of Breadth-First Search

Complete?? Yes (if b is finite) Complete?? Yes (if b is finite)


Time?? 1 + b + b2 + b3 + . . . + bd + b(bd − 1) = O(bd+1 ), i.e., Time?? 1 + b + b2 + b3 + . . . + bd + b(bd − 1) = O(bd+1 ), i.e.,
exp. in d exp. in d
Space?? O(bd+1 ) (keeps every node in memory) Space??
Optimal??

Artificial Intelligence – p.54/89 Artificial Intelligence – p.53/89

Properties of Breadth-First Search Properties of Breadth-First Search

Complete?? Yes (if b is finite) Complete?? Yes (if b is finite)


Time?? 1 + b + b2 + b3 + . . . + bd + b(bd − 1) = O(bd+1 ), i.e., Time?? 1 + b + b2 + b3 + . . . + bd + b(bd − 1) = O(bd+1 ), i.e.,
exp. in d exp. in d
Space?? O(bd+1 ) (keeps every node in memory) Space?? O(bd+1 ) (keeps every node in memory)
Optimal?? Yes (if cost = 1 per step); not optimal in general Optimal?? Yes (if cost = 1 per step); not optimal in general
Space?? It is the big problem; can easily generate nodes at Space??
10MB/sec so 24hrs = 860GB.

Artificial Intelligence – p.56/89 Artificial Intelligence – p.55/89


Depth-First Search Uniform-Cost Search

Expand deepest unexpanded node Expand least-cost unexpanded node


Implementation: fringe = LIFO queue, i.e., put successors at Implementation: fringe = queue ordered by path cost
front Equivalent to breadth-first if step costs all equal
A Complete?? Yes, if step cost ≥ ǫ
Time?? # of nodes with g ≤ cost of optimal solution,
O(b⌈C /ǫ⌉ ) where C ∗ is the cost of the optimal solution

B C
Space?? # of nodes with g ≤ cost of optimal solution,
O(b⌈C /ǫ⌉ )

D E F G Optimal?? Yes—nodes expanded in increasing order of g(n)

H I J K L M N O

Artificial Intelligence – p.58/89 Artificial Intelligence – p.57/89

Depth-First Search Depth-First Search

Expand deepest unexpanded node Expand deepest unexpanded node


Implementation: fringe = LIFO queue, i.e., put successors at Implementation: fringe = LIFO queue, i.e., put successors at
front front
A A

B C B C

D E F G D E F G

H I J K L M N O H I J K L M N O

Artificial Intelligence – p.60/89 Artificial Intelligence – p.59/89


Depth-First Search Depth-First Search

Expand deepest unexpanded node Expand deepest unexpanded node


Implementation: fringe = LIFO queue, i.e., put successors at Implementation: fringe = LIFO queue, i.e., put successors at
front front
A A

B C B C

D E F G D E F G

H I J K L M N O H I J K L M N O

Artificial Intelligence – p.62/89 Artificial Intelligence – p.61/89

Depth-First Search Depth-First Search

Expand deepest unexpanded node Expand deepest unexpanded node


Implementation: fringe = LIFO queue, i.e., put successors at Implementation: fringe = LIFO queue, i.e., put successors at
front front
A
A
B C

D E F G
B C
H I J K L M N O

D E F G

H I J K L M N O

Artificial Intelligence – p.64/89 Artificial Intelligence – p.63/89


Depth-First Search Depth-First Search

Expand deepest unexpanded node Expand deepest unexpanded node


Implementation: fringe = LIFO queue, i.e., put successors at Implementation: fringe = LIFO queue, i.e., put successors at
front front
A A

B C B C

D E F G D E F G

H I J K L M N O H I J K L M N O

Artificial Intelligence – p.66/89 Artificial Intelligence – p.65/89

Depth-First Search Depth-First Search

Expand deepest unexpanded node Expand deepest unexpanded node


Implementation: fringe = LIFO queue, i.e., put successors at Implementation: fringe = LIFO queue, i.e., put successors at
front front
A A

B C B C

D E F G D E F G

H I J K L M N O H I J K L M N O

Artificial Intelligence – p.68/89 Artificial Intelligence – p.67/89


Properties of depth-first search Depth-First Search
Complete??
Expand deepest unexpanded node
Implementation: fringe = LIFO queue, i.e., put successors at
front
A

B C

D E F G

H I J K L M N O

Artificial Intelligence – p.70/89 Artificial Intelligence – p.69/89

Properties of depth-first search Properties of depth-first search


Complete?? No: fails in infinite-depth spaces, spaces with Complete?? No: fails in infinite-depth spaces, spaces with
loops Modify to avoid repeated states along path ⇒ loops Modify to avoid repeated states along path ⇒
complete in finite spaces complete in finite spaces
Time?? O(bm ): terrible if m is much larger than d but if Time??
solutions are dense, may be much faster than breadth-first
Space??

Artificial Intelligence – p.72/89 Artificial Intelligence – p.71/89


Properties of depth-first search Properties of depth-first search
Complete?? No: fails in infinite-depth spaces, spaces with Complete?? No: fails in infinite-depth spaces, spaces with
loops Modify to avoid repeated states along path ⇒ loops Modify to avoid repeated states along path ⇒
complete in finite spaces complete in finite spaces
Time?? O(bm ): terrible if m is much larger than d but if Time?? O(bm ): terrible if m is much larger than d but if
solutions are dense, may be much faster than breadth-first solutions are dense, may be much faster than breadth-first
Space?? O(bm), i.e., linear space! Space?? O(bm), i.e., linear space!
Optimal?? No Optimal??

Artificial Intelligence – p.74/89 Artificial Intelligence – p.73/89

Iterative Deepening Search Depth-Limited Search


= depth-first search with depth limit l, i.e., nodes at depth l
function Iterative-Deepening-Search (problem) return soln
have no successors
for depth from 0 to MAX-INT do
result := Depth-Limited-Search(problem, depth)
function Depth-Limited-Search (problem, limit) return soln/fail/cutoff
if (result != cutoff) then return result
return Recursive-DLS(Make-Node(Initial-State(problem)), problem, limit)
end for
end function
end function

function Recursive-DLS (node, problem, limit) return soln/fail/cutoff


cutoff-occurred := false;
if (Goal-State(problem, State(node))) then return node;
else if (Depth(node) == limit) then return cutoff;
else for each successor in Expand(node, problem) do
result := Recursive-DLS(successor, problem, limit)
if (result == cutoff) then cutoff-occurred := true;
else if (result != fail) then return result;
end for
if (cutoff-occurred) then return cutoff; else return fail;
end function

Artificial Intelligence – p.76/89 Artificial Intelligence – p.75/89


Iterative deepening search l = 1 Iterative deepening search l = 0

Limit = 0 A A

Limit = 1 A A A A

B C B C B C B C

Artificial Intelligence – p.78/89 Artificial Intelligence – p.77/89

Iterative deepening search l = 3 Iterative deepening search l = 2

Limit = 3 A A A A Limit = 2 A A A A

B C B C B C B C B C B C B C B C

D E F G D E F G D E F G D E F G D E F G D E F G D E F G D E F G

H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O
A A A A
A A A A
B C B C B C B C
B C B C B C B C
D E F G D E F G D E F G D E F G
D E F G D E F G D E F G D E F G

H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O

A A A A

B C B C B C B C

D E F G D E F G D E F G D E F G

H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O

Artificial Intelligence – p.80/89 Artificial Intelligence – p.79/89


Properties of iterative deepening search Properties of iterative deepening search
Complete?? Yes Complete??
Time??

Artificial Intelligence – p.82/89 Artificial Intelligence – p.81/89

Properties of iterative deepening search Properties of iterative deepening search


Complete?? Yes Complete?? Yes
Time?? (d + 1)b0 + db1 + (d − 1)b2 + . . . + bd = O(bd ) Time?? (d + 1)b0 + db1 + (d − 1)b2 + . . . + bd = O(bd )
Space?? O(bd) Space??
Optimal??

Artificial Intelligence – p.84/89 Artificial Intelligence – p.83/89


Summary of Algorithms Properties of iterative deepening search
Complete?? Yes
Criterion Breadth- Uniform- Depth- Depth- Iterative Time?? (d + 1)b0 + db1 + (d − 1)b2 + . . . + bd = O(bd )
First Cost First Limited Deepening Space?? O(bd)
Complete? Yes∗ Yes∗ No Yes, if l ≥ d Yes Optimal?? Yes, if step cost = 1 Can be modified to explore
Time b d+1
b ⌈C ∗ /ǫ⌉
b m
b l
bd uniform-cost tree

Space bd+1 b⌈C /ǫ⌉
bm bl bd
Optimal? Yes∗ Yes∗ No No Yes Numerical comparison for b = 10 and d = 5, solution at far right:

N (IDS) = 50 + 400 + 3, 000 + 20, 000 + 100, 000 = 123, 450


N (BFS) = 10 + 100 + 1, 000 + 10, 000 + 100, 000 + 999, 990 = 1, 111, 100

Artificial Intelligence – p.86/89 Artificial Intelligence – p.85/89

Summary Repeated states

Problem formulation usually requires abstracting away


real-world details to define a state space that can Failure to detect repeated states can turn a linear problem
feasibly be explored into an exponential one!
Variety of uninformed search strategies
A A
Iterative deepening search uses only linear space and
not much more time than other uninformed algorithms
B B B

C C C C C

Artificial Intelligence – p.88/89 Artificial Intelligence – p.87/89


Example: Romania
For a given strategy, what is the order of nodes to be generated (or stored), and expanded?
With or without checking duplicated nodes?

Oradea
71
Neamt

Zerind 87
Breadth-first 75 151
Iasi
Arad
Depth-first 140
92
Sibiu Fagaras
99
118
Uniform-cost 80
Vaslui

Timisoara Rimnicu Vilcea


Depth-limited 142
111 Pitesti 211
Lugoj 97
Iterative-deepening 70 98
146 85 Hirsova
Mehadia 101 Urziceni
75 138 86
Bucharest
Dobreta 120
90
Craiova Eforie
Giurgiu

Artificial Intelligence – p.89/89