-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples.py
132 lines (94 loc) · 4.79 KB
/
examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import dlplan
from dlplan.policy import *
import src.transition_system as ts
# TODO absolute/relative paths for file reading
base_path = ""
class FromFile:
def __init__(self, domain_file: str, instance_file: str):
dproblem = ts.tarski.load_domain(base_path + domain_file)
iproblem = ts.tarski.load_instance(base_path + domain_file, base_path + instance_file)
self._dproblem = dproblem
self._iproblem = iproblem
self._instance = ts.conversions.dlinstance_from_tarski(dproblem, iproblem)
self.transition_system = ts.tarski.tarski_to_transition_system(self._iproblem)
self.dl_states = [ts.dlplan.dlstate_from_state(s, self._instance) for s in self.transition_system.states]
#self.tarski_system: ts.tarski.TarskiTransitionSystem = ts.tarski.from_instance(self._iproblem)
#self.dl_system: ts.dlplan.DLTransitionModel = ts.conversions.tarski_to_dl_system(self.tarski_system, self._instance)
"""
def tarski_system(self) -> ts.tarski.TarskiTransitionSystem:
return ts.tarski.from_instance(self._iproblem)
"""
def factory(self) -> dlplan.core.SyntacticElementFactory:
return dlplan.core.SyntacticElementFactory(self._instance.get_vocabulary_info())
"""
def dl_system(self) -> ts.dlplan.DLTransitionModel:
return ts.conversions.tarski_to_dl_system(self.tarski_system(), self._instance)
"""
def read_sketch(self, file) -> Policy:
with open(base_path + file, "r") as f:
sketch = PolicyReader().read("\n".join(f.readlines()), PolicyBuilder(), self.factory())
return sketch
class BlocksOn(FromFile):
def __init__(self, instance_file="domains/blocks_4_on/p-3-0.pddl"):
super().__init__("domains/blocks_4_on/domain.pddl", instance_file)
def sketch_0(self) -> Policy:
"""
{} → {b1}
{} → {n0↓}
{¬b0} → {b1=, n0=}
:return:
"""
return self.read_sketch("drexler_sketches/blocks-on/blocks-on_0.txt")
def sketch_1(self):
return self.read_sketch("drexler_sketches/blocks-on/blocks-on_1.txt")
def sketch_2(self):
return self.read_sketch("drexler_sketches/blocks-on/blocks-on_2.txt")
def sketches(self):
return [self.sketch_0(), self.sketch_1(), self.sketch_2()]
class BlocksClear(FromFile):
def __init__(self, instance_file="domains/blocks_4_clear/p-4-100.pddl"):
super().__init__("domains/blocks_4_clear/domain.pddl", instance_file)
def sketch_0(self) -> Policy:
return self.read_sketch("drexler_sketches/blocks-clear/blocks-clear_0.txt")
def sketch_1(self):
return self.read_sketch("drexler_sketches/blocks-clear/blocks-clear_1.txt")
def sketch_2(self):
return self.read_sketch("drexler_sketches/blocks-clear/blocks-clear_2.txt")
def sketches(self):
return [self.sketch_0(), self.sketch_1(), self.sketch_2()]
class Gripper(FromFile):
def __init__(self, instance_file=base_path + "domains/gripper/p-3-0.pddl"):
super().__init__(base_path + "domains/gripper/domain.pddl", instance_file)
def sketch_0(self):
return self.read_sketch(base_path + "drexler_sketches/gripper/gripper_0.txt")
def sketch_1(self):
return self.read_sketch(base_path + "drexler_sketches/gripper/gripper_1.txt")
def sketch_2(self):
return self.read_sketch(base_path + "drexler_sketches/gripper/gripper_2.txt")
def sketches(self):
return [self.sketch_0(), self.sketch_1(), self.sketch_2()]
class Childsnack(FromFile):
def __init__(self, instance_file=base_path + "domains/childsnack/p-2-1.0-0.0-1-0.pddl"):
super().__init__(base_path + "domains/childsnack/domain.pddl", instance_file)
def sketch_1(self):
return self.read_sketch(base_path + "drexler_sketches/childsnack/childsnack_1.txt")
def sketches(self):
return [None, self.sketch_1(), None]
class Miconic(FromFile):
def __init__(self, instance_file="domains/miconic/p-2-2-0.pddl"):
super().__init__("domains/miconic/domain.pddl", instance_file)
def sketch_1(self):
return self.read_sketch("drexler_sketches/miconic/miconic_1.txt")
def sketch_2(self):
return self.read_sketch("drexler_sketches/miconic/miconic_2.txt")
def sketches(self):
return [None, self.sketch_1(), self.sketch_2()]
class Delivery(FromFile):
def __init__(self, instance_file=base_path + "domains/delivery/instance_2_1_0.pddl"):
super().__init__(base_path + "domains/delivery/domain.pddl", instance_file)
def sketch_1(self):
return self.read_sketch(base_path + "drexler_sketches/delivery/delivery_1.txt")
def sketch_2(self):
return self.read_sketch(base_path + "drexler_sketches/delivery/delivery_2.txt")
def sketches(self):
return [None, self.sketch_1(), self.sketch_2()]