0% found this document useful (0 votes)
30 views

Water Jug Problem

The document discusses the water jug problem, an AI puzzle involving measuring a target amount of water using jugs of different capacities without volume markings. It provides the production rules, describes the state representation and outlines a breadth-first search algorithm to solve the problem.

Uploaded by

anshul.saini0803
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
0% found this document useful (0 votes)
30 views

Water Jug Problem

The document discusses the water jug problem, an AI puzzle involving measuring a target amount of water using jugs of different capacities without volume markings. It provides the production rules, describes the state representation and outlines a breadth-first search algorithm to solve the problem.

Uploaded by

anshul.saini0803
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/ 10

Water Jug Problem

• The Water Jug Problem is a classic puzzle in


artificial intelligence involving two jugs, one
with a capacity of ‘x’ liters and the other ‘y’
liters, and a water source. The goal is to
measure a specific ‘z’ liters of water using
these jugs, with no volume markings.

Production Rules for Water Jug
Problem
• Fill Jug A: Fill jug A to its full capacity.
• Fill Jug B: Fill jug B to its full capacity.
• Empty Jug A: Empty the jug A.
• Empty Jug B: Empty the Jug B.
• Pour from A to B: Pour water from jug A to jug B
unless you get an empty jug A or full jug B.
• Pour from B to A: Pour water from jug B to jug A
until either jug B is empty or jug A is full.
Using these production rules, we can construct a
solution path to move from the initial state to the
goal state.
You are given an ‘m’ liter jug and a ‘n’ liter jug. Both the jugs
are initially empty. The jugs don’t have markings to allow
measuring smaller quantities. You have to use the jugs to
measure d liters of water where ‘d’ is less than ‘n’.

• (X, Y) corresponds to a state where X refers to the amount of


water in Jug1 and Y refers to the amount of water in Jug2.
1. Empty a jug (X, 0)->(0, 0) Empty Jug 1.

2. Fill a Jug, (0, 0)->(X, 0) Fill Jug 1

3. Pour water from one jug to the other until one of


the jugs is either empty or full, (X, Y) -> (X-d, Y+d)
As provided in the problem statement, at any given
state we can do either of the following operations:

1. Fill a jug

2. Empty a jug

3. Transfer water from one jug to another until

either of them gets completely filled or empty.


1. (x,y) is X<4 -> (4, Y) Fill the 4-litre jug

2. (x, y) if Y<3 -> (x, 3) Fill the 3-litre jug

3. (x, y) if x>0 -> (x-d, d) Pour some water from a 4-litre jug

4. (x, y) if Y>0 -> (d, y-d) Pour some water from a 3-litre jug

5. (x, y) if x>0 -> (0, y) Empty 4-litre jug on the ground

6. (x, y) if y>0 -> (x,0) Empty 3-litre jug on the ground

Pour water from a 3-litre jug into a 4-litre jug


7. (x, y) if X+Y >= 4 and y>0 -> (4, y-(4-x
until it is full

Pour water from a 3-litre jug into a 4-litre jug


8. (x, y) if X+Y>=3 and x>0 -> (x-(3-y), 3))
until it is full

Pour all the water from a 3-litre jug into a 4-


9. (x, y) if X+Y <=4 and y>0 -> (x+y, 0
litre jug

Pour all the water from a 4-litre jug into a 3-


10. (x, y) if X+Y<=3 and x>0 -> (0, x+
litre jug

Pour 2-litre water from 3-litre jug into 4-litre


11. (0, 2) -> (2, 0)
jug

12. (2, Y) -> (0, y) Empty 2-litre in the 4-litre jug on the ground.
Algorithm to Solve Water Jug Problem
using BFS
• Start with the initial state where both jugs are empty.
• Create a queue. Next, add the initial state to it.
• While the queue is not empty, opt for the following:
– Pop the front state from the queue.
– Apply all possible production rules to generate new states.
– Check if any of these new states match the goal state.
– If a goal state is found, the problem is solved.
– If not, add the new states to the queue for further
exploration.
• BFS ensures that you find the shortest path to the goal
state, which is efficient for solving the Water Jug
Problem.
Mirror to Practical Scenarios
• Resource Management: In practical situations, it often relates to
resource management. The water in the jugs can represent resources,
such as time, money, or materials. The goal is to manage these
resources to meet specific needs or objectives efficiently. For example,
in project management, you may need to allocate time and budget
effectively to achieve project goals.

• Capacity Constraints: The jug capacities mirror capacity constraints


commonly encountered in real life. In manufacturing, for instance,
factories have a limited capacity to produce goods. Just like in the water
jug problem, you need to optimize the use of these resources to meet
production targets.

• Optimization: The problem requires optimizing actions to achieve a


goal. In supply chain management, companies optimize logistics and
distribution to minimize costs and maximize efficiency. Similarly, the
water jug problem involves finding the optimal sequence of actions to
measure a specific amount of water.
• Decision-Making: Practical scenarios often involve
decision-making processes. Decision-makers must
choose between various options to achieve
objectives. The water jug problem reflects this by
requiring decisions on which jug to fill, pour, or
empty at each step to reach the target amount.

• Trial and Error: Just like solving the water jug


problem may involve trial and error, practical
situations often require experimentation and
adaptation. In marketing, for instance, strategies are
tested, refined, and adapted based on customer
responses. Similarly, solving the water jug problem
may involve trying different actions until a solution is
found.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy