Skip to main content

PDDL parser

Project description

pddl

PyPI PyPI - Python Version PyPI - Status PyPI - Implementation PyPI - Wheel GitHub

test lint docs codecov

black

pddl aims to be an unquestionable and complete parser for PDDL 3.1.

Install

  • from PyPI:
pip install pddl
  • from source (main branch):
pip install git+https://github.com/AI-Planning/pddl.git
  • or, clone the repository and install:
git clone https://github.com/AI-Planning/pddl.git
cd pddl
pip install .

Quickstart

You can use the pddl package in two ways: as a library, and as a CLI tool.

As a library

This is an example of how you can build a PDDL domain or problem programmatically:

from pddl.logic import Predicate, constants, variables
from pddl.core import Domain, Problem
from pddl.action import Action
from pddl.requirements import Requirements

# set up variables and constants
x, y, z = variables("x y z", types=["type_1"])
a, b, c = constants("a b c", type_="type_1")

# define predicates
p1 = Predicate("p1", x, y, z)
p2 = Predicate("p2", x, y)

# define actions
a1 = Action(
    "action-1",
    parameters=[x, y, z],
    precondition=p1(x, y, z) & ~p2(y, z),
    effect=p2(y, z)
)

# define the domain object.
requirements = [Requirements.STRIPS, Requirements.TYPING]
domain = Domain("my_domain",
                requirements=requirements,
                types={"type_1": None},
                constants=[a, b, c],
                predicates=[p1, p2],
                actions=[a1])

print(domain)

that gives:

(define (domain my_domain)
    (:requirements :strips :typing)
    (:types type_1)
    (:constants a b c - type_1)
    (:predicates (p1 ?x - type_1 ?y - type_1 ?z - type_1)  (p2 ?x - type_1 ?y - type_1))
    (:action action-1
        :parameters (?x - type_1 ?y - type_1 ?z - type_1)
        :precondition (and (p1 ?x ?y ?z) (not (p2 ?y ?z)))
        :effect (p2 ?y ?z)
    )
)

As well as a PDDL problem:

problem = Problem(
    "problem-1",
    domain=domain,
    requirements=requirements,
    objects=[a, b, c],
    init=[p1(a, b, c), ~p2(b, c)],
    goal=p2(b, c)
)
print(problem)

Output:

(define (problem problem-1)
    (:domain my_domain)
    (:requirements :strips :typing)
    (:objects a b c - type_1)
    (:init (not (p2 b c)) (p1 a b c))
    (:goal (p2 b c))
)

Example parsing:

from pddl import parse_domain, parse_problem
domain = parse_domain('d.pddl')
problem = parse_problem('p.pddl')

As CLI tool

The package can also be used as a CLI tool. Supported commands are:

  • pddl domain FILE: validate a PDDL domain file, and print it formatted.
  • pddl problem FILE: validate a PDDL problem file, and print it formatted.

Features

Supported PDDL 3.1 requirements:

  • :strips
  • :typing
  • :negative-preconditions
  • :disjunctive-preconditions
  • :equality
  • :existential-preconditions
  • :universal-preconditions
  • :quantified-preconditions
  • :conditional-effects
  • :fluents
  • :numeric-fluents
  • :non-deterministic (see 6th IPC: Uncertainty Part)
  • :adl
  • :durative-actions
  • :duration-inequalities
  • :derived-predicates
  • :timed-initial-literals
  • :preferences
  • :constraints
  • :action-costs

Development

If you want to contribute, here's how to set up your development environment.

  • Install Pipenv
  • Clone the repository: git clone https://github.com/AI-Planning/pddl.git && cd pddl
  • Install development dependencies: pipenv shell --python 3.9 && pipenv install --dev

Tests

To run tests: tox

To run only the code tests: tox -e py37

To run only the code style checks: tox -e flake8

Docs

To build the docs: mkdocs build

To view documentation in a browser: mkdocs serve and then go to http://localhost:8000

Authors

License

pddl is released under the MIT License.

Copyright (c) 2021-2025 WhiteMech

Acknowledgements

The pddl project is partially supported by the ERC Advanced Grant WhiteMech (No. 834228), the EU ICT-48 2020 project TAILOR (No. 952215), the PRIN project RIPER (No. 20203FFYLK), and the JPMorgan AI Faculty Research Award "Resilience-based Generalized Planning and Strategic Reasoning".

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

pddl-0.4.2.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

pddl-0.4.2-py2.py3-none-any.whl (50.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pddl-0.4.2.tar.gz.

File metadata

  • Download URL: pddl-0.4.2.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for pddl-0.4.2.tar.gz
Algorithm Hash digest
SHA256 b334c11131c5d6aac2d99b9ecc9068e6cc87c257b5049b3bd6dad8c5fda78f60
MD5 529fa41997f55a064883a3cbfd6017aa
BLAKE2b-256 55664771beb56cbcf901959e52f0f6502d30ef57e63d58c1221691bbd5a0686e

See more details on using hashes here.

File details

Details for the file pddl-0.4.2-py2.py3-none-any.whl.

File metadata

  • Download URL: pddl-0.4.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 50.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for pddl-0.4.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a2475096f2b0879ac2adfd2d7fe28e226b8022550de9a118af541779f9945aa4
MD5 2160c7d8b2ca4e2c0290b901b16310ea
BLAKE2b-256 e0ed9b6aaa861692b678866c6a5dfe23c7348e8e2e32d650cd85d7b4933165be

See more details on using hashes here.

Supported by

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