plan4past


Nameplan4past JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://whitemech.github.io/plan4past
SummaryClassical and FOND Planning for Pure-Past Linear Temporal Logic Goals
upload_time2023-07-15 23:37:24
maintainer
docs_urlNone
authorLuigi Bonassi
requires_python>=3.8.1,<4.0
licenseLGPLv3+ license
keywords automated planning temporally extended goals pure-past linear temporal logic
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
  <img src="https://user-images.githubusercontent.com/29372925/252561261-c383afa8-9138-43a7-8f7d-fd0ecd9220bd.png" width="40%" height="auto">
</h1>

<p align="center">

  <a href="https://pypi.org/project/plan4past">
    <img alt="Python Version" src="https://img.shields.io/pypi/pyversions/plan4past" />
  </a>
  <a href="https://pypi.org/project/plan4past">
    <img alt="PyPI" src="https://img.shields.io/pypi/v/plan4past">
  </a>
  <a href="https://github.com/whitemech/plan4past/workflows/test/badge.svg">
    <img alt="build" src="https://github.com/whitemech/plan4past/workflows/test/badge.svg">
  </a>
  <a href="https://codecov.io/gh/whitemech/plan4past">
    <img alt="codecov" src="https://codecov.io/gh/whitemech/plan4past/branch/main/graph/badge.svg">
  </a>
  <a href="https://github.com/whitemech/plan4past/blob/main/LICENSE">
    <img alt="GitHub" src="https://img.shields.io/badge/license-LGPLv3%2B-blue">
  </a>
</p>

---

Classical and FOND Planning for Pure-Past Linear Temporal Logic Goals.

## Installation

- from PyPI: 

```
pip install plan4past
```

- from source (`main` branch): 

```
pip install git+https://github.com/whitemech/Plan4Past.git
```

or, clone the repository and install:

```
git clone https://github.com/whitemech/Plan4Past.git
cd Plan4Past
pip install .
```

## Quickstart

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

### As a library
This is an example of how you can encode a PPLTL goal formula into a PDDL domain and problem programmatically.

```python
from pathlib import Path
from pddl.formatter import domain_to_string, problem_to_string
from pddl.parser.domain import DomainParser
from pddl.parser.problem import ProblemParser
from pylogics.parsers import parse_pltl
from plan4past.compiler import Compiler

formula = "on_b_a & O(ontable_c)"
domain_parser = DomainParser()
problem_parser = ProblemParser()

domain = domain_parser(Path("examples/pddl/domain.pddl").read_text(encoding="utf-8"))
problem = problem_parser(Path("examples/pddl/p-0.pddl").read_text(encoding="utf-8"))
goal = parse_pltl(formula)

compiler = Compiler(domain, problem, goal)
compiler.compile()
compiled_domain, compiled_problem = compiler.result

try:
    with open("./new-domain.pddl", "w+", encoding="utf-8") as d:
        d.write(domain_to_string(compiled_domain))
    with open("./new-problem.pddl", "w+", encoding="utf-8") as p:
        p.write(problem_to_string(compiled_problem))
except Exception as e:
    raise IOError(
        "[ERROR]: Something wrong occurred while writing the compiled domain and problem."
    ) from e
```

By executing the code above, you will obtain a `new-domain.pddl` as well as a `new-problem.pddl` in output.

### As a CLI tool

The package can also be used as a CLI tool. The supported command is:

```
plan4past -d DOMAIN_FILE -p PROBLEM_FILE -g "PPLTL_FORMULA" [-m MAPPING] 
```
where `DOMAIN_FILE` and `PROBLEM_FILE` are the PDDL domain and problem files, respectively, and `PPLTL_FORMULA` is the 
goal formula expressed in Pure-Past Linear Temporal Logic. 
The optional `MAPPING` file is a mapping between the PDDL objects and the PPLTL formula's atomic propositions.

For instance:
```
plan4past -d examples/pddl/domain.pddl -p examples/pddl/p-0.pddl -g "ontable_c & O(on_b_a)"
```

## Docker & Apptainer images

A Docker image as well as an Apptainer image are available for Plan4Past.

- To use Docker:
`docker build -t plan4past .` and `docker run --rm -it plan4past`

- To use Apptainer:
```
apptainer build plan4past.sif plan4past.def

# to launch the tool:
./plan4past.sif -d examples/pddl/domain.pddl -p examples/pddl/p-0.pddl -g "ontable_c & O(on_b_a)"
```


## Development

If you want to contribute, set up your development environment as follows:

- Intall [Poetry](https://python-poetry.org)
- Clone the repository: `git clone https://github.com/whitemech/Plan4Past.git && cd Plan4Past`
- Install the dependencies: `poetry shell && poetry install`

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

## License

Plan4Past is released under the GNU Lesser General Public License v3.0 or later (LGPLv3+).

Copyright 2021 -- 2023 WhiteMech

## Citing

If you use Plan4Past in your research, please consider citing the following paper:

```
@inproceedings{icaps2023bdffgs,
  author       = {Luigi Bonassi and 
                  Giuseppe {De Giacomo} and 
                  Marco Favorito and 
                  Francesco Fuggitti and 
                  {Alfonso Emilio} Gerevini and 
                  Enrico Scala},
  title        = {Planning for Temporally Extended Goals in Pure-Past Linear Temporal Logic},
  booktitle    = {{ICAPS}},
  volume       = {33},
  url          = {https://ojs.aaai.org/index.php/ICAPS/article/view/27179},
  doi          = {10.1609/icaps.v33i1.27179},
  number       = {1},
  month        = {Jul.},
  pages        = {61-69},
  year         = {2023},
}
```

## Acknowledgements

Plan4Past has been partially supported by the EU H2020 project AIPlan4EU (No. 101016442), the ERC-ADG WhiteMech 
(No. 834228), the EU ICT-48 2020 project TAILOR (No. 952215), the PRIN project RIPER (No. 20203FFYLK), and the PNRR MUR 
project FAIR (No. PE0000013).


            

Raw data

            {
    "_id": null,
    "home_page": "https://whitemech.github.io/plan4past",
    "name": "plan4past",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<4.0",
    "maintainer_email": "",
    "keywords": "automated planning,temporally extended goals,pure-past linear temporal logic",
    "author": "Luigi Bonassi",
    "author_email": "luigi.bonassi@unibs.it",
    "download_url": "https://files.pythonhosted.org/packages/e0/da/28b9d30aa731a8593f23a9297cd24f60537d149ca96dcdd7a48c21a51a69/plan4past-0.1.0.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\n  <img src=\"https://user-images.githubusercontent.com/29372925/252561261-c383afa8-9138-43a7-8f7d-fd0ecd9220bd.png\" width=\"40%\" height=\"auto\">\n</h1>\n\n<p align=\"center\">\n\n  <a href=\"https://pypi.org/project/plan4past\">\n    <img alt=\"Python Version\" src=\"https://img.shields.io/pypi/pyversions/plan4past\" />\n  </a>\n  <a href=\"https://pypi.org/project/plan4past\">\n    <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/plan4past\">\n  </a>\n  <a href=\"https://github.com/whitemech/plan4past/workflows/test/badge.svg\">\n    <img alt=\"build\" src=\"https://github.com/whitemech/plan4past/workflows/test/badge.svg\">\n  </a>\n  <a href=\"https://codecov.io/gh/whitemech/plan4past\">\n    <img alt=\"codecov\" src=\"https://codecov.io/gh/whitemech/plan4past/branch/main/graph/badge.svg\">\n  </a>\n  <a href=\"https://github.com/whitemech/plan4past/blob/main/LICENSE\">\n    <img alt=\"GitHub\" src=\"https://img.shields.io/badge/license-LGPLv3%2B-blue\">\n  </a>\n</p>\n\n---\n\nClassical and FOND Planning for Pure-Past Linear Temporal Logic Goals.\n\n## Installation\n\n- from PyPI: \n\n```\npip install plan4past\n```\n\n- from source (`main` branch): \n\n```\npip install git+https://github.com/whitemech/Plan4Past.git\n```\n\nor, clone the repository and install:\n\n```\ngit clone https://github.com/whitemech/Plan4Past.git\ncd Plan4Past\npip install .\n```\n\n## Quickstart\n\nYou can use the `plan4past` package in two ways: as a library, and as a CLI tool.\n\n### As a library\nThis is an example of how you can encode a PPLTL goal formula into a PDDL domain and problem programmatically.\n\n```python\nfrom pathlib import Path\nfrom pddl.formatter import domain_to_string, problem_to_string\nfrom pddl.parser.domain import DomainParser\nfrom pddl.parser.problem import ProblemParser\nfrom pylogics.parsers import parse_pltl\nfrom plan4past.compiler import Compiler\n\nformula = \"on_b_a & O(ontable_c)\"\ndomain_parser = DomainParser()\nproblem_parser = ProblemParser()\n\ndomain = domain_parser(Path(\"examples/pddl/domain.pddl\").read_text(encoding=\"utf-8\"))\nproblem = problem_parser(Path(\"examples/pddl/p-0.pddl\").read_text(encoding=\"utf-8\"))\ngoal = parse_pltl(formula)\n\ncompiler = Compiler(domain, problem, goal)\ncompiler.compile()\ncompiled_domain, compiled_problem = compiler.result\n\ntry:\n    with open(\"./new-domain.pddl\", \"w+\", encoding=\"utf-8\") as d:\n        d.write(domain_to_string(compiled_domain))\n    with open(\"./new-problem.pddl\", \"w+\", encoding=\"utf-8\") as p:\n        p.write(problem_to_string(compiled_problem))\nexcept Exception as e:\n    raise IOError(\n        \"[ERROR]: Something wrong occurred while writing the compiled domain and problem.\"\n    ) from e\n```\n\nBy executing the code above, you will obtain a `new-domain.pddl` as well as a `new-problem.pddl` in output.\n\n### As a CLI tool\n\nThe package can also be used as a CLI tool. The supported command is:\n\n```\nplan4past -d DOMAIN_FILE -p PROBLEM_FILE -g \"PPLTL_FORMULA\" [-m MAPPING] \n```\nwhere `DOMAIN_FILE` and `PROBLEM_FILE` are the PDDL domain and problem files, respectively, and `PPLTL_FORMULA` is the \ngoal formula expressed in Pure-Past Linear Temporal Logic. \nThe optional `MAPPING` file is a mapping between the PDDL objects and the PPLTL formula's atomic propositions.\n\nFor instance:\n```\nplan4past -d examples/pddl/domain.pddl -p examples/pddl/p-0.pddl -g \"ontable_c & O(on_b_a)\"\n```\n\n## Docker & Apptainer images\n\nA Docker image as well as an Apptainer image are available for Plan4Past.\n\n- To use Docker:\n`docker build -t plan4past .` and `docker run --rm -it plan4past`\n\n- To use Apptainer:\n```\napptainer build plan4past.sif plan4past.def\n\n# to launch the tool:\n./plan4past.sif -d examples/pddl/domain.pddl -p examples/pddl/p-0.pddl -g \"ontable_c & O(on_b_a)\"\n```\n\n\n## Development\n\nIf you want to contribute, set up your development environment as follows:\n\n- Intall [Poetry](https://python-poetry.org)\n- Clone the repository: `git clone https://github.com/whitemech/Plan4Past.git && cd Plan4Past`\n- Install the dependencies: `poetry shell && poetry install`\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## License\n\nPlan4Past is released under the GNU Lesser General Public License v3.0 or later (LGPLv3+).\n\nCopyright 2021 -- 2023 WhiteMech\n\n## Citing\n\nIf you use Plan4Past in your research, please consider citing the following paper:\n\n```\n@inproceedings{icaps2023bdffgs,\n  author       = {Luigi Bonassi and \n                  Giuseppe {De Giacomo} and \n                  Marco Favorito and \n                  Francesco Fuggitti and \n                  {Alfonso Emilio} Gerevini and \n                  Enrico Scala},\n  title        = {Planning for Temporally Extended Goals in Pure-Past Linear Temporal Logic},\n  booktitle    = {{ICAPS}},\n  volume       = {33},\n  url          = {https://ojs.aaai.org/index.php/ICAPS/article/view/27179},\n  doi          = {10.1609/icaps.v33i1.27179},\n  number       = {1},\n  month        = {Jul.},\n  pages        = {61-69},\n  year         = {2023},\n}\n```\n\n## Acknowledgements\n\nPlan4Past has been partially supported by the EU H2020 project AIPlan4EU (No. 101016442), the ERC-ADG WhiteMech \n(No. 834228), the EU ICT-48 2020 project TAILOR (No. 952215), the PRIN project RIPER (No. 20203FFYLK), and the PNRR MUR \nproject FAIR (No. PE0000013).\n\n",
    "bugtrack_url": null,
    "license": "LGPLv3+ license",
    "summary": "Classical and FOND Planning for Pure-Past Linear Temporal Logic Goals",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/whitemech/plan4past/issues",
        "Documentation": "https://whitemech.github.io/plan4past",
        "Homepage": "https://whitemech.github.io/plan4past",
        "Pull Requests": "https://github.com/whitemech/plan4past/pulls",
        "Repository": "https://github.com/whitemech/plan4past.git"
    },
    "split_keywords": [
        "automated planning",
        "temporally extended goals",
        "pure-past linear temporal logic"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c03c3e8655982a72af55cec34bba9a0cde220d940ca2dcb5d461250bb8c2a76b",
                "md5": "0306e0c89b34a3a5ef30918c3aaf09d4",
                "sha256": "8641a9f738e11d8c83f890b6e418b27f8ff5c192a81a01b87fc8658ab01d52c8"
            },
            "downloads": -1,
            "filename": "plan4past-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0306e0c89b34a3a5ef30918c3aaf09d4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<4.0",
            "size": 23074,
            "upload_time": "2023-07-15T23:37:23",
            "upload_time_iso_8601": "2023-07-15T23:37:23.058318Z",
            "url": "https://files.pythonhosted.org/packages/c0/3c/3e8655982a72af55cec34bba9a0cde220d940ca2dcb5d461250bb8c2a76b/plan4past-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e0da28b9d30aa731a8593f23a9297cd24f60537d149ca96dcdd7a48c21a51a69",
                "md5": "8364de8efa3293990e72b697322fb79e",
                "sha256": "9456a7705b8f4c3df62e34f59f9a551c45f887d145c5a7a40704f74a2769c310"
            },
            "downloads": -1,
            "filename": "plan4past-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8364de8efa3293990e72b697322fb79e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<4.0",
            "size": 15909,
            "upload_time": "2023-07-15T23:37:24",
            "upload_time_iso_8601": "2023-07-15T23:37:24.463471Z",
            "url": "https://files.pythonhosted.org/packages/e0/da/28b9d30aa731a8593f23a9297cd24f60537d149ca96dcdd7a48c21a51a69/plan4past-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-15 23:37:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "whitemech",
    "github_project": "plan4past",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "plan4past"
}
        
Elapsed time: 0.09959s