pddl


Namepddl JSON
Version 0.4.0 PyPI version JSON
download
home_pagehttps://github.com/AI-Planning/pddl.git
SummaryPDDL parser
upload_time2023-10-18 15:19:17
maintainer
docs_urlNone
authorMarco Favorito, Francesco Fuggitti, Christian Muise
requires_python>=3.8
licenseMIT License
keywords pddl
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            <h1 align="center">
  <b>pddl</b>
</h1>

<p align="center">
  <a href="https://pypi.org/project/pddl">
    <img alt="PyPI" src="https://img.shields.io/pypi/v/pddl">
  </a>
  <a href="https://pypi.org/project/pddl">
    <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/pddl" />
  </a>
  <a href="">
    <img alt="PyPI - Status" src="https://img.shields.io/pypi/status/pddl" />
  </a>
  <a href="">
    <img alt="PyPI - Implementation" src="https://img.shields.io/pypi/implementation/pddl">
  </a>
  <a href="">
    <img alt="PyPI - Wheel" src="https://img.shields.io/pypi/wheel/pddl">
  </a>
  <a href="https://github.com/AI-Planning/pddl/blob/main/LICENSE">
    <img alt="GitHub" src="https://img.shields.io/github/license/AI-Planning/pddl">
  </a>
</p>
<p align="center">
  <a href="">
    <img alt="test" src="https://github.com/AI-Planning/pddl/workflows/test/badge.svg">
  </a>
  <a href="">
    <img alt="lint" src="https://github.com/AI-Planning/pddl/workflows/lint/badge.svg">
  </a>
  <a href="">
    <img alt="docs" src="https://github.com/AI-Planning/pddl/workflows/docs/badge.svg">
  </a>
  <a href="https://codecov.io/gh/AI-Planning/pddl">
    <img alt="codecov" src="https://codecov.io/gh/AI-Planning/pddl/branch/main/graph/badge.svg?token=FG3ATGP5P5">
  </a>
</p>
<p align="center">
  <a href="https://img.shields.io/badge/flake8-checked-blueviolet">
    <img alt="" src="https://img.shields.io/badge/flake8-checked-blueviolet">
  </a>
  <a href="https://img.shields.io/badge/mypy-checked-blue">
    <img alt="" src="https://img.shields.io/badge/mypy-checked-blue">
  </a>
  <a href="https://img.shields.io/badge/code%20style-black-black">
    <img alt="black" src="https://img.shields.io/badge/code%20style-black-black" />
  </a>
  <a href="https://www.mkdocs.org/">
    <img alt="" src="https://img.shields.io/badge/docs-mkdocs-9cf">
  </a>
</p>

`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:

```python
from pddl.logic import Predicate, constants, variables
from pddl.core import Domain, Problem
from pddl.action import Action
from pddl.formatter import domain_to_string, problem_to_string
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_to_string(domain))
```

that gives:
```output
(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:
```python
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:
```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:
```python
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](https://helios.hud.ac.uk/scommv/IPC-14/repository/kovacs-pddl-3.1-2011.pdf)
requirements:

- [x] `:strips`
- [x] `:typing`
- [x] `:negative-preconditions`
- [x] `:disjunctive-preconditions`
- [x] `:equality`
- [x] `:existential-preconditions`
- [x] `:universal-preconditions`
- [x] `:quantified-preconditions`
- [x] `:conditional-effects`
- [ ] `:fluents`
- [x] `:numeric-fluents`
- [x] `:non-deterministic` (see [6th IPC: Uncertainty Part](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.163.7140&rep=rep1&type=pdf))
- [x] `:adl`
- [ ] `:durative-actions`
- [ ] `:duration-inequalities`
- [x] `:derived-predicates`
- [ ] `:timed-initial-literals`
- [ ] `:preferences`
- [ ] `:constraints`
- [x] `:action-costs`

## Development

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

- Install [Pipenv](https://pipenv-fork.readthedocs.io/en/latest/)
- Clone the repository: `git clone https://github.com/AI-Planning/pddl.git && cd pddl`
- Install development dependencies: `pipenv shell --python 3.8 && 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](http://localhost:8000)

## Authors

- [Marco Favorito](https://marcofavorito.me)
- [Francesco Fuggitti](https://francescofuggitti.github.io)
- [Christian Muise](http://www.haz.ca/)

## License

`pddl` is released under the MIT License.

Copyright (c) 2021-2022 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".


# 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.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/AI-Planning/pddl.git",
    "name": "pddl",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "pddl",
    "author": "Marco Favorito, Francesco Fuggitti, Christian Muise",
    "author_email": "marco.favorito@gmail.com, francesco.fuggitti@gmail.com, christian.muise@queensu.ca",
    "download_url": "https://files.pythonhosted.org/packages/1a/32/33cf14d140b5508f6532b501bd681cacbf2d5ae612eec8d34ea836919a13/pddl-0.4.0.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\n  <b>pddl</b>\n</h1>\n\n<p align=\"center\">\n  <a href=\"https://pypi.org/project/pddl\">\n    <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/pddl\">\n  </a>\n  <a href=\"https://pypi.org/project/pddl\">\n    <img alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/pddl\" />\n  </a>\n  <a href=\"\">\n    <img alt=\"PyPI - Status\" src=\"https://img.shields.io/pypi/status/pddl\" />\n  </a>\n  <a href=\"\">\n    <img alt=\"PyPI - Implementation\" src=\"https://img.shields.io/pypi/implementation/pddl\">\n  </a>\n  <a href=\"\">\n    <img alt=\"PyPI - Wheel\" src=\"https://img.shields.io/pypi/wheel/pddl\">\n  </a>\n  <a href=\"https://github.com/AI-Planning/pddl/blob/main/LICENSE\">\n    <img alt=\"GitHub\" src=\"https://img.shields.io/github/license/AI-Planning/pddl\">\n  </a>\n</p>\n<p align=\"center\">\n  <a href=\"\">\n    <img alt=\"test\" src=\"https://github.com/AI-Planning/pddl/workflows/test/badge.svg\">\n  </a>\n  <a href=\"\">\n    <img alt=\"lint\" src=\"https://github.com/AI-Planning/pddl/workflows/lint/badge.svg\">\n  </a>\n  <a href=\"\">\n    <img alt=\"docs\" src=\"https://github.com/AI-Planning/pddl/workflows/docs/badge.svg\">\n  </a>\n  <a href=\"https://codecov.io/gh/AI-Planning/pddl\">\n    <img alt=\"codecov\" src=\"https://codecov.io/gh/AI-Planning/pddl/branch/main/graph/badge.svg?token=FG3ATGP5P5\">\n  </a>\n</p>\n<p align=\"center\">\n  <a href=\"https://img.shields.io/badge/flake8-checked-blueviolet\">\n    <img alt=\"\" src=\"https://img.shields.io/badge/flake8-checked-blueviolet\">\n  </a>\n  <a href=\"https://img.shields.io/badge/mypy-checked-blue\">\n    <img alt=\"\" src=\"https://img.shields.io/badge/mypy-checked-blue\">\n  </a>\n  <a href=\"https://img.shields.io/badge/code%20style-black-black\">\n    <img alt=\"black\" src=\"https://img.shields.io/badge/code%20style-black-black\" />\n  </a>\n  <a href=\"https://www.mkdocs.org/\">\n    <img alt=\"\" src=\"https://img.shields.io/badge/docs-mkdocs-9cf\">\n  </a>\n</p>\n\n`pddl` aims to be an unquestionable and complete parser for PDDL 3.1.\n\n## Install\n\n- from PyPI:\n```\npip install pddl\n```\n\n- from source (`main` branch):\n```\npip install git+https://github.com/AI-Planning/pddl.git\n```\n\n- or, clone the repository and install:\n```\ngit clone https://github.com/AI-Planning/pddl.git\ncd pddl\npip install .\n```\n## Quickstart\n\nYou can use the `pddl` package in two ways: as a library, and as a CLI tool.\n\n### As a library\n\nThis is an example of how you can build a PDDL domain or problem\nprogrammatically:\n\n```python\nfrom pddl.logic import Predicate, constants, variables\nfrom pddl.core import Domain, Problem\nfrom pddl.action import Action\nfrom pddl.formatter import domain_to_string, problem_to_string\nfrom pddl.requirements import Requirements\n\n# set up variables and constants\nx, y, z = variables(\"x y z\", types=[\"type_1\"])\na, b, c = constants(\"a b c\", type_=\"type_1\")\n\n# define predicates\np1 = Predicate(\"p1\", x, y, z)\np2 = Predicate(\"p2\", x, y)\n\n# define actions\na1 = Action(\n    \"action-1\",\n    parameters=[x, y, z],\n    precondition=p1(x, y, z) & ~p2(y, z),\n    effect=p2(y, z)\n)\n\n# define the domain object.\nrequirements = [Requirements.STRIPS, Requirements.TYPING]\ndomain = Domain(\"my_domain\",\n                requirements=requirements,\n                types={\"type_1\": None},\n                constants=[a, b, c],\n                predicates=[p1, p2],\n                actions=[a1])\n\nprint(domain_to_string(domain))\n```\n\nthat gives:\n```output\n(define (domain my_domain)\n    (:requirements :strips :typing)\n    (:types type_1)\n    (:constants a b c - type_1)\n    (:predicates (p1 ?x - type_1 ?y - type_1 ?z - type_1)  (p2 ?x - type_1 ?y - type_1))\n    (:action action-1\n        :parameters (?x - type_1 ?y - type_1 ?z - type_1)\n        :precondition (and (p1 ?x ?y ?z) (not (p2 ?y ?z)))\n        :effect (p2 ?y ?z)\n    )\n)\n```\n\nAs well as a PDDL problem:\n```python\nproblem = Problem(\n    \"problem-1\",\n    domain=domain,\n    requirements=requirements,\n    objects=[a, b, c],\n    init=[p1(a, b, c), ~p2(b, c)],\n    goal=p2(b, c)\n)\nprint(problem_to_string(problem))\n```\n\nOutput:\n```output\n(define (problem problem-1)\n    (:domain my_domain)\n    (:requirements :strips :typing)\n    (:objects a b c - type_1)\n    (:init (not (p2 b c)) (p1 a b c))\n    (:goal (p2 b c))\n)\n```\n\nExample parsing:\n```python\nfrom pddl import parse_domain, parse_problem\ndomain = parse_domain('d.pddl')\nproblem = parse_problem('p.pddl')\n```\n\n### As CLI tool\n\nThe package can also be used as a CLI tool.\nSupported commands are:\n- `pddl domain FILE`: validate a PDDL domain file, and print it formatted.\n- `pddl problem FILE`: validate a PDDL problem file, and print it formatted.\n\n## Features\n\nSupported [PDDL 3.1](https://helios.hud.ac.uk/scommv/IPC-14/repository/kovacs-pddl-3.1-2011.pdf)\nrequirements:\n\n- [x] `:strips`\n- [x] `:typing`\n- [x] `:negative-preconditions`\n- [x] `:disjunctive-preconditions`\n- [x] `:equality`\n- [x] `:existential-preconditions`\n- [x] `:universal-preconditions`\n- [x] `:quantified-preconditions`\n- [x] `:conditional-effects`\n- [ ] `:fluents`\n- [x] `:numeric-fluents`\n- [x] `:non-deterministic` (see [6th IPC: Uncertainty Part](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.163.7140&rep=rep1&type=pdf))\n- [x] `:adl`\n- [ ] `:durative-actions`\n- [ ] `:duration-inequalities`\n- [x] `:derived-predicates`\n- [ ] `:timed-initial-literals`\n- [ ] `:preferences`\n- [ ] `:constraints`\n- [x] `:action-costs`\n\n## Development\n\nIf you want to contribute, here's how to set up your development environment.\n\n- Install [Pipenv](https://pipenv-fork.readthedocs.io/en/latest/)\n- Clone the repository: `git clone https://github.com/AI-Planning/pddl.git && cd pddl`\n- Install development dependencies: `pipenv shell --python 3.8 && pipenv install --dev`\n\n## Tests\n\nTo run tests: `tox`\n\nTo run only the code tests: `tox -e py37`\n\nTo run only the code style checks: `tox -e flake8`\n\n## Docs\n\nTo build the docs: `mkdocs build`\n\nTo view documentation in a browser: `mkdocs serve`\nand then go to [http://localhost:8000](http://localhost:8000)\n\n## Authors\n\n- [Marco Favorito](https://marcofavorito.me)\n- [Francesco Fuggitti](https://francescofuggitti.github.io)\n- [Christian Muise](http://www.haz.ca/)\n\n## License\n\n`pddl` is released under the MIT License.\n\nCopyright (c) 2021-2022 WhiteMech\n\n## Acknowledgements\n\nThe `pddl` project is partially supported by the ERC Advanced Grant WhiteMech\n(No. 834228), the EU ICT-48 2020 project TAILOR (No. 952215),\nthe PRIN project RIPER (No. 20203FFYLK), and the JPMorgan AI Faculty\nResearch Award \"Resilience-based Generalized Planning and Strategic\nReasoning\".\n\n\n# Change Log\n\n## 0.1.0 (2021-06-21)\n\nThe first official release of pddl.\n\nMain features:\n* Specify PDDL domains and problems programmatically.\n* Parsing for PDDL domains and problems.\n\n## 0.0.1 (2020-07-30)\n\n* First commit on the package.\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "PDDL parser",
    "version": "0.4.0",
    "project_urls": {
        "Homepage": "https://github.com/AI-Planning/pddl.git"
    },
    "split_keywords": [
        "pddl"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05b805b927d9e49ab6b067bfc396777f5663df93fd45522a966aa33ed5dbd833",
                "md5": "79f2c9f3471ffa15483a4eace59ec4ea",
                "sha256": "189094c74984a882c71fe6f732fe96252cd3cc818a26c2bd989c4f2543062d17"
            },
            "downloads": -1,
            "filename": "pddl-0.4.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "79f2c9f3471ffa15483a4eace59ec4ea",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 50532,
            "upload_time": "2023-10-18T15:19:15",
            "upload_time_iso_8601": "2023-10-18T15:19:15.376212Z",
            "url": "https://files.pythonhosted.org/packages/05/b8/05b927d9e49ab6b067bfc396777f5663df93fd45522a966aa33ed5dbd833/pddl-0.4.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a3233cf14d140b5508f6532b501bd681cacbf2d5ae612eec8d34ea836919a13",
                "md5": "bb02df54a0930674e31a083830d76f23",
                "sha256": "ccebc2a3b30c85060ff7a29a94af959a494b64bd983c5ef4e77d3ec3bd1c8fd7"
            },
            "downloads": -1,
            "filename": "pddl-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bb02df54a0930674e31a083830d76f23",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 1235922,
            "upload_time": "2023-10-18T15:19:17",
            "upload_time_iso_8601": "2023-10-18T15:19:17.247464Z",
            "url": "https://files.pythonhosted.org/packages/1a/32/33cf14d140b5508f6532b501bd681cacbf2d5ae612eec8d34ea836919a13/pddl-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-18 15:19:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AI-Planning",
    "github_project": "pddl",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "pddl"
}
        
Elapsed time: 0.12785s