Planning Graph for AI Planning
Project description
planning-graph
Planning Graph for AI Planning in Python
About
This library implements Planning Graph and its Planner that can be used to solve STRIPS-like AI Planning Problems using PDDL.
When passed the domain and problem representations in PDDL, the library returns Solution Plan if any.
Documentation
If you are interested in understanding the Planning Graph, please read my post at https://towardsdatascience.com/improving-classical-ai-planning-complexity-with-planning-graph-c63d47f87018
Installation
pip install planning-graph
or, you can clone this repository
Example
PDDL for representing planning domain and problem
The Dock-Worker Robots Domain and Problem are provided in the domain directory. You can create your own PDDL files, or you can download from the internet.
Create a Planning Graph from PDDL
from planning_graph.planning_graph import PlanningGraph
planning_graph = PlanningGraph('domain/dock-worker-robot-domain.pddl',
'domain/dock-worker-robot-problem.pddl')
graph = planning_graph.create(max_num_of_levels=10)
planning_graph.create() returns a Graph object if the goal state is achieved, or the maximum number of levels have been reached.
Create visualization
If you want to visualize the generated graph you can set visualize=True, by default it is set to False.
from planning_graph.planning_graph import PlanningGraph
planning_graph = PlanningGraph('domain/dock-worker-robot-domain.pddl',
'domain/dock-worker-robot-problem.pddl',
visualize=True)
graph = planning_graph.create(max_num_of_levels=10)
graph.visualize_png("generated_graph.png")
the result looks like the following:
Find a Solution Plan
To find a solution plan you simply have to create a Planner and pass the arguments it requires.
from planning_graph.planning_graph import PlanningGraph
from planning_graph.planning_graph_planner import GraphPlanner
planning_graph = PlanningGraph('domain/dock-worker-robot-domain.pddl',
'domain/dock-worker-robot-problem.pddl')
graph = planning_graph.create(max_num_of_levels=10)
goal = planning_graph.goal
graph_planner = GraphPlanner()
layered_plan = graph_planner.plan(graph, goal)
it returns a layered plan if the solution exists, otherwise, it returns None.
pddlpy
pddlpy included in this repo is the work of Hernán M. Foffani, it is copied from here. It is copied because it won't work when installed as a package due to wrong version of antlr4 package. There are no changes made to it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file planning-graph-0.0.1.tar.gz
.
File metadata
- Download URL: planning-graph-0.0.1.tar.gz
- Upload date:
- Size: 43.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53d6a58fef2c0fbf00a1b1a5d7945e98ec7a2b1a1e38463b6bdc5d54a01b2a3b |
|
MD5 | 40fe4996c8ffa362e778fc06e5795926 |
|
BLAKE2b-256 | 574c657b3cb1f051af24db38407e42aee99c3caabf6ad3ff7487a5aca8446275 |
File details
Details for the file planning_graph-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: planning_graph-0.0.1-py3-none-any.whl
- Upload date:
- Size: 50.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 022b709bfd4a4870d9c4f5ecb0391aeb8a3fda1a69d279dc65db0471058747f0 |
|
MD5 | a82417ff046909ed2372a3214f822a1e |
|
BLAKE2b-256 | 7f06201c214a2faf7caa7359ef08168a19d6745f87e928c8a12c1fde4a3d7900 |