-
Notifications
You must be signed in to change notification settings - Fork 1
Using Planners
Many agents implemented in PDDLSIM may need to use planning for some part of their decision-making. Despite this, unfortunately, using planners with PDDLSIM is not as simple as just running a planner on a PDDLSIM problem. This is mainly because PDDLSIM implements some extensions over standard PDDL, such as probabilistic effects, multiple goals, etc. Therefore, agents using planners must either drop support for problems utilizing unsupported features, or convert such problems into a format planners can support. Either way of course, one still needs to bridge the gap between the planner's API and PDDLSIM's API.
Tip
For a practical example of using planners, check out the simple planner example, or the multiple goals planner example, which is slightly more involved, and shows how to actually reduce a problem into a form planners can use, by eliminating the :multiple-goals requirement.
Assuming you have a Domain/Problem object, and want to query it for including different requirements, this can be done via accessing its requirements_section field, which in practice, acts as a set of Requirement. Therefore, assuming you have a domain and a problem, and want to make sure the domain doesn't use probabilistic effects, and that the problem doesn't use multiple goals, you can write:
if Requirement.PROBABILISTIC_EFFECTS in domain.requirements_section:
raise ValueError(...)
if Requirement.MULTIPLE_GOALS in problem.requirements_section:
raise ValueError(...)It's likewise very simple to extend this to checking if any of a set of "banned" requirements are present in a domain/problem.
Note
Note that during the conversion of a Problem into a string, the revealables section and the action fallibilities section aren't kept, as they are considered hidden information. This makes conversion technically lossy. This currently cannot be changed.
There are two main ways to feed domains and problems into a planner: via a textual representation, or via some kind of problem-construction API. Assuming the PDDLSIM domain and problem only use features that the planner supports, creating a string to pass into a planner can be done by running repr(...) on the domain/object, e.g. repr(domain).
The alternative to passing a string, i.e., using a problem-construction API, is also fully supported, and can be achieved by simply walking the AST objects (from pddlsim.ast) generated by PDDLSIM, and using the planner-specific API accordingly. See the API reference for more information on the structure of the AST objects, helpful for doing this kind of "walking".