-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
78 lines (63 loc) · 2.73 KB
/
Copy pathmain.py
File metadata and controls
78 lines (63 loc) · 2.73 KB
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
import os
from fire import Fire
from run import run_single
def main(
domain_dir: str = "data/deterministic/blocksworld",
):
problem_files = [f for f in os.listdir(domain_dir) if f.endswith(".pddl")]
if "domain.pddl" in problem_files:
problem_files.remove("domain.pddl")
policy_files = [f for f in os.listdir(domain_dir) if f.endswith(".json")]
property_files = [f for f in os.listdir(domain_dir) if f.endswith(".pctl")]
problem_files = sorted(problem_files)
policy_files = sorted(policy_files)
property_files = sorted(property_files)
print('DOMAIN DIR:', domain_dir)
print(problem_files)
print(policy_files)
print(property_files)
results = {}
for policy_file in policy_files:
results[policy_file] = {}
for problem_file in problem_files:
results[policy_file][problem_file] = {}
compile = True
for property_file in property_files:
print(f'RUNNING FOR: {problem_file} {policy_file} {property_file}')
res = run_single(domain_dir, problem_file, policy_file, property_file, compile_dtmc=compile)
results[policy_file][problem_file][property_file] = res if res is not None else "Error"
compile = False
# --- Formatting Logic ---
print(f"\nResults for domain `{domain_dir}`")
# Calculate column widths
# 1. First column width = max length of problem filenames (or at least 15 chars)
if problem_files:
col0_width = max(len(p) for p in problem_files) + 4
else:
col0_width = 15
# 2. Property column widths = max length of property name (or at least 10 chars)
# We strip .pctl for the header name
prop_names = [p.split('.pctl')[0] for p in property_files]
prop_widths = [max(len(n), 10) + 2 for n in prop_names]
for policy_file in policy_files:
print(f"Policy `{policy_file}`:")
# Print Header Row
# Empty block for the "Problem" column
print(f"{'':<{col0_width}}", end="")
for i, name in enumerate(prop_names):
print(f"| {name:<{prop_widths[i]}}", end="")
print("|")
# Print Separator Line
total_width = col0_width + sum(w + 2 for w in prop_widths) + len(prop_widths) # rough estimate
print("-" * total_width)
# Print Data Rows
for problem_file in problem_files:
print(f"{problem_file:<{col0_width}}", end="")
for i, property_file in enumerate(property_files):
val = str(results[policy_file][problem_file][property_file])
print(f"| {val:<{prop_widths[i]}}", end="")
print("|")
print("\n")
return
if __name__ == "__main__":
Fire(main)