planning-structs 0.1.0__tar.gz → 0.2.0__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.
- {planning_structs-0.1.0 → planning_structs-0.2.0}/CHANGELOG.md +7 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/CITATION.cff +1 -1
- {planning_structs-0.1.0 → planning_structs-0.2.0}/PKG-INFO +8 -1
- {planning_structs-0.1.0 → planning_structs-0.2.0}/README.md +7 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/pyproject.toml +1 -1
- {planning_structs-0.1.0 → planning_structs-0.2.0}/src/planning_structs/trace.py +14 -4
- planning_structs-0.2.0/tests/test_trace.py +24 -0
- planning_structs-0.1.0/tests/test_trace.py +0 -15
- {planning_structs-0.1.0 → planning_structs-0.2.0}/.gitignore +0 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/LICENSE +0 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/src/planning_structs/__init__.py +0 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/src/planning_structs/action_model.py +0 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/src/planning_structs/domain.py +0 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/src/planning_structs/instance.py +0 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/tests/conftest.py +0 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/tests/helpers.py +0 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/tests/test_action_model.py +0 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/tests/test_domain.py +0 -0
- {planning_structs-0.1.0 → planning_structs-0.2.0}/tests/test_instance.py +0 -0
|
@@ -6,6 +6,13 @@ All notable changes to this package are documented here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.2.0] - 2026-11-06
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- `Trace.proposition_order` and `Trace.action_order` (optional): the data's own order of the entries
|
|
13
|
+
of vector states, and of the actions that integer actions refer to. Both default to `None`, so
|
|
14
|
+
existing code is unaffected.
|
|
15
|
+
|
|
9
16
|
## [0.1.0] - 2026-11-06
|
|
10
17
|
|
|
11
18
|
First release, extracted from `rosame` 0.1.0 (`rosame.planning_structs`), where these structures were
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: planning-structs
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Typed STRIPS planning structures: domains, groundings, symbolic action models and traces
|
|
5
5
|
Project-URL: Homepage, https://github.com/xikaioliver/planning-structs
|
|
6
6
|
Project-URL: Issues, https://github.com/xikaioliver/planning-structs/issues
|
|
@@ -61,6 +61,13 @@ print(model)
|
|
|
61
61
|
trace = Trace(objects=[("r1", "room"), ("r2", "room")],
|
|
62
62
|
states=[["(robot-at r1)"], ["(robot-at r2)"]],
|
|
63
63
|
actions=["(move r1 r2)"])
|
|
64
|
+
|
|
65
|
+
# Data in its own order: name the entries of vector states and the actions integers refer to.
|
|
66
|
+
trace = Trace(objects=[("r1", "room"), ("r2", "room")],
|
|
67
|
+
states=[[1.0, 0.0], [0.0, 1.0]],
|
|
68
|
+
actions=[0],
|
|
69
|
+
proposition_order=["(robot-at r1)", "(robot-at r2)"],
|
|
70
|
+
action_order=["(move r1 r2)", "(move r2 r1)"])
|
|
64
71
|
```
|
|
65
72
|
|
|
66
73
|
## Conventions
|
|
@@ -39,6 +39,13 @@ print(model)
|
|
|
39
39
|
trace = Trace(objects=[("r1", "room"), ("r2", "room")],
|
|
40
40
|
states=[["(robot-at r1)"], ["(robot-at r2)"]],
|
|
41
41
|
actions=["(move r1 r2)"])
|
|
42
|
+
|
|
43
|
+
# Data in its own order: name the entries of vector states and the actions integers refer to.
|
|
44
|
+
trace = Trace(objects=[("r1", "room"), ("r2", "room")],
|
|
45
|
+
states=[[1.0, 0.0], [0.0, 1.0]],
|
|
46
|
+
actions=[0],
|
|
47
|
+
proposition_order=["(robot-at r1)", "(robot-at r2)"],
|
|
48
|
+
action_order=["(move r1 r2)", "(move r2 r1)"])
|
|
42
49
|
```
|
|
43
50
|
|
|
44
51
|
## Conventions
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "planning-structs"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.2.0"
|
|
8
8
|
description = "Typed STRIPS planning structures: domains, groundings, symbolic action models and traces"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -10,7 +10,7 @@ Atoms and actions may be written "(in s1 r2)", "in s1 r2", ("in", "s1", "r2") or
|
|
|
10
10
|
from __future__ import annotations
|
|
11
11
|
|
|
12
12
|
from dataclasses import dataclass
|
|
13
|
-
from typing import Any, Sequence, Tuple
|
|
13
|
+
from typing import Any, Optional, Sequence, Tuple
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
@dataclass
|
|
@@ -20,13 +20,23 @@ class Trace:
|
|
|
20
20
|
objects [(name, type), ...]: every object the states and actions mention, including domain
|
|
21
21
|
constants.
|
|
22
22
|
states T + 1 states. Each state is an iterable of true atoms, a dict {atom: probability} (atoms
|
|
23
|
-
not listed have probability 0), or a vector of probabilities
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
not listed have probability 0), or a vector of probabilities; a whole [T + 1, P] array
|
|
24
|
+
is also accepted. Vector entries follow `proposition_order` if given, otherwise the
|
|
25
|
+
propositions of Instance(domain, objects) in their order.
|
|
26
|
+
actions T actions, each an action (e.g. "(move r1 r2)"), an integer, or None for an unknown
|
|
27
|
+
action. Integers index `action_order` if given, otherwise Instance(domain, objects).actions.
|
|
28
|
+
|
|
29
|
+
Optional, for data that comes in its own order:
|
|
30
|
+
proposition_order the atoms naming the entries of vector states, in the data's order.
|
|
31
|
+
action_order the actions that integer actions refer to, in the data's order.
|
|
32
|
+
|
|
33
|
+
These fields only describe the data; programs that consume traces resolve and validate them.
|
|
26
34
|
"""
|
|
27
35
|
objects: Sequence[Tuple[str, str]]
|
|
28
36
|
states: Any
|
|
29
37
|
actions: Sequence[Any]
|
|
38
|
+
proposition_order: Optional[Sequence[Any]] = None
|
|
39
|
+
action_order: Optional[Sequence[Any]] = None
|
|
30
40
|
|
|
31
41
|
def __post_init__(self) -> None:
|
|
32
42
|
if hasattr(self.states, "__len__") and len(self.states) != len(self.actions) + 1:
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from planning_structs import Trace
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_trace_forms_and_length():
|
|
7
|
+
objs = [("r1", "room"), ("r2", "room")]
|
|
8
|
+
t = Trace(objs, [["(robot-at r1)"], {"(robot-at r2)": 0.9}], ["(move r1 r2)"])
|
|
9
|
+
assert t.length == 1
|
|
10
|
+
assert Trace(objs, [["(robot-at r1)"], ["(robot-at r1)"]], [None]).length == 1 # unknown action
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_states_must_be_one_more_than_actions():
|
|
14
|
+
with pytest.raises(ValueError):
|
|
15
|
+
Trace([("r1", "room")], [["(robot-at r1)"]], ["(move r1 r2)"])
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_optional_orders_default_to_none_and_are_kept():
|
|
19
|
+
objs = [("r1", "room"), ("r2", "room")]
|
|
20
|
+
plain = Trace(objs, [["(robot-at r1)"], ["(robot-at r2)"]], ["(move r1 r2)"])
|
|
21
|
+
assert plain.proposition_order is None and plain.action_order is None
|
|
22
|
+
ordered = Trace(objs, [[1.0, 0.0], [0.0, 1.0]], [0],
|
|
23
|
+
proposition_order=["(robot-at r1)", "(robot-at r2)"], action_order=["(move r1 r2)"])
|
|
24
|
+
assert ordered.proposition_order == ["(robot-at r1)", "(robot-at r2)"] and ordered.action_order == ["(move r1 r2)"]
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from planning_structs import Trace
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def test_trace_forms_and_length():
|
|
7
|
-
objs = [("r1", "room"), ("r2", "room")]
|
|
8
|
-
t = Trace(objs, [["(robot-at r1)"], {"(robot-at r2)": 0.9}], ["(move r1 r2)"])
|
|
9
|
-
assert t.length == 1
|
|
10
|
-
assert Trace(objs, [["(robot-at r1)"], ["(robot-at r1)"]], [None]).length == 1 # unknown action
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_states_must_be_one_more_than_actions():
|
|
14
|
-
with pytest.raises(ValueError):
|
|
15
|
-
Trace([("r1", "room")], [["(robot-at r1)"]], ["(move r1 r2)"])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|