1.2 Problem Solving - State Space Search (AIML)
1.2 Problem Solving - State Space Search (AIML)
What is an AI Technique?
• Artificial intelligence problems span a very broad spectrum. They
appear to have very little in common except that they are hard.
• Are there any techniques that are appropriate for the solution of a
variety of these problems?
• One of the few hard and fast results to come out of the first three
decades of AI research is the realization that
Intelligence requires knowledge
What is an AI Technique?
- An agent that tries to come up with a sequence of actions that will bring the
environment into a desired state.
-Special type of goal-based agent
Environment –
static – agent assumes that in the time it takes to formulate and solve the problem the
environment doesn’t change
observable – initial state and current state is known
discrete – more than one solution possible
deterministic – the solution, when executed will work!!
Deterministic, fully observable => single state problem
– Agent knows exactly which state it will be in;
A path sequence is an ordered listing of states and actions used in achieving a goal.
solution is a sequence
SIMPLE PROBLEM-SOLVING AGENT
A simple problem-solving agent. It first formulates a goal and a problem, searches for a sequence of
actions that would solve the problem, and then executes the actions one at a time. When this is
complete, it formulates another goal and starts over
Problem solving as state space search
Search algorithms
Apply
Real- Search
State space Goal
world ?
problem
unfold (using O)
Mathematically
workable specification
Formalizing search in a state space
• Each arc has a fixed, positive cost associated with it, corresponding to
the cost of the operator
• Each node has a set of successor nodes corresponding to all of the
legal operators that can be applied to the applied at the source node’s
state
• The process of expanding a node means to generate all of the successor
nodes and add them and their associated arcs to the state-space graph
• One or more nodes are designated as the start nodes
• A goal test predicate is applied to a state to determine if its associated
node is a goal node
Formalizing search in a state space
• Three missionaries and three cannibals are on one side of a river, along with a boat
that can hold one or two people. Find a way to get everyone to the other side, without
ever leaving a group of missionaries outnumbered by cannibals.
PROBLEM FORMULATION
• State: (#m, #c, 1/0)
- #m denotes the number of missionaries in the first bank
- #c denotes the number of cannibals in the first bank
- The last bit indicates whether the boat is in the first bank.
• Starting state: (3, 3, 1)
• Goal state: (0, 0, 0)
• Operators: Boat carries (#m, #c): {(1, 0), (0, 1), (1, 1), (2, 0), (0, 2)}
MC State space
M-C search graph
# SOLUTIONS = 02
COST = # operations = 11
Water Jug Problem
Problem statement: “You are given two jugs, a 4-litre one and a 3-litre one. Neither
has any measuring markers on it. There is a pump that can be used to fill the jugs
with water. How can you get exactly 2 litres of water into 4-litre jug.”
Problem formulation
• State: (x, y) where x = 0, 1, 2, 3, or 4; y = 0, 1, 2, 3
• Start state: (0, 0).
• Goal state: (2, n) for any n such that n<=3
• Attempting to end up in a goal state.
Water Jug Problem
Operators
1. (x, y) → (4, y) Fill the 4-gallon jug
if x > 4
2. (x, y) → (x, 3) Fill the 3-gallon jug
if y < 3
3. (x, y) → (x - d, y) Pour some water out of the 4-gallon jug
if x > 0
4. (x, y) → (x, y - d) Pour some water out of the 3-gallon jug
if y > 0
5. (x, y) → (0, y) Empty the 4-gallon jug on the ground
if x > 0
6. (x, y) → (x, 0) Empty the 3-gallon jug on the ground
if y > 0
Water Jug Problem
7. (x, y) → (4, y - (4 - x)) Pour water from the 3-gallon jug into the
if x + y ≥ 4, y > 0 4- gallon jug until the 4-gallon jug is full.
8. (x, y) → ( x - (3 - y), 3) Pour water from the 4-gallon jug into the 3-
if x + y ≥ 3, x > 0 gallon jug until the 3-gallon jug is full.
9. (x, y) → (x + y, 0) Pour all the water from the 3-
if x + y ≤ 4, y > 0 gallon jug into the 4-gallon jug
10. (x, y) → (0, x + y) Pour all the water from the 4-
if x + y ≤ 3, x > 0 gallon jug into the 3-gallon jug
11. ( 0, 2) → (2, 0) Pour 2-gallons from the 3-gallon
jug into the 4-gallon jug
12. (2, y) → (0, y) Empty the 2-gallons in the 4-
gallon jug on the ground
Search Tree for Water Jug (4l-3l) Problem
Water Jug Problem
One solution to the water jug problem