Skip to main content

Python utils for lifted PDDL planning, including PDDL parser and lifted successor generation.

Project description

Plado Python Planning Library

Name is pronounced PLAY-doh, it's catchy, playful, and easy to say - according to ChatGPT.

Plado is a python library for parsing, manipulating, and operating on the semantics of (P)PPDL files. It currently supports derived predicates, numeric fluents, conditional and probabilistic effects. The complete support list is given below.

Installation

Requirements: Python >= 3.10

Plado is available via pypi and can be installed simply by

pip install plado

As plado is written in pure python, you can alternatively just clone the repository and make the plado folder available in your python path.

PDDL Support List

  • strips
  • typing
  • disjunctive-preconditions
  • equality
  • existential-preconditions
  • universal-preconditions
  • negative-preconditions
  • fluents
  • durative-actions
  • durative-inequalities
  • continuous-effects
  • derived-predicates
  • timed-initial-literals
  • preferences
  • constraints
  • probabilistic-effects
  • rewards

Components

Plado features three main components: a syntactic, a semantic, and a largely orthogonal datalog component. This functionality is split across the following sub-modules:

  • pddl plado's class representation of all (supported) PDDL entities
  • pddl_utils basic utility functions for traversing and manipulating the internal PDDL representation
  • parser PDDL file parsing and sanity checking
  • semantics implementation of the semantic operations
  • datalog plado's datalog engine

Syntactic Component

The syntactic component is responsible for reading and writing (Probabilistic)PDDL files, and features a series of additional utility functions for sanity checking syntactically valid PDDL tasks and performing various task-equivalent transformations, such as bringing conditions into a normal form.

Parsing

A PDDL problem and domain pair can be parsed via the parser sub-module:

from plado.parser import parse, parse_and_normalize
domain, problem = parse(PATH_TO_DOMAIN, PATH_TO_PROBLEM)
# alternatively, with performing additional normalization steps
# domain, problem = parse_and_normalize(PATH_TO_DOMAIN, PATH_TO_PROBLEM)

Plado parses the given PDDL files into tree-like data-structures, represented through the classes from the pddl sub-module.

Normalization

The normalization steps involve the normalization of conditions and action effects such that, in the end, all conditions are conjunctions of literals and all actions effects have the form universal effect > conjunctive effect > probabilistic effect > conjunctive effect > universal effect > conditional effect > atomic effect. Quantified and disjunctive conditions are replaced by newly introduced derived predicates. All transformations preserve the semantics of the original PDDL instance.

The normalization functions can also be called manually via pddl_utils.normalize_conditions and pddl_utils.normalize_effects.

Traversal and Manipulation

Plado's tree-like representation can be traversed and manipulated following the visitor pattern. For traversal, plado provides the abstract classes pddl.BooleanExpressionVisitor, pddl.NumericExpressionVisitor, and pddl.ActionEffectVisitor; likewise for manipulation, the pddl.BooleanExpressionTransformer, pddl.NumericExpressionTransformer, and pddl.ActionEffectTransformer classes. For convenience, there are also pddl.RecursiveBooleanExpressionVisitor and RecursiveNumericExpressionVisitor classes, which default to recursively traversing all non-leaf expression elements.

Individual expression or action-effect objects have a traverse function that accept a visitor or transformer object. The pddl_utils module provides further functions to visit or transform all conditions appearing in a PDDL domain or action.

Semantic Component

The semantic component comes with a PDDL state representation, which serves as the basis for implementing advanced features, such as Boolean and numeric expression evaluators, an applicable actions, as well as a successor generator. All semantic operations require a pddl.semantics.task.Task object, which coalesces a plado PDDL domain and problem pair into single object. pddl.semantics.task.Task performs some additional simplifications, such as replacing object strings by numeric identifiers, that ease the implementation of the semantic operations.

The following operations are available. All operations operate at the lifted task level, i.e., don't necessitate grounding.

  • The applicable actions generator (pddl.semantics.applicable_actions_generator) takes a state as input and returns the list of ground actions applicable in that state. The computation is done via a compilation into a datalog program, which is passed to a dedicated datalog engine.
  • The successor generator (pddl.semantics.successor_generator) takes a state and a ground action as input and returns the probability distribution over successor states. In the presence of conditional or universal effects, action effects are grounded via a compilation into datalog.
  • The goal checker (pddl.semantics.goal_checker) takes a state as input and returns true if the state satisfies the task's goal condition. The condition is evaluated using a compilation into datalog.
  • The grounder (pddl.semantics.grounder) uses datalog for grounding all delete-relaxed reachable facts and actions.

Datalog Component

The heart of plado is its datalog engine, which powers all of plado's semantic operations. Plado processes a datalog program in three steps:

  1. Preprocessing: constants in atoms are replaced by fresh variables, binding which to the constant through additional equality atoms; the variables in all atoms of a datalog clause are made distinct by introducing fresh variables and additional equality atoms; variables in each datalog clause are standardized to indices 0,...,|variables in clause|-1.
  2. Optimization: each clause of the standardized datalog program is translated into a join graph; which is heuristically optimized to obtain small intermediate results.
  3. Code compilation: the datalog program is evaluated following the semi-naive method. The code performing this evaluation is generated dynamically from the structural dependencies between the clauses of the datalog program and their associated optimized join graphs from the previous step.

The datalog engine also supports numeric conditions.

All these steps are abstracted away through the pddl.datalog.evaluator.DatalogEngine class.

Example Usages

Some examples are provided directly by the plado repository, cf. the examples folder. In particular, examples/search.py implements a BFWS-based complete (deterministic) planner using plado's functionality. examples/grounder.py utilizes plado for grounding the delete-relaxed reachable parts of a PDDL task.

Plado also appears as the base engine underlying the AI Beluga competition toolkit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plado-0.1.6.tar.gz (69.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plado-0.1.6-py3-none-any.whl (73.2 kB view details)

Uploaded Python 3

File details

Details for the file plado-0.1.6.tar.gz.

File metadata

  • Download URL: plado-0.1.6.tar.gz
  • Upload date:
  • Size: 69.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for plado-0.1.6.tar.gz
Algorithm Hash digest
SHA256 248cbd72c87e62db216198b7b8b42d9086f239803ba716bb4f93cea2d9588379
MD5 11de4ab64d554a330069919a1e3a8d19
BLAKE2b-256 d70aa7a151ab7bda12d7639e5d9539f44330a607d56919146db006f1162a97f0

See more details on using hashes here.

File details

Details for the file plado-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: plado-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 73.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for plado-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a1608ca4e8ed4dc71c483f2089321cd2fb6993679eb73223865f9d3bfa044d80
MD5 557faf6e2ad8a3e84ceba64a0b0d2a19
BLAKE2b-256 9d29ce515a41d07db2d425ff2a328d7a374553a90171ade592d5575dbcd3d8f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page