1

I have a problem in Hill Climbing algorithm with Water Jug Problem :

Given two jugs, one of which can accommodate X liters of water and the other which can accommodate Y liters of water, determine the number of steps required to obtain exactly D liters of water in one of the jugs.

From the start state, (X,Y) = (0,0), it can generate some states :

  • (X,Y) = (0,Y)
    or
  • (X,Y) = (X,0)

And from these states, it can generate others until the end state that is either (X,D) or (D,Y).

So, Can I estimate the heuristic function for this problem? How to know which state is better than others?

Thank you everyone.

Mohsen Kamrani
  • 7,177
  • 5
  • 42
  • 66
Khuê Phạm
  • 59
  • 1
  • 7

1 Answers1

2

Represent each state in the state space as (x,y) itself.

Heuristic function: h(s) for each s = (x,y) = |x-D| + |y - D| (Assuming you want to minimize h(.) )

Please consider that this is just a greedy decision that assumes if one of the jugs contains an amount of water too close too D it's a good state! Obviously this is true for the goal state but it won't assure reaching an optimal solution, as it's not expected from the HC at all!

Why this h(.)? Cause it's admissible and you can use it (probably when your teacher asks) for A* and it will give you the optimal answer.


Considering the following problems of "Hill Climbing" algorithm, don't expect too much:

  • Foothill problem
    Local peaks attract procedure’s attention away from trying to reach the “top”
  • Plateau problem
    Area flat so there is very little to attract procedure to one path over another
  • Ridge problem
    Every step is down though not at a local minimum
Mohsen Kamrani
  • 7,177
  • 5
  • 42
  • 66
  • 1
    Am I missing something, or is this not actually an admissible heuristic? It definitely is only admissible if the cost of a move is based on the the amount of water poured, but I think that trying to incorporate the distance of both buckets to D creates additional problems. Consider a simple situation with a 3 gallon bucket and a five gallon bucket where the goal is 3 gallons. You can find the correct answer in one step by filling the three gallon bucket. h(0,0) would be 8, but the actual cost of getting to the goal would only be 3 (assuming cost = gallons poured, as mentioned above). – seaotternerd Oct 01 '14 at 19:25