Problem Solving in AI
Problem Solving in AI
TYPICAL AI PROBLEMS
Problem-solving agents
In Artificial Intelligence, Search techniques are universal
problem-solving methods. Rational agents or Problem-
solving agents in AI mostly used these search strategies or
algorithms to solve a specific problem and provide the best
result. Problem- solving agents are the goal-based agents and
use atomic representation. In this topic, wewill learn various
problem-solving search algorithms.
• Some of the most popularly used problem solving with
the help of artificial intelligence are:
1. Chess.
2. Travelling Salesman Problem.
3. Tower of Hanoi Problem.
4. Water-Jug Problem.
5. N-Queen Problem. 1
PROBLEM SOLVING APPROACH TO
TYPICAL AI PROBLEMS
Problem Searching
2
PROBLEM SOLVING APPROACH TO
TYPICAL AI PROBLEMS
Steps : Solve Problem Using Artificial Intelligence
• The process of solving a problem consists of five steps.
These are:
5
PROBLEM SOLVING APPROACH TO
TYPICAL AI PROBLEMS
Search Algorithm Terminologies
• Search: Searching is a step by step procedure to solve a
search-problem in a given search space. A search problem
can have three main factors:
1. Search Space: Search space represents a set of
possible solutions, which a system may have.
2. Start State: It is a state from where agent begins the
search.
3. Goal test: It is a function which observe the current state
and returns whether the goal state is achieved or not.
• Search tree: A tree representation of search problem is called
Search tree. The root of the search tree is the root node which
is corresponding to the initial state.
• Actions: It gives the description of all the available actions to
the agent. 6
Example Problems
• A Toy Problem is intended to illustrate or exercise various
problem-solving methods.
• A real- world problem is one whose solutions people actually
care about.
Toy Problems
• Vacuum World
• States: The state is determined by both the agent location
and the dirt locations. The agent is in one of the 2 locations,
each of which might or might not contain dirt. Thus there are
2*2^2=8 possible world states.
• Initial state: Any state can be designated as the initial state.
• Actions: In this simple environment, each state has just three
actions: Left, Right, and
• Suck. Larger environments might also include Up and Down. 7
Example Problems
• Transition model: The actions have their expected effects,
except that moving Left in the leftmost squ are, moving Right
in the rightmost square, and Sucking in a clean square have
no effect. The complete state space is shown in Figure.
• Goal test: This checks whether all the squares are clean.
• Path cost: Each step costs 1, so the path cost is the number
of steps in the path.
8- Puzzle Problem
10
Queens Problem
Queens Problem
• States: Any arrangement of 0 to 8 queens on the board is a
state.
• Initial state: No queens on the board.
• Actions: Add a queen to any empty square.
• Transition model: Returns the board with a queen added to
the specified square.
• Goal test: 8 queens are on the board, none attacked. 11
Problem
• Consider the given problem. Describe the operator
involved in it. Consider the water jug problem: You are
given two jugs, a 4-gallon one and 3-gallon one. Neither
has any measuring marker on it. There is a pump that can
be used to fill the jugs with water. How can you get
exactly 2 gallon of water from the 4-gallon jug ?
• Explicit Assumptions: A jug can be filled from the pump,
water can be poured out of a jug on to the ground, water
can be poured from one jug to another and that there are
no other measuring devices available.
• Here the initial state is (0, 0). The goal state is (2, n) for
any value of n.
12
• State Space Representation: we will represent a state of the
problem as a tuple (x, y) where x represents the amount of
water in the 4-gallon jug and y represents the amount of water
in the 3-gallon jug. Note that 0 ≤ x ≤ 4, and 0 ≤ y ≤ 3.
• To solve this we have to make some assumptions not
mentioned in the problem. They are:
• We can fill a jug from the pump.
• We can pour water out of a jug to the ground.
• We can pour water from one jug to another.
• There is no measuring device available.
15
S.No Gallons in
S 4- Gallons in 3- Rule Applied
. gel jug(x) gel jug (y)
o
1. 0 0 Initial state
l
2.. 4 0 1. Fill 4
3 1 u 3 6. Poor 4 into 3 to fill
4. 1 t 0 4. Empty 3
5. 0 i 1 8. Poor all of 4 into
3
6. 4 o 1 1. Fill 4
7. 2 3 6. Poor 4 into 3
n
16
S
• 4-gallon one and a 3-gallon Jug
o
l
•No measuringumark on the jug.
•There is a pump to fill the jugs with water.
•How can you get
t exactly 2 gallon of water into the 4-
gallon jug?
i
n
17
END
18