Problem Solving
Problem Solving
Introduction
A problem is a situation which is experienced by an agent and is solved by a sequence of actions that
reduce the difference between the initial situation and the goal.
Components of a problem
- Initial state
The state from which the agent starts to solve a problem
- Actions
Description of possible actions in particular state
- Transition Model
Description of each action with respect to state
- Goal Test
Determination of the particular state is goal or not
- Path Cost
Calculates the cost to each path
Operators
– UP: If the empty slot is not touching the up-frame, move it up.
– DOWN: If the empty slot is not touching down-frame, move it down.
– LEFT: If the empty slot is not touching left-frame, move it left.
– RIGHT: If the empty slot is not touching right-frame, move it right.
Final State
Toy problems
Toy problems illustrate various problem solving methods with exact description and can be used to
compare performance.
Examples: 8 – Puzzle game, 8 – Queens Problems, Tic - Tac Toe
Q. 8 Puzzle Game
The puzzle consists of an 8-square frames and an empty slot. The tiles are numbered from 1-8.
It is possible to move the tiles in the square field by moving tile into the empty slot. Manage the
tile square in a numeric order.
Here,
Initial State
Operators
– UP: If the empty slot is not touching the up-frame, move it up.
– DOWN: If the empty slot is not touching down-frame, move it down.
– LEFT: If the empty slot is not touching left-frame, move it left.
– RIGHT: If the empty slot is not touching right-frame, move it right.
Final State
Solution
- Step 1
- Step 2
- Step 3
- Step 4
Here,
Initial State
Operation
Add a queen in any square
Final State
Real World Problems
The Real world problem is related to people actually care about. Such problems are likely not to have a
multiple formulations. Route finding, a real world problem is defined in terms of locations and transitions
along links between them. Examples: VLSI layout, Robot Navigation
Operators
Fill 3-gallon from faucet, fill 4-gallon from faucet
Fill 3-gallon from 4-gallon , fill 4-gallon from 3-gallon
Empty 3-gallon into 4-gallon, empty 4-gallon into 3-gallon
Dump 3-gallon down drain, dump 4-gallon down drain
Final State
Goal state (0, 2)
Solution
Q. You are given two jars of a six gallons and eight gallons capacity. There is no marking on the
jars. There is a water tap, which can be used to fill jar. Your goal is to have exactly four gallons of
water in eight gallons jar without taking any other jar or measuring device. Model the above
problem as an AI production system and draw the search tree.
Problem 3
S E N D
+ M O R E
M O N E Y
Solution:
Step 1:
Domain of M = {1}
Select M = 1
So we have,
S E N D
+ 1 O R E
1 O N E Y
Step 2:
Domain of S = {9}
Select S = 9 Then O = 0 (Carry = 1)
So,
9 E N D
+ 1 0 R E
1 0 N E Y
Step 3:
Domain of D = {2, 3, 4, 5, 6, 7, 8}
Domain of E = {2, 3, 4, 5, 6, 7, 8}
So, Domain of Y = {2, 3, 4, 5}
Select D = 7 & E = 5 Then Y = 2 (Carry =1)
So,
9 5 N 7
+ 1 0 R 5
1 0 N 5 2
Step 4:
Domain of N = {3, 4, 6, 8}
Domain of R = {3, 4, 6, 8}
So, Domain of E will be 5 (with carry = 1) when we select N = 6 & R = 8.
Now we have,
9 5 6 7
+ 1 0 8 5
1 0 6 5 2
Hence, the required solutions are:
S = 9, E = 5, N = 6, D = 7, M = 1, O = 0, R = 8, Y = 2.
Production System
Knowledge representation formalism consists of collections of condition-action rules. A system that uses
this rule of knowledge representation is called a production system.
A production system consists of rules and factors. Knowledge is encoded in a declarative from which
comprises of a set of rules of the form
Situation ------------ Action
SITUATION that implies ACTION.
Example:-
IF the initial state is a goal state THEN quit.
The major components of an AI production system are
i. A global database
ii. A set of production rules and
iii. A control system
– The goal database is the central data structure used by an AI production system
– The production rules operate on the global database. Each rule has a precondition that is either
satisfied or not by the database. If the precondition is satisfied, the rule can be applied.
Application of the rule changes the database.
– The control system chooses which applicable rule should be applied and ceases computation
when a termination condition on the database is satisfied.
Advantages:
Production systems provide an excellent tool for structuring AI programs.
Production Systems are highly modular because the individual rules can be added, removed or
modified independently.
The production rules are expressed in a natural form, so the statements contained in the
knowledge base should the recording of an expert thinking out loud.
Disadvantages:
One important disadvantage is the fact that it may be very difficult to analyze the flow of
control within a production system because the individual rules don’t call each other.
Architecture of Production System