methods with variable task list?

  • Hello,

    I'm interested in using a method whose list of tasks is created by some "external" algorithm (a function call). I've read the SHOP2 documentation and can't see if this is doable. Could someone confirm if this is possible (or not)?

    • It's possible to do this, by making the task network part of a method definition be a variable, that will be bound to a list.

      HOWEVER, because of the order in which variables are bound in method expressions, the results may be hard to predict.  I have also found that this is cumbersome and difficult, because one often wishes to construct a complex task structure, with dependencies between these the subtasks.  I have not found an elegant way to do this.

      • Thanks Robert,

        I think I understand what you say, given the fact that I've been away from lisp for some years. If I understand correctly, you mean something like:

        (:method (blah)
            ((will-do ?something))

        If I'm right, I think this kind of convolution doesn't suit my needs.

        Reading the SHOP2 documentation I see at the end of point 9.1:

        "In SHOP 1.x it was valid to have methods of the following form, where e is any Lisp expression:

        (:method (varSubtasks ?tasklist)

        This kind of method is not supported in SHOP2".

        Since this is exactly what I want, I wonder why it was deprecated. Maybe something related with provability? Would it be too hard to add it back?

        I've been experimenting with methods of the form:

        (:method (blah2 ?args)
           ((eval (some-function ?args))))

        but it seems that eval terms are never evaluated in the task part, whereas they're in the preconditions.

        Kind regards,

        A. Mosteo.

    • That is correct.  eval will not be evaluated in a task network, since EVAL is specific to the code used to retrieve preconditions. 

      Any particular reason not to just invoke the function in the preconditions (say, using ASSIGN), to bind a variable, and then put the variable in the task network?

      I think that would work, but I can't swear to it.  There might be issues with applying substitutions.  I've put some unification fixes into the CVS.  You might try the approach that I propose above with the release version of SHOP2, and if that doesn't work, try the CVS version.

      • No reason except my ignorance ;) I didn't figure that something as an assignment could be put in a logical expression. I'm trying it but have a new problem (probably only lisp-related):

        For testing purposes I've defined a method which receives a number n and creates operators for 1 .. n. For example:

        (split 3)

        should expand to

        (!consume 1) (!consume 2) (!consume 3)


                    ; SPLIT
                    ; This should create as many consumes as the parameter says
                    (:method (split ?high)
                             ((exists ?high) (assign ?sub (do-split ?high)))

        To do this I use a lisp function, do-split, assigning to a var as you suggest.

        Now, the problem is that the function returns a list of the form: ((!consume 1) (!consume 2) ..) so when it is expanded in the tasks list of the method it results in:

        (((!consume 1) (!consume 2) (!consume 3)))

        which as you can see has one parenthesis too many to work. I can't figure a way to just return


        or to get rid of that outer parenthesis later. If I put just "?sub" instead of "(?sub)" in the method tasks, shop2 gives an error when creating the domain.

        Whereas this example could be done purely with methods/operators, it's only an example of what I intend to do.

        Thanks for your help and kind regards,

        A. Mosteo.