Chapter 3-Problem Solving by Searching Part 1
Chapter 3-Problem Solving by Searching Part 1
➢Goal Formulation:
➢It is the first and simplest step in problem-solving.
➢It organizes the steps/sequence required to formulate one goal out of
multiple goals as well as actions to achieve that goal.
➢ Goal formulation is based on the current situation and the agent’s
performance measure
Steps in Problem Solving
➢ Problem Formulation:
➢ It is the most important step of problem-solving which decides what
actions should be taken to achieve the formulated goal.
➢ There are following five components involved in problem formulation:
➢Initial State
➢Actions
➢Transition Model
➢Goal Test
➢Path Cost
Problem Formulation Components
➢ Initial State: It is the starting state or initial step of the agent towards
its goal.
➢Actions: It is the description of the possible actions available to the
agent.
➢Transition Model: It describes what each action does.
➢Goal Test: It determines if the given state is a goal state.
➢Path cost: It assigns a numeric cost to each path that follows the goal.
The problem-solving agent selects a cost function, which reflects its
performance measure.
Note: an optimal solution has the lowest path cost among all the
solutions.
State Space of Problem
➢ Initial state, actions, and transition model together define the state-
space of the problem implicitly.
➢The state-space forms a directed map or graph where nodes are the
states, links between the nodes are actions, and the path is a sequence of
states connected by the sequence of actions.
➢Solution of problem is the path from initial state to goal state in a state
space of problem.
Well Defined Problems
You are given two jugs, a 4-gallon one and a 3-gallon one.
Neither has any measuring mark on it. There is a pump
that can be used to fill the jugs with water. How can you
get exactly 2 gallons of water into the 4-gallon jug
The state space for this problem can be described as the set of ordered
pairs of integers (X, Y)
Where,
X represents the quantity of water in the 4-gallon jug X= 0,1,2,3,4
Y represents the quantity of water in 3-gallon jug Y=0,1,2,3
Start State: (0,0)
Goal State: (2,0)
Production Rule:
- Fill 4/3 gallon jug
- Empty 4/3 gallon jug
- Pour from either of the jug to another
0,0
4,0 0,3
The aim is to choose a value for each variable so that the resulting possible world satisfies
the constraints; we want a model of the constraints.
Constraint Satisfaction Problems
A B C
+ D E F
G H I
Solution:
1. A ≠ B ≠ C ≠ D ≠ E ≠ F ≠ G ≠ H ≠ I
2. C + F = I
C + F = 10 + I (I as carry)
3. B + E = H
B + E = 10 + H
B+E+1=H
B + E + 1 =10 + H (H as carry)
4. A + D = G
A+D+1=G
Step 1:
Domain of C = {1, 2, 3, 4, 5, 6, 7, 8, 9}
Domain of F = {1, 2, 3, 4, 5, 6, 7, 8, 9}
So,
Domain of I = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
A B 4
+ D E 9
G H 3
Step 2:
Domain of B = {1, 2, 5, 6, 7, 8}
Domain of E = {1, 2, 5, 6, 7, 8}
So,
Domain of H = {0, 1, 2, 5, 6, 7, 8}
Select B = 2 & E = 8
Then H = 10+1 {previous carry = 1 + (Carry = 1)}
So,
A 2 4
+ D 8 9
G 1 3
Step 3:
Domain of A = {0, 5, 6, 7}
Domain of D = {0, 5, 6, 7}
So, Domain of G = {5, 6}
Select A = 0 & D = 5 Then G = 6 (with addition of Carry)
So,
Hence, the required solutions are:
A = 0, B = 2, C = 4, D = 5, E = 8, F = 9, G = 6, H = 1, I = 3.
0 2 4
+ 5 8 9
6 1 3
Class Work
Class Work
W R O N G
+ W R O N G
R I G H T
Class Work
B A S E
+ B A L L
G A M E S
Game Playing
A game can be formally defined as a kind of search problem as
below:
➢ Initial state:
➢ The arcs of the graph represent possible moves by the players (+ and -)
Example: Tic-tac-toe
➢ There are two players denoted by X and O. They are alternatively writing
their letter in one of the 9 cells of a 3 by 3 board. The winner is the one who
succeeds in writing three letters in line.
➢ The game begins with an empty board. It ends in a win for one player and a
loss for the other, or possibly in a draw.
➢ A complete tree is a representation of all the possible plays of the game. The
root node is the initial state, in which it is the first player's turn to move (the
player X).
➢ The successors of the initial state are the states the player can reach in one
move, their successors are the states resulting from the other player's possible
replies, and so on.
Q. Explain the production system for Water Jug
Problem.
Statement :- We are given 2 jugs, a 4 liter one and a 3- liter one.
Neither has any measuring markers on it. There is a pump that
can be used to fill the jugs with water. How can we get exactly 2
liters of water in to the 4-liter jugs?
Solution:-
The state space for this problem can be defined as
where,
i represents the number missionaries in one side of a river .
j represents the number of cannibals in the same side of river.
The initial state is (3,3), that is three missionaries and three cannibals
one side of a river (Bank 1) and ( 0,0) on another side of the river
(bank 2) .
The goal state is to get (3,3) at bank 2 and (0,0) at bank 1.
To solve this problem we will make the following assumptions: