Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Articial Intelligence

Problem Solving and Search


Readings: Chapter 3 of Russell & Norvig.
Articial Intelligence p.1/89
Example: Romania
Problem: On holiday in Romania; currently in Arad.
Flight leaves tomorrow from Bucharest. Find a short
route to drive to Bucharest.
Formulate problem:
states: various cities
actions: drive between cities
solution: sequence of cities, e.g., Arad, Sibiu,
Fagaras, Bucharest
Articial Intelligence p.2/89
Example: Romania
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75
120
151
140
99
80
97
101
211
138
146
85
90
98
142
92
87
86
Articial Intelligence p.3/89
Problem types
Deterministic, fully observable = single-state problem
Agent knows exactly which state it will be in; solution
is a sequence
Non-observable = conformant problem
Agent may have no idea where it is; solution (if any)
is a sequence
Nondeterministic and/or partially observable =
contingency problem
percepts provide new information about current state
solution is a tree or policy
often interleave search, execution
Unknown state space = exploration problem (online)
Articial Intelligence p.4/89
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.
The world is static and deterministic.
Articial Intelligence p.5/89
Example: Vacuum World
Single-state,
start in #5.
Solution??
.
1 2
3 4
5 6
7 8
Articial Intelligence p.6/89
Example: Vacuum World
Single-state, start in #5.
Solution?? [Right, Suck]
Conformant, start in
{1, 2, 3, 4, 5, 6, 7, 8}
e.g., Right goes to
{2, 4, 6, 8}.
Solution??
1 2
3 4
5 6
7 8
Articial Intelligence p.7/89
Example: Vacuum World
Single-state, start in #5.
Solution?? [Right, Suck]
Conformant, start in
{1, 2, 3, 4, 5, 6, 7, 8}
e.g., Right goes to {2, 4, 6, 8}.
Solution??
[Right, Suck, Left, Suck]
Contingency, start in #5
Murphys Law: can
1 2
3 4
5 6
7 8
Articial Intelligence p.8/89
Example: Vacuum World
Single-state, start in #5.
Solution?? [Right, Suck]
Conformant, start in
{1, 2, 3, 4, 5, 6, 7, 8}
e.g., Right goes to {2, 4, 6, 8}.
Solution??
[Right, Suck, Left, Suck]
Contingency, start in #5
Murphys Law: can
1 2
3 4
5 6
7 8
Articial Intelligence p.9/89
Single-state problem formulation
A problem is dened by four items:
initial state e.g., at Arad
successor function S(x) = set of actionstate pairs
e.g., S(Arad) = {Arad Zerind, Zerind, . . .}
goal test, can be explicit, e.g., x = at Bucharest
implicit, e.g., NoDirt(x)
path cost (additive) e.g., sum of distances, number of
actions executed, etc. Usually given as c(x, a, y), the
step cost from x to y by action a, assumed to be 0.
A solution is a sequence of actions leading from the
initial state to a goal state
Articial Intelligence p.10/89
Selecting a State Space
Real world is absurdly complex state space must be
abstracted for problem solving
(Abstract) state = set of real states
(Abstract) action = complex combination of real actions
e.g., Arad Zerind represents a complex set of
possible routes, detours, rest stops, etc.
For guaranteed realizability, any real state in Arad
must get to some real state in Zerind.
Each abstract action should be easier than the
original problem!
(Abstract) solution = set of real paths that are solutions
in the real world
Articial Intelligence p.11/89
State space graph of vacuum world
R
L
S S
S S
R
L
R
L
R
L
S
S S
S
L
L
L L R
R
R
R
states??
actions??
goal test??
path cost??
Articial Intelligence p.12/89
State space graph of vacuum world
R
L
S S
S S
R
L
R
L
R
L
S
S S
S
L
L
L L R
R
R
R
states??: integer dirt and robot locations (ignore dirt
amounts)
actions??: Left, Right, Suck, NoOp
goal test??: no dirt
path cost??: 1 per action (0 for NoOp)
Articial Intelligence p.13/89
Formulating Problem as a Graph
In the graph
each node represents a possible state;
a node is designated as the initial state;
one or more nodes represent goal states, states in which
the agents goal is considered accomplished.
each edge represents a state transition caused by a
specic agent action;
associated to each edge is the cost of performing that
transition.
Articial Intelligence p.14/89
Search Graph
How do we reach a goal state?
4
3
3
5
7
4
2
5
4
2
B
F
A
S
G
C
D
initial state
goal states
E
There may be several possible ways. Or none!
Factors to consider:
cost of nding a path;
cost of traversing a path.
Articial Intelligence p.15/89
Problem Solving as Search
Search space: set of states reachable from an initial state S
0
via a (possibly empty/nite/innite) sequence of state
transitions.
To achieve the problems goal
search the space for a (possibly optimal) sequence of
transitions starting from S
0
and leading to a goal state;
execute (in order) the actions associated to each
transition in the identied sequence.
Depending on the features of the agents world the two steps
above can be interleaved.
Articial Intelligence p.16/89
Problem Solving as Search
Reduce the original problem to a search problem.
A solution for the search problem is a path initial
stategoal state.
The solution for the original problem is either
the sequence of actions associated with the path or
the description of the goal state.
Articial Intelligence p.17/89
Example: The 8-puzzle
2
1
7
6
8 3
4
5
It can be generalized to 15-puzzle, 24-puzzle, or
(n
2
1)-puzzle for n 6.
Articial Intelligence p.18/89
Example: The 8-puzzle
Go from state S to state G.
(G)
(S)
2 8 3
1 6 4
7 5
1 2 3
6
4
5 7
8
R
L
L
R
D U
D U
L
L
R
R
D D U
U
1 6 4
7 5
2 8 3
8 3
1 6 4
5 7
8 3
1 4
7 5 6
8 3
1 6 4
7 5
8 3
1 6
7 5 4
8 3
1
7 5 6
4
3
1 4
7 5 6
8
8 3
4
7 5 6
1
8 3
6 4
5 7 1
2
2 2
2 2
2 2 2
Articial Intelligence p.19/89

You might also like