Midterm1 sample solution (CSCI561)
Spring 2008
1.
The
Water Jug Problem
is a puzzle with N water jugs of various sizes, but with no
measuring marks on them.
You have the ability to fill any individual water jug from a tap, to
pour the water from any jar into another, and to empty any jug on the ground.
The goal is
generally to get a specific amount of water into one of the jugs.
For example, consider the
problem where you have two empty jugs that hold 3 gallons and 4 gallons, respectively, and
the goal is to have exactly two gallons of water in the 4 gallon jug.
1a.
Define the state space in terms of what features will be in the states and what the
operators will be.
We can represent the state of the specific 2 water jugs problem with a pair of non
negative integers: <x
1
,x
2
>, where x
1
and x
2,
respectively, show the amount of water
in the 3 and 4 gallon jugs (0
≤
x
1
≤
3 and 0
≤
x
2
≤
4).
Given a state <x
1
,x
2
>,
•
If x
1
> 0 then there exists an
empty
action e
1
that takes <x
1
,x2> to <0,x
2
>
•
If x
2
> 0 then there exists an
empty
action e
2
that takes <x
1
,x2> to <x
1
,0>
•
If x
1
< 3 then there exists a
fill
action f
1
which takes <x
1
,x
2
> to <3,x
2
>
•
If x
2
< 4 then there exists a
fill
action f
2
which takes <x
1
,x
2
> to <x
1
,4>
•
If 0 < x
1
and x
2
< 4 then the
pour
action p
12
is available, which takes <x
1
,x2>
to <x
1
4+x
2
,4> if x
1
> 4x
2
, or to <0,x
1
+x
2
> if x
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '09
 Moradi
 Hillary Rodham Clinton, Quantification, Firstorder logic, water jug problem

Click to edit the document details