Professional Documents
Culture Documents
Artificial Intelligence
Problem:
Formulate problem:
Readings:
Problem types
Example: Romania
Oradea
71
75
Neamt
Zerind
87
151
Iasi
Arad
140
Sibiu
Fagaras
111
Vaslui
80
Rimnicu Vilcea
Timisoara
92
99
118
Lugoj
Pitesti
97
142
211
70
98
Mehadia
75
Dobreta
146
85
101
86
138
Bucharest
120
Craiova
Hirsova
Urziceni
90
Giurgiu
Eforie
Problem Solving
We will start by considering the simpler cases in which the
following holds.
The agents world (environment) is representable by a
discrete set of states.
The agents actions are representable by a discrete set of
operators.
Single-state,
start in #5.
Solution??
Conformant, start in
{1, 2, 3, 4, 5, 6, 7, 8}
e.g., Right goes to {2, 4, 6, 8}.
Solution??
[Right, Suck, Lef t, Suck]
Conformant, start in
{1, 2, 3, 4, 5, 6, 7, 8}
e.g., Right goes to
{2, 4, 6, 8}.
Solution??
Artificial Intelligence p.8/89
Contingency, start in #5
Murphys Law:
can
Contingency, start in #5
Murphys Law:
can
R
L
R
L
S
L
S
S
S
S
R
L
R
L
S
states??
actions??
goal test??
path cost??
In the graph
R
L
R
L
L
S
S
S
S
R
R
L
S
Search Graph
How do we reach a goal state?
Search space:
initial state
B
7
goal states
Factors to consider:
search
execute
2 8 3
1 6 4
7
5
configurations of tiles
Operators: move one tile Up/Down/Left/Right
States:
2 8 3
1 6 4
7
5
1 2 3
4
8
7 6 5
(S)
(G)
2 8 3
1 6 4
7
5
L
2 8 3
1 6 4
7 5
D
How can an artificial agent represent the states and the state
2 8 3
6 4
1 7 5
2 8 3
1
4
7 6 5
L
2 8 3
1 4
7 6 5
3
2
1 8 4
7 6 5
2 8 3
1 6 4
7 5
D
R
2 8 3
1 4
7 6 5
2 8 3
1 6
7 5 4
Artificial Intelligence p.19/89
2 8 3
1 6 4
7
5
Problem Formulation
1. Choose an appropriate data structure to represent the
world states.
2. Define each operator as a precondition/effects pair
where the
precondition holds exactly in the states the operator
applies to,
effects describe how a state changes into a
successor state by the application of the operator.
2 8 3
becomes A = 1 6 4
7 0 5
Operators:
2 8 3
1 6 4
7 0 5
Preconditions:
Effects:
Op (3,2,R)
2 8 3
1 6 4
7 5 0
A[3,
( 2] = 0
A[3, 2] A[3, 3]
A[3, 3] 0
2 8 3
1 6 4
7 0 5
Op (3,2,L)
2 8 3
1 6 4
0 7 5
A Better Formulation
A Better Formulation
States:
Operators:
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 L
2 8 3
1 6 4
7
5
2 8 3
1 6 4
0 7 5
2 8 3
becomes ( 1 6 4 , (3, 2))
7 0 5
Example: Op L
any steps
1 2 3
4 5 6
8 7
2 8 3
2 8 3
Op L
( 1 6 4 , (3, 2)) = ( 1 6 4 (3, 1))
7 0 5
0 7 5
Preconditions:
Effects:
c0 > 1
A[r0 , c0 1]
A[r0 , c0 ]
A[r0 , c0 1] 0
(r , c )
(r0 , c0 1)
0 0
3gl
4gl
a1
a2
a3
a4
a5
a6
a7
a8
a9
2 3
1 2 3
5 6
4 5 6
8 7
E4:
J4 < 4
E4-3:
J4 > 0
J3 < 3,
effect:
effect:
J4 = J4 (3 J3 )
J4 < 4,
effect:
J3 4 J4
E3-4:
J3 = 3,
J4
= 4,
J3
= J3 (4 J4 )
J3 = 0,
J3 + J4 < 4,
J3 > 0
effect:
0 J4 4
J4 = 0
0 J3 3,
Initial State Description
...
J4 = 0
J4 3 J3
P3-4:
=4
Claim:
J4 = J3 + J4 ,
J4 = 2
J3 = 0
Artificial Intelligence p.32/89
Problem
J_3 = 0
J_4 = 0
Search Graph
F4
J_4 = 2
F3
Layout Problems
(VLSI layout, furniture layout, packaging, . . . )
J_3 = 0
J_4 = 4
J_3 = 0
J_4 = 0
F3
J_3 = 3
J_4 = 0
P4-3
J_3 = 3
J_4 = 4
J_3 = 3
J_4 = 1
...
...
F4
J_3 = 0
J_4 = 4
...
P3-4
Assembly Sequencing
(assembly of electric motors, . . . )
E4
E3-4
Task Scheduling
(manufacturing, timetables, . . . )
J_3 = 2
J_4 = 4
C
B
...
Problem Solution
J_3 = 3
J_4 = 3
J_3 = 0
J_4 = 2
More on Graphs
F3
J_3 = 2
J_4 = 0
E3-4
J_3 = 0
J_4 = 3
Directed Graphs
C
For 1 i < j k + 1,
Ni is a ancestor of Nj ; Nj is a descendant of Ni .
a solution, or failure
initialize the search tree using the initial state of problem
loop do
C
A
depth 1
if
depth 0
G
D
...
depth 2
depth 3
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.
Arad
Sibiu
Arad
Fagaras
Timisoara
Oradea
Rimnicu Vilcea
Arad
Sibiu
Zerind
Lugoj
Arad
Oradea
Arad
Fagaras
Timisoara
Oradea
Rimnicu Vilcea
Arad
Zerind
Lugoj
Arad
Arad
Sibiu
parent, action
State
Node
88
22
Arad
depth = 6
Oradea
Fagaras
Timisoara
Oradea
Rimnicu Vilcea
Arad
Zerind
Lugoj
Arad
Oradea
g=6
state
Search Strategies
A strategy is defined by picking the order of node
expansion. Strategies are evaluated along the following
dimensions:
completenessdoes it always find a solution if one
exists?
time complexitynumber of nodes
generated/expanded
space complexitymaximum number of nodes in
memory
optimalitydoes it always find a least-cost solution?
Time and space complexity are measured in terms of
bmaximum branching factor of the search tree
ddepth of the least-cost solution
mmaximum depth of the state space (may be )
Breadth-First Search
Breadth-First Search
B
D
C
E
B
G
D
Artificial Intelligence p.48/89
C
E
G
Artificial Intelligence p.47/89
Breadth-First Search
Breadth-First Search
B
D
C
E
B
G
D
Artificial Intelligence p.50/89
C
E
G
Artificial Intelligence p.49/89
Depth-First Search
Uniform-Cost Search
O(bC / )
Optimal?? Yesnodes expanded in increasing order of g(n)
D
H
E
J
F
K
G
N
Depth-First Search
Depth-First Search
B
D
H
E
I
F
K
G
M
E
I
F
K
G
M
Depth-First Search
Depth-First Search
B
D
H
E
I
F
K
G
M
C
E
F
K
G
M
Depth-First Search
Depth-First Search
C
H
D
H
E
I
F
K
C
E
F
K
G
M
G
M
Depth-First Search
Depth-First Search
B
D
H
E
I
F
K
G
M
E
I
F
K
G
N
Depth-First Search
Depth-First Search
D
H
E
I
F
K
G
M
D
H
E
I
F
K
G
M
Depth-First Search
Complete??
Expand deepest unexpanded node
Implementation: fringe = LIFO queue, i.e., put successors at
front
A
D
H
E
I
F
K
G
M
Depth-Limited Search
= depth-first search with depth limit l, i.e., nodes at depth l
have no successors
Limit = 1
D
H
E
I
F
K
G
M
D
O
E
I
F
K
G
M
D
O
E
I
F
K
Limit = 2
G
M
D
O
E
I
F
K
G
M
C
E
C
E
E
I
F
K
G
M
D
O
E
I
F
K
C
E
E
I
F
K
G
M
D
O
E
I
D
O
E
I
D
O
E
I
C
E
A
C
C
E
G
M
F
K
F
K
F
K
B
D
C
D
A
B
O
A
G
M
D
O
E
I
F
K
G
M
Summary of Algorithms
Criterion
Complete?
Breadth-
Uniform-
Depth-
Depth-
Iterative
First
Cost
First
Limited
Deepening
Yes
Yes
No
Yes, if l d
Yes
bd
bm
bl
bd
No
No
Yes
d+1
Time
Space
bd+1
Optimal?
Yes
C /
bC
Yes
Complete?? Yes
Time?? (d + 1)b0 + db1 + (d 1)b2 + . . . + bd = O(bd )
Space?? O(bd)
Optimal?? Yes, if step cost = 1 Can be modified to explore
uniform-cost tree
Numerical comparison for b = 10 and d = 5, solution at far right:
N (IDS)
N (BFS)
10 + 100 + 1, 000 + 10, 000 + 100, 000 + 999, 990 = 1, 111, 100
Summary
Repeated states
B
C
B
C
B
C
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
Breadth-first
Depth-first
Uniform-cost
Depth-limited
75
Neamt
Zerind
Iasi
Arad
140
Sibiu
92
99
Fagaras
118
Vaslui
80
Rimnicu Vilcea
Timisoara
111
Iterative-deepening
87
151
Lugoj
Pitesti
97
142
211
70
98
Mehadia
75
Dobreta
146
85
101
Bucharest
120
Craiova
Hirsova
Urziceni
86
138
90
Giurgiu
Eforie