Package: pddl
pddlpddlaims to be an unquestionable and complete parser for PDDL 3.1.Installfrom PyPI:pip install pddlfrom source (mainbranch):pip install git+https://github.com/AI-Planning/pddl.gitor, clone the repository and install:git clone https://github.com/AI-Planning/pddl.git
cd pddl
pip install .QuickstartYou can use thepddlpackage in two ways: as a library, and as a CLI tool.As a libraryThis is an example of how you can build a PDDL domain or problem
programmatically:frompddl.logicimportPredicate,constants,variablesfrompddl.coreimportDomain,Problemfrompddl.actionimportActionfrompddl.formatterimportdomain_to_string,problem_to_stringfrompddl.requirementsimportRequirements# set up variables and constantsx,y,z=variables("x y z",types=["type_1"])a,b,c=constants("a b c",type_="type_1")# define predicatesp1=Predicate("p1",x,y,z)p2=Predicate("p2",x,y)# define actionsa1=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_to_string(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_to_string(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:frompddlimportparse_domain,parse_problemdomain=parse_domain('d.pddl')problem=parse_problem('p.pddl')As CLI toolThe 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.FeaturesSupportedPDDL 3.1requirements::strips:typing:negative-preconditions:disjunctive-preconditions:equality:existential-preconditions:universal-preconditions:quantified-preconditions:conditional-effects:fluents:numeric-fluents:non-deterministic(see6th IPC: Uncertainty Part):adl:durative-actions:duration-inequalities:derived-predicates:timed-initial-literals:preferences:constraints:action-costsDevelopmentIf you want to contribute, here's how to set up your development environment.InstallPipenvClone the repository:git clone https://github.com/AI-Planning/pddl.git && cd pddlInstall development dependencies:pipenv shell --python 3.8 && pipenv install --devTestsTo run tests:toxTo run only the code tests:tox -e py37To run only the code style checks:tox -e flake8DocsTo build the docs:mkdocs buildTo view documentation in a browser:mkdocs serveand then go tohttp://localhost:8000AuthorsMarco FavoritoFrancesco FuggittiChristian MuiseLicensepddlis released under the MIT License.Copyright (c) 2021-2022 WhiteMechAcknowledgementsThepddlproject 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".Change Log0.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.