https://github.com/apla-toolbox/pythonpddl
π§π A PDDL Planner in Python partially wrapping PDDL.jl using JuliaPy
https://github.com/apla-toolbox/pythonpddl
artificial-intelligence astar automated-planning dijsktra julia juliapy pddl planner planners pyjulia python
Last synced: 10 days ago
JSON representation
π§π A PDDL Planner in Python partially wrapping PDDL.jl using JuliaPy
- Host: GitHub
- URL: https://github.com/apla-toolbox/pythonpddl
- Owner: APLA-Toolbox
- License: apache-2.0
- Created: 2020-12-18T22:45:06.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-27T22:45:11.000Z (2 months ago)
- Last Synced: 2025-02-28T07:29:39.636Z (2 months ago)
- Topics: artificial-intelligence, astar, automated-planning, dijsktra, julia, juliapy, pddl, planner, planners, pyjulia, python
- Language: Python
- Homepage:
- Size: 1.59 MB
- Stars: 31
- Watchers: 2
- Forks: 3
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: docs/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![]()
# Python PDDL
β¨ A Python wrapper using JuliaPy for the PDDL.jl parser package and implementing its own planners. β¨


[](https://codecov.io/gh/APLA-Toolbox/PythonPDDL)
[](https://www.codefactor.io/repository/github/apla-toolbox/pythonpddl)
[](http://isitmaintained.com/project/APLA-Toolbox/PythonPDDL "Percentage of issues still open")
[](https://github.com/Apla-Toolbox/PythonPDDL/blob/master/LICENSE)
[](https://GitHub.com/Apla-Toolbox/PythonPDDL/graphs/contributors/)

[](https://pypi.python.org/pypi/jupyddl/)
[Report Bug](https://github.com/APLA-Toolbox/PythonPDDL/issues) Β· [Request Feature](https://github.com/APLA-Toolbox/PythonPDDL/issues)Loved the project? Please consider [donating](https://www.buymeacoffee.com/dq01aOE) to help it improve!
## Features π±
- β¨ Built to be expanded: easy to add new planners
- π₯οΈ Supported on MacOS and Ubuntu
- π Built with Julia and Python
- π Uninformed Planners (DFS, BFS)
- π§ Informed Planners (Dijkstra, A*, Greedy Best First)
- π Several general purpose heuristics (Goal Count, Delete Relaxation [Hmax, Hadd], Critical Path [H1, H2, H3], Relaxed Critical Path [H1, H2, H3])
- π» Maintained (Incoming: Landmarks Heuristics...)## Docker π
You can also use the project in a docker container using [docker-pythonpddl](https://github.com/APLA-Toolbox/docker-pythonpddl)
## Install πΎ
- Install Python (3.7.5 is the tested version)
- Install Julia
```bash
$ wget https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.2-linux-x86_64.tar.gz
$ tar -xvzf julia-1.5.2-linux-x86_64.tar.gz
$ sudo cp -r julia-1.5.2 /opt/
$ sudo ln -s /opt/julia-1.5.2/bin/julia /usr/local/bin/julia
```- Install Julia dependencies
```bash
$ julia --color=yes -e 'using Pkg; Pkg.add(Pkg.PackageSpec(path="https://github.com/APLA-Toolbox/PDDL.jl"))'
$ julia --color=yes -e 'using Pkg; Pkg.add(Pkg.PackageSpec(path="https://github.com/JuliaPy/PyCall.jl"))'
```- Package installation (only if used as library, not needed to run the scripts)
```bash
$ python3 -m pip install --upgrade pip
$ python3 -m pip install jupyddl
```## IPC Script βοΈ
- Clone the project :
```shell
$ git clone https://github.com/APLA-Toolbox/PythonPDDL
$ cd PythonPDDL
$ python3 -m pip install -r requirements.txt
$ git submodule update --init // Only if you need PDDL files for testing
```- Run the script :
```shell
$ cd scripts/
$ python ipc.py "path_to_domain.pddl" "path_to_problem.pddl" "path_to_desired_output_file"
```The output file will show the path with a list of state, the path with a list of action and the metrics proposed by IPC2018.
## Basic Usage π
If using the jupyddl pip package:
- If you want to use the data analysis tool, create a pddl-examples folder with pddl instances subfolders containing "problem.pddl" and "domain.pddl". (refer to APLA-Toolbox/pddl-examples)
If you want to use it by cloning the project:
```shell
$ git clone https://github.com/APLA-Toolbox/PythonPDDL
$ cd PythonPDDL
$ python3 -m pip install -r requirements.txt
$ git submodule update --init
```You should have a `pddl-examples` folder containing PDDL instances.
### AutomatedPlanner Class πΊοΈ
```python
from jupyddl import AutomatedPlanner # takes some time because it has to instantiate the Julia interface
apl = AutomatedPlanner("pddl-examples/dinner/domain.pddl", "pddl-examples/dinner/problem.pddl)apl.available_heuristics
["basic/zero", "basic/goal_count", "delete_relaxation/h_max", "delete_relaxation/h_add"]apl.initial_state
actions = apl.available_actions(apl.initial_state)
[, , , , , ]apl.satisfies(apl.problem.goal, apl.initial_state)
Falseapl.transition(apl.initial_state, actions[0])
path = apl.breadth_first_search() # computes path ([]State) with BFS
print(apl.get_state_def_from_path(path))
[, , ]print(apl.get_actions_from_path(path))
[, , ]
```### DataAnalyst (more like Viz) Class π
Make sure you have a pddl-examples folder where you run your environment that contains independent folders with "domain.pddl" and "problem.pddl" files, with those standard names. ( if you didn't generate with git submodule update )
```python
from jupyddl import DataAnalystda = DataAnalyst()
da.plot_astar() # plots complexity statistics for all the problem.pddl/domain.pddl couples in the pddl-examples/ folderda.plot_astar(problem="pddl-examples/dinner/problem.pddl", domain="pddl-examples/dinner/domain.pddl") # scatter complexity statistics for the provided pddl
da.plot_astar(heuristic_key="basic/zero") # use h=0 instead of goal_count for your computation
da.plot_dfs() # same as astar
da.comparative_data_plot() # Run all planners on the pddl-examples folder and plots them on the same figure, data is stored in a data.json file
da.comparative_data_plot(astar=False) # Exclude astar from the comparative plot
da.comparative_data_plot(heuristic_key="basic/zero") # use zero heuristic for h based planners
da.comparative_data_plot(collect_new_data=False) # uses data.json to plot the data
da.comparative_astar_heuristic_plot() # compare results of astar with all available heuristics
```## Cite π°
If you use the project in your work, please consider citing it with:
```
@misc{https://doi.org/10.13140/rg.2.2.22418.89282,
doi = {10.13140/RG.2.2.22418.89282},
url = {http://rgdoi.net/10.13140/RG.2.2.22418.89282},
author = {Erwin Lejeune},
language = {en},
title = {Jupyddl, an extensible python library for PDDL planning and parsing},
publisher = {Unpublished},
year = {2021}
}
```List of publications & preprints using `jupyddl` (please open a pull request to add missing entries):
* [name](link) (month year)
## Contribute π
Please see `docs/CONTRIBUTING.md` for more details on contributing!
## Maintainers βοΈ- Erwin Lejeune
- Sampreet Sarkar