pddl-utils 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pddl_utils-0.0.1/LICENSE +21 -0
- pddl_utils-0.0.1/PKG-INFO +115 -0
- pddl_utils-0.0.1/README.md +99 -0
- pddl_utils-0.0.1/pddl_utils.egg-info/PKG-INFO +115 -0
- pddl_utils-0.0.1/pddl_utils.egg-info/SOURCES.txt +12 -0
- pddl_utils-0.0.1/pddl_utils.egg-info/dependency_links.txt +1 -0
- pddl_utils-0.0.1/pddl_utils.egg-info/requires.txt +1 -0
- pddl_utils-0.0.1/pddl_utils.egg-info/top_level.txt +1 -0
- pddl_utils-0.0.1/pddlutils/__init__.py +37 -0
- pddl_utils-0.0.1/pddlutils/grounding.py +95 -0
- pddl_utils-0.0.1/pddlutils/progression.py +0 -0
- pddl_utils-0.0.1/pddlutils/utils.py +0 -0
- pddl_utils-0.0.1/setup.cfg +4 -0
- pddl_utils-0.0.1/setup.py +25 -0
pddl_utils-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AI Planning
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pddl-utils
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Library of miscellaneous utilies to work with PDDL (both in Python and on the command line).
|
|
5
|
+
Home-page: https://github.com/AI-Planning/pddl-utils
|
|
6
|
+
Author: Christian Muise
|
|
7
|
+
Author-email: christian.muise@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: pddl
|
|
16
|
+
|
|
17
|
+
# pddl-utils
|
|
18
|
+
|
|
19
|
+
Library of miscellaneous utilies to work with PDDL (both in Python and on the command line).
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install pddl-utils
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Python
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import pddlutils as pu
|
|
33
|
+
|
|
34
|
+
# Extended wrapper of the pddl library.
|
|
35
|
+
domain, problem = pu.load('domain.pddl', 'problem.pddl')
|
|
36
|
+
|
|
37
|
+
# Alternatively, if you have a pddl dom,prob pair, you can wrap it using...
|
|
38
|
+
# domain, problem = pu.load(dom, prob)
|
|
39
|
+
|
|
40
|
+
# Set of (lifted) fluents and actions
|
|
41
|
+
domain.predicates
|
|
42
|
+
domain.actions
|
|
43
|
+
|
|
44
|
+
# Access a particular action or fluent or constant/object
|
|
45
|
+
a = domain.action['move']
|
|
46
|
+
f = domain.predicate['connected']
|
|
47
|
+
|
|
48
|
+
p1 = domain.constant['person1']
|
|
49
|
+
l1 = problem.object['loc1']
|
|
50
|
+
l2 = problem.object['loc2']
|
|
51
|
+
|
|
52
|
+
# Ground a predicate
|
|
53
|
+
f = pu.ground(f, l1, l2)
|
|
54
|
+
|
|
55
|
+
# Ground an action
|
|
56
|
+
ag = pu.ground(a, p1, l1, l2)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Planned Usage
|
|
60
|
+
|
|
61
|
+
### Python
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import pddlutils as pu
|
|
65
|
+
|
|
66
|
+
# Extended wrapper of the pddl library.
|
|
67
|
+
domain, problem = pu.load('domain.pddl', 'problem.pddl')
|
|
68
|
+
|
|
69
|
+
# Alternatively, if you have a pddl dom,prob pair, you can wrap it using...
|
|
70
|
+
# domain, problem = pu.load(dom, prob)
|
|
71
|
+
|
|
72
|
+
# Set of (lifted) fluents and actions
|
|
73
|
+
domain.predicates
|
|
74
|
+
domain.actions
|
|
75
|
+
|
|
76
|
+
# Access a particular action or fluent or constant/object
|
|
77
|
+
a = domain.action['move']
|
|
78
|
+
f = domain.predicate['connected']
|
|
79
|
+
|
|
80
|
+
p1 = domain.constant['person1']
|
|
81
|
+
l1 = problem.object['loc1']
|
|
82
|
+
l2 = problem.object['loc2']
|
|
83
|
+
|
|
84
|
+
# Ground a predicate
|
|
85
|
+
f = pu.ground(f, l1, l2)
|
|
86
|
+
|
|
87
|
+
# Ground an action
|
|
88
|
+
ag = pu.ground(a, p1, l1, l2)
|
|
89
|
+
|
|
90
|
+
# Ground an entire domain (actions and fluents replaced with type-specific ground versions)
|
|
91
|
+
gdom, gprob = pu.ground(domain, problem)
|
|
92
|
+
|
|
93
|
+
# Easy progression
|
|
94
|
+
s0 = problem.init
|
|
95
|
+
act = list(problem.actions)[0]
|
|
96
|
+
s1 = tl.progress(s0, act)
|
|
97
|
+
|
|
98
|
+
# Easy action/fluent lookup
|
|
99
|
+
act = problem.action('move loc1 loc2')
|
|
100
|
+
fluent = problem.fluent('connected loc1 loc2')
|
|
101
|
+
assert fluent == problem.fluent('(connected loc1 loc2)')
|
|
102
|
+
|
|
103
|
+
# parses plans from file, string, or list
|
|
104
|
+
plan = problem.parse_plan('plan.ipc')
|
|
105
|
+
plan = problem.parse_plan('(move loc1 loc2)\n(move loc2 loc3)')
|
|
106
|
+
plan = problem.parse_plan(['move loc1 loc2', 'move loc2 loc3'])
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### CLI
|
|
110
|
+
|
|
111
|
+
Progress the initial state through a plan, and create a new problem file with the final state reached.
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
$ planutils progress --domain domain.pddl --problem problem.pddl --plan plan.ipc --output new-problem.pddl
|
|
115
|
+
```
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# pddl-utils
|
|
2
|
+
|
|
3
|
+
Library of miscellaneous utilies to work with PDDL (both in Python and on the command line).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install pddl-utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Python
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import pddlutils as pu
|
|
17
|
+
|
|
18
|
+
# Extended wrapper of the pddl library.
|
|
19
|
+
domain, problem = pu.load('domain.pddl', 'problem.pddl')
|
|
20
|
+
|
|
21
|
+
# Alternatively, if you have a pddl dom,prob pair, you can wrap it using...
|
|
22
|
+
# domain, problem = pu.load(dom, prob)
|
|
23
|
+
|
|
24
|
+
# Set of (lifted) fluents and actions
|
|
25
|
+
domain.predicates
|
|
26
|
+
domain.actions
|
|
27
|
+
|
|
28
|
+
# Access a particular action or fluent or constant/object
|
|
29
|
+
a = domain.action['move']
|
|
30
|
+
f = domain.predicate['connected']
|
|
31
|
+
|
|
32
|
+
p1 = domain.constant['person1']
|
|
33
|
+
l1 = problem.object['loc1']
|
|
34
|
+
l2 = problem.object['loc2']
|
|
35
|
+
|
|
36
|
+
# Ground a predicate
|
|
37
|
+
f = pu.ground(f, l1, l2)
|
|
38
|
+
|
|
39
|
+
# Ground an action
|
|
40
|
+
ag = pu.ground(a, p1, l1, l2)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Planned Usage
|
|
44
|
+
|
|
45
|
+
### Python
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import pddlutils as pu
|
|
49
|
+
|
|
50
|
+
# Extended wrapper of the pddl library.
|
|
51
|
+
domain, problem = pu.load('domain.pddl', 'problem.pddl')
|
|
52
|
+
|
|
53
|
+
# Alternatively, if you have a pddl dom,prob pair, you can wrap it using...
|
|
54
|
+
# domain, problem = pu.load(dom, prob)
|
|
55
|
+
|
|
56
|
+
# Set of (lifted) fluents and actions
|
|
57
|
+
domain.predicates
|
|
58
|
+
domain.actions
|
|
59
|
+
|
|
60
|
+
# Access a particular action or fluent or constant/object
|
|
61
|
+
a = domain.action['move']
|
|
62
|
+
f = domain.predicate['connected']
|
|
63
|
+
|
|
64
|
+
p1 = domain.constant['person1']
|
|
65
|
+
l1 = problem.object['loc1']
|
|
66
|
+
l2 = problem.object['loc2']
|
|
67
|
+
|
|
68
|
+
# Ground a predicate
|
|
69
|
+
f = pu.ground(f, l1, l2)
|
|
70
|
+
|
|
71
|
+
# Ground an action
|
|
72
|
+
ag = pu.ground(a, p1, l1, l2)
|
|
73
|
+
|
|
74
|
+
# Ground an entire domain (actions and fluents replaced with type-specific ground versions)
|
|
75
|
+
gdom, gprob = pu.ground(domain, problem)
|
|
76
|
+
|
|
77
|
+
# Easy progression
|
|
78
|
+
s0 = problem.init
|
|
79
|
+
act = list(problem.actions)[0]
|
|
80
|
+
s1 = tl.progress(s0, act)
|
|
81
|
+
|
|
82
|
+
# Easy action/fluent lookup
|
|
83
|
+
act = problem.action('move loc1 loc2')
|
|
84
|
+
fluent = problem.fluent('connected loc1 loc2')
|
|
85
|
+
assert fluent == problem.fluent('(connected loc1 loc2)')
|
|
86
|
+
|
|
87
|
+
# parses plans from file, string, or list
|
|
88
|
+
plan = problem.parse_plan('plan.ipc')
|
|
89
|
+
plan = problem.parse_plan('(move loc1 loc2)\n(move loc2 loc3)')
|
|
90
|
+
plan = problem.parse_plan(['move loc1 loc2', 'move loc2 loc3'])
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### CLI
|
|
94
|
+
|
|
95
|
+
Progress the initial state through a plan, and create a new problem file with the final state reached.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
$ planutils progress --domain domain.pddl --problem problem.pddl --plan plan.ipc --output new-problem.pddl
|
|
99
|
+
```
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pddl-utils
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Library of miscellaneous utilies to work with PDDL (both in Python and on the command line).
|
|
5
|
+
Home-page: https://github.com/AI-Planning/pddl-utils
|
|
6
|
+
Author: Christian Muise
|
|
7
|
+
Author-email: christian.muise@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: pddl
|
|
16
|
+
|
|
17
|
+
# pddl-utils
|
|
18
|
+
|
|
19
|
+
Library of miscellaneous utilies to work with PDDL (both in Python and on the command line).
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install pddl-utils
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Python
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import pddlutils as pu
|
|
33
|
+
|
|
34
|
+
# Extended wrapper of the pddl library.
|
|
35
|
+
domain, problem = pu.load('domain.pddl', 'problem.pddl')
|
|
36
|
+
|
|
37
|
+
# Alternatively, if you have a pddl dom,prob pair, you can wrap it using...
|
|
38
|
+
# domain, problem = pu.load(dom, prob)
|
|
39
|
+
|
|
40
|
+
# Set of (lifted) fluents and actions
|
|
41
|
+
domain.predicates
|
|
42
|
+
domain.actions
|
|
43
|
+
|
|
44
|
+
# Access a particular action or fluent or constant/object
|
|
45
|
+
a = domain.action['move']
|
|
46
|
+
f = domain.predicate['connected']
|
|
47
|
+
|
|
48
|
+
p1 = domain.constant['person1']
|
|
49
|
+
l1 = problem.object['loc1']
|
|
50
|
+
l2 = problem.object['loc2']
|
|
51
|
+
|
|
52
|
+
# Ground a predicate
|
|
53
|
+
f = pu.ground(f, l1, l2)
|
|
54
|
+
|
|
55
|
+
# Ground an action
|
|
56
|
+
ag = pu.ground(a, p1, l1, l2)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Planned Usage
|
|
60
|
+
|
|
61
|
+
### Python
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import pddlutils as pu
|
|
65
|
+
|
|
66
|
+
# Extended wrapper of the pddl library.
|
|
67
|
+
domain, problem = pu.load('domain.pddl', 'problem.pddl')
|
|
68
|
+
|
|
69
|
+
# Alternatively, if you have a pddl dom,prob pair, you can wrap it using...
|
|
70
|
+
# domain, problem = pu.load(dom, prob)
|
|
71
|
+
|
|
72
|
+
# Set of (lifted) fluents and actions
|
|
73
|
+
domain.predicates
|
|
74
|
+
domain.actions
|
|
75
|
+
|
|
76
|
+
# Access a particular action or fluent or constant/object
|
|
77
|
+
a = domain.action['move']
|
|
78
|
+
f = domain.predicate['connected']
|
|
79
|
+
|
|
80
|
+
p1 = domain.constant['person1']
|
|
81
|
+
l1 = problem.object['loc1']
|
|
82
|
+
l2 = problem.object['loc2']
|
|
83
|
+
|
|
84
|
+
# Ground a predicate
|
|
85
|
+
f = pu.ground(f, l1, l2)
|
|
86
|
+
|
|
87
|
+
# Ground an action
|
|
88
|
+
ag = pu.ground(a, p1, l1, l2)
|
|
89
|
+
|
|
90
|
+
# Ground an entire domain (actions and fluents replaced with type-specific ground versions)
|
|
91
|
+
gdom, gprob = pu.ground(domain, problem)
|
|
92
|
+
|
|
93
|
+
# Easy progression
|
|
94
|
+
s0 = problem.init
|
|
95
|
+
act = list(problem.actions)[0]
|
|
96
|
+
s1 = tl.progress(s0, act)
|
|
97
|
+
|
|
98
|
+
# Easy action/fluent lookup
|
|
99
|
+
act = problem.action('move loc1 loc2')
|
|
100
|
+
fluent = problem.fluent('connected loc1 loc2')
|
|
101
|
+
assert fluent == problem.fluent('(connected loc1 loc2)')
|
|
102
|
+
|
|
103
|
+
# parses plans from file, string, or list
|
|
104
|
+
plan = problem.parse_plan('plan.ipc')
|
|
105
|
+
plan = problem.parse_plan('(move loc1 loc2)\n(move loc2 loc3)')
|
|
106
|
+
plan = problem.parse_plan(['move loc1 loc2', 'move loc2 loc3'])
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### CLI
|
|
110
|
+
|
|
111
|
+
Progress the initial state through a plan, and create a new problem file with the final state reached.
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
$ planutils progress --domain domain.pddl --problem problem.pddl --plan plan.ipc --output new-problem.pddl
|
|
115
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
pddl_utils.egg-info/PKG-INFO
|
|
5
|
+
pddl_utils.egg-info/SOURCES.txt
|
|
6
|
+
pddl_utils.egg-info/dependency_links.txt
|
|
7
|
+
pddl_utils.egg-info/requires.txt
|
|
8
|
+
pddl_utils.egg-info/top_level.txt
|
|
9
|
+
pddlutils/__init__.py
|
|
10
|
+
pddlutils/grounding.py
|
|
11
|
+
pddlutils/progression.py
|
|
12
|
+
pddlutils/utils.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pddl
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pddlutils
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
from pddl import parse_domain, parse_problem
|
|
3
|
+
|
|
4
|
+
from pddlutils.grounding import ground
|
|
5
|
+
|
|
6
|
+
__all__ = ['load', 'ground']
|
|
7
|
+
|
|
8
|
+
def load(_domain, _problem):
|
|
9
|
+
|
|
10
|
+
# If string, load from file. Otherwise, assume it's already loaded
|
|
11
|
+
if isinstance(_domain, str):
|
|
12
|
+
domain = parse_domain(_domain)
|
|
13
|
+
else:
|
|
14
|
+
domain = _domain
|
|
15
|
+
|
|
16
|
+
if isinstance(_problem, str):
|
|
17
|
+
problem = parse_problem(_problem)
|
|
18
|
+
else:
|
|
19
|
+
problem = _problem
|
|
20
|
+
|
|
21
|
+
domain.action = {}
|
|
22
|
+
for action in domain.actions:
|
|
23
|
+
domain.action[action.name] = action
|
|
24
|
+
|
|
25
|
+
domain.predicate = {}
|
|
26
|
+
for predicate in domain.predicates:
|
|
27
|
+
domain.predicate[predicate.name] = predicate
|
|
28
|
+
|
|
29
|
+
domain.constant = {}
|
|
30
|
+
for constant in domain.constants:
|
|
31
|
+
domain.constant[constant.name] = constant
|
|
32
|
+
|
|
33
|
+
problem.object = {}
|
|
34
|
+
for obj in problem.objects:
|
|
35
|
+
problem.object[obj.name] = obj
|
|
36
|
+
|
|
37
|
+
return (domain, problem)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
|
|
2
|
+
from pddl.logic import Predicate
|
|
3
|
+
from pddl.logic.base import BinaryOp, UnaryOp
|
|
4
|
+
from pddl.core import Action, Domain, Problem
|
|
5
|
+
|
|
6
|
+
def ground(lifted, *args):
|
|
7
|
+
"""
|
|
8
|
+
Ground a lifted domain, action, or predicate with the given arguments.
|
|
9
|
+
|
|
10
|
+
Parameters
|
|
11
|
+
----------
|
|
12
|
+
lifted : Action or Predicate
|
|
13
|
+
Lifted action or predicate to ground.
|
|
14
|
+
args : list
|
|
15
|
+
List of arguments to ground the lifted action or predicate with.
|
|
16
|
+
|
|
17
|
+
Returns
|
|
18
|
+
-------
|
|
19
|
+
Action or Predicate
|
|
20
|
+
Grounded domain, action, or predicate.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
if isinstance(lifted, Action):
|
|
24
|
+
return _ground_action(lifted, args)
|
|
25
|
+
elif isinstance(lifted, Predicate):
|
|
26
|
+
return _ground_predicate(lifted, args)
|
|
27
|
+
elif isinstance(lifted, Domain):
|
|
28
|
+
assert len(args) == 1 and isinstance(args[0], Problem), "A domain must be grounded with a problem"
|
|
29
|
+
raise NotImplementedError("Grounding of a domain is not yet implemented")
|
|
30
|
+
else:
|
|
31
|
+
raise ValueError("Unknown type of lifted object")
|
|
32
|
+
|
|
33
|
+
def _recursive_ground(lifted, var2arg):
|
|
34
|
+
if isinstance(lifted, Predicate):
|
|
35
|
+
args = [var2arg[term] for term in lifted.terms]
|
|
36
|
+
return _ground_predicate(lifted, args)
|
|
37
|
+
elif isinstance(lifted, BinaryOp):
|
|
38
|
+
return lifted.__class__(*[_recursive_ground(l, var2arg) for l in lifted.operands])
|
|
39
|
+
elif isinstance(lifted, UnaryOp):
|
|
40
|
+
return lifted.__class__(_recursive_ground(lifted.argument, var2arg))
|
|
41
|
+
else:
|
|
42
|
+
raise NotImplementedError(f"Grounding of {type(lifted)} is not yet implemented")
|
|
43
|
+
|
|
44
|
+
def _ground_action(action, args):
|
|
45
|
+
"""
|
|
46
|
+
Ground an action with the given arguments.
|
|
47
|
+
|
|
48
|
+
Parameters
|
|
49
|
+
----------
|
|
50
|
+
action : Action
|
|
51
|
+
Action to ground.
|
|
52
|
+
args : list
|
|
53
|
+
List of arguments to ground the action with.
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
-------
|
|
57
|
+
Action
|
|
58
|
+
Grounded action.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
assert len(action.terms) == len(args), "Number of arguments must match"
|
|
62
|
+
|
|
63
|
+
for i in range(len(action.terms)):
|
|
64
|
+
assert args[i].type_tag in action.terms[i].type_tags, f"Type of arguments must match: {args[i].type_tag} not in {action.parameters[i].type_tags}"
|
|
65
|
+
|
|
66
|
+
var2arg = {var: arg for var, arg in zip(action.parameters, args)}
|
|
67
|
+
aname = action.name + '_' + '_'.join([arg.name for arg in args])
|
|
68
|
+
precond = _recursive_ground(action.precondition, var2arg)
|
|
69
|
+
effect = _recursive_ground(action.effect, var2arg)
|
|
70
|
+
|
|
71
|
+
return Action(aname, [], precond, effect)
|
|
72
|
+
|
|
73
|
+
def _ground_predicate(predicate, args):
|
|
74
|
+
"""
|
|
75
|
+
Ground a predicate with the given arguments.
|
|
76
|
+
|
|
77
|
+
Parameters
|
|
78
|
+
----------
|
|
79
|
+
predicate : Predicate
|
|
80
|
+
Predicate to ground.
|
|
81
|
+
args : list
|
|
82
|
+
List of arguments to ground the predicate with.
|
|
83
|
+
|
|
84
|
+
Returns
|
|
85
|
+
-------
|
|
86
|
+
Predicate
|
|
87
|
+
Grounded predicate.
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
assert predicate.arity == len(args), "Number of arguments must match"
|
|
91
|
+
|
|
92
|
+
for i in range(predicate.arity):
|
|
93
|
+
assert args[i].type_tag in predicate.terms[i].type_tags, f"Type of arguments must match: {args[i].type_tag} not in {predicate.terms[i].type_tags}"
|
|
94
|
+
|
|
95
|
+
return Predicate(predicate.name, *args)
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
from setuptools import find_packages, setup
|
|
3
|
+
|
|
4
|
+
with open("README.md", "r") as fh:
|
|
5
|
+
long_description = fh.read()
|
|
6
|
+
|
|
7
|
+
setup(
|
|
8
|
+
name="pddl-utils",
|
|
9
|
+
version="0.0.1",
|
|
10
|
+
packages=find_packages(exclude=["tests"]),
|
|
11
|
+
description="Library of miscellaneous utilies to work with PDDL (both in Python and on the command line).",
|
|
12
|
+
long_description=long_description,
|
|
13
|
+
long_description_content_type="text/markdown",
|
|
14
|
+
author="Christian Muise",
|
|
15
|
+
author_email="christian.muise@gmail.com",
|
|
16
|
+
install_requires=["pddl"],
|
|
17
|
+
license="MIT",
|
|
18
|
+
url="https://github.com/AI-Planning/pddl-utils",
|
|
19
|
+
classifiers=[
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
],
|
|
24
|
+
python_requires=">=3.10",
|
|
25
|
+
)
|