Problems, Problem Spaces and Search
Problems, Problem Spaces and Search
problem.
¢ Goal state
D E F IN IN G TH E P R O B L E M A S S TATE S P AC E
¢ State spaces (means all possible states) are used
extensively in solving Artificial Intelligence Problems.
⚫ Path Cost
¢ Cost incurred in reaching from one state to
another.
E X A M P L E 1: W A T E R J U G P R O B L E M
Problem:
o We have given two jugs with different capacities, one
is an X-liter jug and the other is a Y-liter jug.
o Neither has any marking on it.
o There is a pump that can be used to fill the jugs.
o H ow can we get exactly L liters of water in a
particular jug?
For example:
Suppose we have two jugs with 4L and 3L capacity
with no markings. How can we get exactly 2L water
in 4L jug.
S T A T E S P A C E R E P R E S E N T A T I O N O F W ATER J U G
PROBLEM
¢ Each state of the problem as a tuple (x, y) where x
represents the amount of water in the first-jug and y
represents the amount of water in the second-jug. y).
¢ Initial State: Usually (0,0)
¢ Intermediate State: (x , y) is obtained after applying
possible rule on the previous state. Note 0 ≤ x ≤
max(x_capacity), and 0 ≤ y ≤ max(y_capacity)
¢ Final State: L liters water in any one jug i.e. (L,y) or
(x , L).
¢ Rules / Operators: Rules for the problem can be
defined as:
§ water can be filled in any jug from pump,
§ we can pour water out of the jug onto the ground,
§ water can be poured from one jug to another.
S T A T E S P A C E R E P R E S E N T A T I O N O F W ATER J U G
P R O B L E M C ONTD …..
x=0,1,2,3,4 and
y = 0,1,2
S T A T E S P A C E R E P R E S E N T A T I O N O F W ATER J U G
P R O B L E M C ONTD …..
¢ For example, for the 4L and 3L jugs with initial state
(0,0) and goal state (2,y) following rules can be defined:
Rule Description
1. (x, y) → (4, y)
If x < 4, we can fill 4-L jug completely.
2. (x, y) → (x, 3)
If y < 3, we can fill 3-L jug completely.
3. (x, y) → (0, y)
If x > 0 we can empty 4-L jug on ground
4. (x, y) → (x, 0)
If y > 0, Empty 3-L jug on ground
5. (x, y) → (4, y - (4 - x))
0 < x+y ≥ 4 and y > 0 Pour some water from 3-L jug to fill 4-L jug
6. (x, y) → (x - (3-y), 3)
0 < x+y ≥ 3 and x > 0; Pour some water from 4-L jug to fill 3-L jug
S T A T E S P A C E R E P R E S E N T A T I O N O F W ATER J U G
P R O B L E M C ONTD …..
Rule Description
7. (x, y) → (x+y, 0)
0 < x+y < =4 and y ≥ 0 ; Pour all of water from 3-L jug into 4-Ljug
8. (x, y) → (0, x+y)
0 < x+y <= 3 and x ≥ 0 ; Pour all of water from 4-L jug into 3-Ljug
9. (x, y) → (x-d, y)
If x >0, pour some water out of 4-L jug completely.
10. (x, y) → (x, y-d)
If y >0, pour some water out of 4-L jug completely.
E XAMP L E
Jug X Jug Y Rule No.
0 0
0 3 2
3 0 7
3 3 2
4 2 5
0 2 3
2 0 7
1 2 3 1 2 3
4 6
4 5 6
7 5 8
7 8
S T A T E S P A C E R E P R E S E N T A T I O N O F 8- P U Z Z L E
PROBLEM
¢ Each state of 8-puzzle problem is represented as a 3X3
matrix with one of the tile blank and remaining 8 tiles
numbered.
¢ Initial State: A ny random arrangement of 8
numbered tiles and one blank tiles given in the
problem.
¢ Intermediate States: Any random arrangement of 8
numbered tiles and one blank tiles obtained from after
applying valid operators or rules on the current state.
¢ Final State: Any random arrangement of 8 numbered
tiles and one blank tiles given in the problem.
S T A T E S P A C E R E P R E S E N T A T I O N O F 8- P U Z Z L E
PROBLEM
¢ Operators /R u les:
The empty space can only move in four directions (Movement of
empty space)
i. Up
ii. Down
iii. Right or
iv. Left
The empty space cannot move diagonally and can take only one step
at a time.
S T A T E S P A C E R E P R E S E N T A T I O N O F 8- P U Z Z L E
PROBLEM
STATE SP A C E REPRESENTATION OF 8-
PUZZLE PROBLEM
1 4 3
7 6
5 8 2
Up
Left Right
Down
1 3 1 4 3 1 4 3 1 4 3
7 4 6 7 6 7 8 6 7 6
5 8 2 5 8 2 5 2 5 8 2
Left Up Down Up
Right Left Right Down
1 3 1 3 4 3 1 4 3 1 4 3 1 4 3 1 4 1 4 3
7 4 6 7 4 6 1 7 6 5 7 6 7 8 6 7 8 6 7 6 3 7 6 2
5 8 2 5 8 2 5 8 2 8 2 5 2 5 2 5 8 2 5 8
S T A T E S P A C E R E P R E S E N T A T I O N O F 8- P U Z Z L E
PROBLEM
MISSIONARIES AND CANNIBALS PROBLEM
Problem:
¢ Three missionaries and three cannibals find
themselves on one side of the river.
¢ They have agreed that they would all like to get to
the other side of the river.
¢ But the missionaries are not sure whether they can
trust cannibals or not. So, the missionaries want to
manage the trip across the river so that the number
of missionaries on the either side is never less than
the number of cannibals who are on the same side.
¢ The boat can take only two people at a time.
M
C
M M
C M C
C
M C C
M
Goal state
Initial state
STATE S PACE REPRESENTATION OF
M I S S I O N A R I E S AN D C A N N I B A L S P R O B L E M
¢ Each state is represented as 3 tuple < rs, m, c > where rs
represents either state which can be either 1 (starting
side of river) or 2 (destination side of river). m is the
number of missionaries on river side and c is the number
of cannibals on the river side.
¢ Initial State: ((1,3,3), (2,0,0))
¢ Intermediate States: ((1,m,c), (2,m’,c’)) where 0 £ m, m’,
c, c’ £ 3 obtained after applying valid rules.
¢ Goal States: ((1, 0, 0), (2, 3, 3))
¢ Rules / Operators: The number of missionaries on the
either side is never less than the number of cannibals who
are on the same side.
The boat can take only two people at a time and cannot
cross with zero people as at least one person is required to
row the boat.
STATE S PAC E REPRESENTATION OF MISSIONARIES
A N D C A N N I B A L S P R O B L E M C ONTD ….
PROBLEM CHARACTERISTICS
1 2 3 1 2 3
8 6 4 8 6 4
7 5 7 5
P R O B L E M C H A R A C T E R I S T I C S C O N T D ……
3) Is the Universe Predictable?
¢ Problems can be classified into those with certain
outcome (eight puzzle and water jug problems) and
those with uncertain outcome ( playing cards) .
¢ In certain – outcome problems, planning could be done