Menu

Newbie needs help

Lou S
2005-10-06
2013-05-20
  • Lou S

    Lou S - 2005-10-06

    I am new to JSHOP2 and am trying to come up to speed by solving a problem involving several islands, planes, ferries, and trucks to move a package from one island to another.

    I have been looking at the logistics sample problem provided with the JSHOP2 distribution and have several questions:

    1.) Why does the 'same' axiom (see below) work?
         The tail is nil.  Doesn't that cause 'same' to always evaluate as true.
    (:- (same ?x ?x) nil)

    2.) Where does '?city-goal' come from in method 'obj-at'?  What initializes it?  The only parameters to obj-at are ?obj and ?loc-goal.

    I have read the JSHOP documentation several times but didn't find the answers to my questions.

    Thanks

     
    • Okhtay Ilghami

      Okhtay Ilghami - 2005-10-06

      1) You are right, the NIL always evaluates to true, but notice that the two parameters of the same axiom have the same name (?x). So an expression (same a b) matches this axiom only when "a" and "b" are the same thing. Of course, after this matching happens, there is nothing left to check, hence the "NIL" precondition.

      2) Variables that appear in preconditions but not parameter list of their corresponding method/axiom/operator are existentially quantified (i.e., ANY constant that makes the atom match an existing atom in the current state of the world would do).

       
      • Lou S

        Lou S - 2005-10-07

        Thanks for the reponse.  Unfortunately your answer leads to a few more questions.

        >>So an expression (same a b) matches this axiom only when "a" and "b" are the same thing.

        I did notice that the two parameters are the same. However what is doing the comparision?  Is the comparision implied?

        Based on your response to my 2nd question, I understand that the result of evaluation of the domain state 'in-city' with paramater ?loc-goal is assigned to ?city-goal.  Is this correct?  Is the rightmost term always the one that receives the result of the previous evaluation?

        here is a snipit of the obj-at method.
            (:method (obj-at ?obj ?loc-goal)
                     ((in-city ?loc-goal ?city-goal)
                      (obj-at ?obj ?loc-now)
                      (in-city ?loc-now ?city-goal)
                      (truck ?truck ?city-goal)
                      )
              ((in-city-delivery ?truck ?obj ?loc-now ?loc-goal))

              ((in-city ?loc-goal ?city-goal)
        ....

        Thanks again

         
        • Robert P. Goldman

          Maybe you didn't mean to, but your message suggests an incorrect understanding of the way precondition-checking works.  Try not to think about this as if SHOP is doing "assignment."  It isn't.

          A better analogy would be to think of the preconditions as a set of simultaneous equations i nmathematics.  So, in your example, SHOP2 will try to find values for ?loc-goal ?city-goal ?obj, ?loc-now and ?truck that satisfy the constraints
          ((in-city ?loc-goal ?city-goal)
          (obj-at ?obj ?loc-now)
          (in-city ?loc-now ?city-goal)
          (truck ?truck ?city-goal)
          )
          The process is quite similar to finding values for x, y, and z that satisfy
          x + y = 22
          y + z = 44
          z = 11

          If you haven't already, you should find yourself an introduction to Prolog, which explains how that programming language works, since what SHOP2 does in checking preconditions is very much like what Prolog does.

           
    • Dana Nau

      Dana Nau - 2005-10-06

      I'll need to let someone else answer the 2nd question, but here's an answer to the first one.  The "same" predicate evaluates to true if and only if both of its arguments are the same.  FOr example,  (same 3 3) is true but (same 3 4) is false.

       
    • Okhtay Ilghami

      Okhtay Ilghami - 2005-10-07

      1. The function that finds the satisfier does the comparison. Variables are bound from left to right as the function works its way through the expression for which it is trying to find a satisfier (Just like Prolog works). For example, when it wants to find a satisfier for (same red blue), it maps "?x" to "red" first, then sees "?x" again as the second parameter, but since ?x has already been mapped to "red" and "red != blud" it realizes that the expression is not satisfiable. On the other hand, if it is trying to satisfy (same blue blue), it first maps "?x" to blue, then moves on to the second parameter which is ?x again, but since it is already mapped to "blue", the binding is complete, so it tries to satisfy the precondition of the axiom (which is NIL, and is automatically satisfied).

      2. Hmmmmm, I am not sure I understand you. Again, think of the function that finds satisfiers. It works from left to right, first mapping the ?loc-goal to the constant that is sent via the method parameter list. Then it sees ?city-goal, which is not bound to anything yet. This means it is an existentially-quantified variable. So, the function looks for all the atoms in the state that look like (in-city c1 c2) where c1 is the same constant that ?loc-goal has already been mapped to. All such c2's are possible candidates for the value of ?city-goal, and the function returns them one-by-one and the planner tries them one-by-one till one of them yields a plan.

       
    • Lou S

      Lou S - 2005-10-07

      Many thanks,

      Both answers make much more sense know.  I did have an incorrect understanding of the way precondition checking works.  I plan to read a Prolog introduction before proceeding.

       

Log in to post a comment.