100% found this document useful (1 vote)
843 views31 pages

Problems, Problem Spaces and Search

This document discusses problem solving in artificial intelligence and defines key concepts such as: 1) Defining problems precisely by specifying the initial and goal states, as well as representing problems as state spaces. 2) Analyzing problem characteristics to determine the best solving technique. 3) Isolating and representing the task knowledge needed to solve the problem. 4) Choosing and applying problem solving techniques, such as representing water jug, 8-puzzle, and missionaries-cannibals problems as state spaces to solve them.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
843 views31 pages

Problems, Problem Spaces and Search

This document discusses problem solving in artificial intelligence and defines key concepts such as: 1) Defining problems precisely by specifying the initial and goal states, as well as representing problems as state spaces. 2) Analyzing problem characteristics to determine the best solving technique. 3) Isolating and representing the task knowledge needed to solve the problem. 4) Choosing and applying problem solving techniques, such as representing water jug, 8-puzzle, and missionaries-cannibals problems as state spaces to solve them.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

PROBLEMS, PROBLEM

SPACES AND SEARCH


PROBLEM SOLVING IN AI
¢ To build a system/agent to solve a particular problem
in AI, we need to do following four things:
1) D efine the problem precisely. T his definition must
include precise specification of what the initial state
(s) will be as well as what final situations constitute
acceptable solutions to the problem.
PROBLEM SOLVING IN AI
2.Analyze the problem i.e. aspects that have important
impact on the appropriateness of various possible
techniques for solving the problem.

3. Isolate and represent the task knowledge to solve the

problem.

4. Choose the best problem-solving technique(s) and

apply it (them) to get a solution.


PROBLEM FORMULATION IN AI
Problem can be defined using five components:
¢ Initial state

¢ Total Possible Actions: A description of possible


actions available to the agent.

¢ S tate S pace: S et of all states reachable from the


initial state by any sequence of actions

¢ Path Cost: Cost of each path

¢ 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.

¢ A state space consists of


⚫ A (possibly infinite) set of states

¢ The start state represents the initial problem

¢ Each intermediate state represents some


configuration reachable from the start state
¢ Some states may be goal states (solutions)
D EFINING THE P R O B LEM AS STATE SPACE-
CONTD…
⚫A set of rules/operators/actions
⚫ Applying an rule to a state transforms it to another
state in the state space
¢ Not all rules are applicable to all states.

⚫ 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 …..

Firstly we need to define a state space:

Define an ordered pair (x, y) such that

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

N ote: There may be many solutions and we try to


search the best solution
8-P U Z Z L E P R O B L E M
¢ The 8-Puzzle problem includes a 3x3 square tray in which
8 numbered tiles are placed and the ninth one is
unnumbered (blank/ black).
¢ This problem involves moving the tiles on the tray into a
particular configuration.
¢ The blank square on the board represents a space.
¢ The player can move a tile into the space, freeing that
position for another tile to be moved into and so on.
¢ For Example,
Initial State Goal State:

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.

¢ How can everyone get to the other side without


missionaries being eaten?
MISSIONARIES AND CANNIBALS PROBLEM

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

¢ In order to choose an appropriate method, it is necessary to


analyze the problem with respect to the following considerations.

1) Is the problem decomposable ?


¢ A very large and composite problem can be easily solved if it can be broken
into smaller problems and recursion could be used. Suppose we want to
solve.

¢ E x:- ∫ x2 + 3x+sin 2x cos 2x dx


ANALYZE THE PROBLEM- PROBLEM
CHARACTERISTICS
2) Can solution steps be ignored or undone?
¢ AI Problems generally fall under three classes ignorable , recoverable and
irrecoverable. This classification is with reference to the steps to be used
for the solution of a problem.
Ø Ignorable problems- In which, solution steps can be ignored.

Ex:- theorem proving.


Ø Irrecoverable problems- In which solution steps can’t be undone.
Ex- chess problem.
ANALYZE THE PROBLEM- PROBLEM
CHARACTERISTICS
Ø Recoverable problems- The problem where steps can be undone. Ex:- 8
puzzle problem
Final State
Initial State
1 2 3 1 2 3
8 6 4 8 4
7 5 7 6 5

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

to generate a sequence of operators that guarantees to


a lead to a solution. Planning helps to avoid unwanted
solution steps.
¢ For uncertain outcome problems, planning can at best
generate a sequence of operators that has a good
probability of leading to a solution. The uncertain
outcome problems do not guarantee a solution and it is
often very expensive.
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 ……
4) Is good solution absolute or relative ?
¢ There are two categories of problems.

¢ In one (absolute), like the water jug and 8 puzzle problems,


we are satisfied with the solution, unmindful of the solution
path taken.
¢ In the other category (relative) not just any solution is
acceptable. We want the best, like that of traveling sales
man problem, where it is the shortest path.
¢ In any – path problems, by searching methods we obtain a
solution and we do not explore alternatives. For the best-
path problems all possible paths are explored using an
exhaustive search until the best path is obtained.
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 ……
5) Role of Knowledge
¢ Though one could have unlimited computing power, the
size of the knowledge base available for solving problem
does matter in arriving at a good the solution.
¢ For example, the game of playing chess, just the rules for
determining legal moves and some simple control
mechanism is sufficient to arrive at a solution.
¢ But additional knowledge about good strategy and tactics
could help to constrain the search and speed up the
execution of the program. The solution would then be
realistic.
¢ Consider the case of predicting the political trend or News
paper understanding. This would require an enormous
amount of knowledge even to be able to recognize a
solution , leave alone the best.
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 ……
6) Is the solution a state or a path?
The problems such as water jug or 8-puzzle or TSP have
final solution as a path.
It is easy to look for state as solution where as looking for
path requires more effort.
State as a solution:
The bank president ate a dish of pasta salad with the fork.
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 ……
7) Does the task requires interaction with the
human ?
i)Solitary in which the computer will be given a problem
description and will produce an answer.
ii)Conversational, in which there will be intermediate
communication between a person and the computer,
wither to provide additional assistance to the computer
or to provide additional informed information to the user.
TH A N K S

You might also like