-
Notifications
You must be signed in to change notification settings - Fork 6
/
simulate_plan_execution.py
41 lines (32 loc) · 1.44 KB
/
simulate_plan_execution.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
from plans.temporal_plan import PlanTemporalNetwork
from examples.create_temporal_domain import create_temporal_domain
from examples.create_temporal_problem import create_temporal_problem
if __name__ == "__main__":
"""
This script uses the PlanTemporalNetwork class.
First it creates the PDDL domain and problem files.
Then it loads a temporal plan from file and generates a temporal network.
Then it simulates the execution of the temporal plan for some time,
returning the current state and effects of ongoing actions as TILs.
Finally, it prints the current state as a new problem file.
"""
domain = create_temporal_domain()
problem = create_temporal_problem()
print("Printing the original problem...")
print(problem)
print("")
print("Parsing plan file...")
plan_file = "pddl/test_domains/match_plan.pddl"
plan = PlanTemporalNetwork(domain, problem)
plan.read_from_file(plan_file)
# print the plan file
with open(plan_file, "r") as f: print(f.read())
print("")
time = 13.0
print("Printing the problem at time {:0.2f}".format(time))
state, ongoing_action_tils = plan.simulate_execution(until_time=time)
# update the problem to the current state and time
problem.update_with_state(state)
# add new TILs to the problem that represent the end effects of ongoing actions
for til in ongoing_action_tils: problem.add_til(til)
print(problem)