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 source (master branch):
pip install git+https://github.com/whitemech/pddl.git
  • or, clone the repository and install:
git clone https://github.com/whitemech/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, Action, Requirements
from pddl.formatter import domain_to_string, problem_to_string

# set up variables and constants
x, y, z = variables("x y z", types=["type_1"])
a, b, c = constants("a b c", types=["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"],
       constants=[a, b, c],
       predicates=[p1, p2],
       actions=[a1])

print(domain_to_string(domain))

that gives:

(define (domain my_domain)
    (:requirements :strips :typing)
    (:types type_1)
    (:constants a b c)
    (:predicates (p1 ?x ?y ?z) (p2 ?x ?y))
    (:actions
        (action-1
            :parameters (?x ?y ?z)
            :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_to_string(problem))

Output:

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

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/whitemech/pddl.git && cd pddl
  • Install development dependencies: pipenv shell --python 3.7 && 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 GNU Lesser General Public License v3.0 or later (LGPLv3+).

Copyright 2021 WhiteMech

Change Log

0.1.0 (2021-06-21)

The first official release of pddl.

Main features:

  • Specify PDDL domains and problems programmatically.
  • Parsing for PDDL domains and problems.

0.0.1 (2020-07-30)

  • First commit on the package.

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.1.0.tar.gz (822.7 kB view details)

Uploaded Source

Built Distribution

pddl-0.1.0-py2.py3-none-any.whl (36.0 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: pddl-0.1.0.tar.gz
  • Upload date:
  • Size: 822.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.5

File hashes

Hashes for pddl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8e6063e05c7e0570cef23ff6bf10503620aeb4d7ac0467bf80da73c75299d644
MD5 eb2b18dfbbf9a8cb81dda8efeca23464
BLAKE2b-256 3a663c88d122c5996cee223e707a95f0230057f641b7179ccbec9564a2242c1b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pddl-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 36.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.5

File hashes

Hashes for pddl-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d2b17ded88acae6819a2832295b68353a173a2c2b5988f34f6845dde4c80273f
MD5 3c6e5e3a7ac631998a035073e21eb2bb
BLAKE2b-256 ef1b16da15a90218f252df54bea02b66871f460cc0dcbbde31c5a9fd84648f3d

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