-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcreate_temporal_domain.py
49 lines (40 loc) · 1.92 KB
/
create_temporal_domain.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
from pddl.domain import Domain
from pddl.effect_assignment import AssignmentType
from pddl.problem import Problem
from pddl.grounding import Grounding
from pddl.time_spec import TimeSpec
from plans.temporal_plan import PlanTemporalNetwork
def create_temporal_domain() -> Domain:
domain = Domain("match_domain")
# types
domain.add_type("match")
domain.add_type("fuse")
# predicates
domain.add_predicate_from_str("light", {"?m" : "match"})
domain.add_predicate_from_str("unused", {"?m" : "match"})
domain.add_predicate_from_str("mended", {"?f" : "fuse"})
domain.add_predicate_from_str("handempty")
# functions
domain.add_function_from_str("fuses_mended")
# light match
domain.add_operator_from_str("light_match", {"?m" : "match"}, durative=True)
op = domain.operators['light_match']
op.set_constant_duration(8)
op.add_simple_condition_from_str("unused", {"?m" : "match"})
op.add_simple_effect_from_str("unused", {"?m" : "match"}, is_delete=True)
op.add_simple_effect_from_str("light", {"?m" : "match"})
op.add_simple_effect_from_str("light", {"?m" : "match"}, time_spec=TimeSpec.AT_END, is_delete=True)
# mend fuse
domain.add_operator_from_str("mend_fuse", {"?f" : "fuse", "?m" : "match"}, durative=True)
op = domain.operators['mend_fuse']
op.set_constant_duration(5)
op.add_simple_condition_from_str("light", {"?m" : "match"}, time_spec=TimeSpec.OVER_ALL)
op.add_simple_condition_from_str("handempty")
op.add_simple_effect_from_str("handempty", is_delete=True)
op.add_simple_effect_from_str("mended", {"?f" : "fuse"}, time_spec=TimeSpec.AT_END)
op.add_simple_effect_from_str("handempty", time_spec=TimeSpec.AT_END)
op.add_assign_effect_from_str("fuses_mended", time_spec=TimeSpec.AT_END, assign_type=AssignmentType.INCREASE, value=1.0)
return domain
if __name__ == "__main__":
domain = create_temporal_domain()
print(domain)