Blocks-world PDDL Theoretic

Getting started

The framework is released as EGG file to be used on a Desktop platform, therefore it can be easily installed in a Theoretic installation.

The framework needs ANTLR4 library for its operation.

Using EmbASP

In the following, we describe an actual usage of the framework by means of a running example; as a use case, we will develop a simple Desktop application to solve the blocks-world problem.

The complete code of this example is freely available here.

../_images/blocks-world.svg

We will make use of the annotation-guided mapping, in order to retrieve the actions constituting a PDDL plan via Theoretic objects.

To this purpose, the following classes are intended to represent possible actions that a blocks-world solution plan can feature:

class PickUp(Predicate):
   predicateName="pick-up"

   def __init__(self, block=None):
      super(PickUp, self).__init__([("block")])
      self.block = block

   [...]
class PutDown (Predicate):
   predicateName="put-down"

   def __init__(self, block=None):
      super(PutDown, self).__init__([("block")])
      self.block = block

   [...]
class Stack (Predicate):
   predicateName="stack"

   def __init__(self, block1=None, block2=None):
      super(Stack, self).__init__([("block1"), ("block2")])
      self.block1 = block1
      self.block2 = block2

   [...]
class Unstack (Predicate):
   predicateName="unstack"

   def __init__(self, block1=None, block2=None):
      super(Unstack, self).__init__([("block1"), ("block2")])
      self.block1 = block1
      self.block2 = block2

   [...]

At this point, supposing that we are given two files defining the blocks-world domain and a problem instance, we can start deploying our application:

handler  = DesktopHandler(SPDDesktopService())

input_domain = PDDLInputProgram(PDDLProgramType.DOMAIN)
input_domain.add_files_path("../domain.pddl")

input_problem= PDDLInputProgram(PDDLProgramType.PROBLEM)
input_problem.add_files_path("../p01.pddl")

handler.add_program(input_domain)
handler.add_program(input_problem)

PDDLMapper.get_instance().register_class(PickUp)
PDDLMapper.get_instance().register_class(PutDown)
PDDLMapper.get_instance().register_class(Stack)
PDDLMapper.get_instance().register_class(Unstack)

output = handler.start_sync()

for obj in output.get_actions_objects():
   if isinstance(obj, PickUp) | isinstance(obj, PutDown) | isinstance(obj, Stack) | isinstance(obj, Unstack) :
      print(obj)

The file contains an Handler instance as field, that is initialized with a DesktopHandler using the required parameter SPDDesktopService.

Then it’s set-up the input to the solver; since PDDL requires separate definitions for domain and problem, two PDDLInputProgram are created and then given to the handler.

The next lines inform the PDDLMapper about what classes are intended to map the output actions.

Finally the solver is invoked, and the output is retrieved.

The output actions can be managed accordingly to the user’s desiderata.


For further information, contact embasp@mat.unical.it or visit our website.