-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhighwayenv_run.py
More file actions
102 lines (84 loc) · 2.82 KB
/
Copy pathhighwayenv_run.py
File metadata and controls
102 lines (84 loc) · 2.82 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"""
Standalone script to create HighEnvDecider and run it for all combinations.
"""
import os
from sandra.config import SanDRAConfiguration
from sandra.highenv.decider import HighEnvDecider
import matplotlib
import itertools
print(matplotlib.get_backend())
matplotlib.use("TkAgg")
def main():
seeds = [
5838,
2421,
7294,
9650,
4176,
6382,
8765,
1348, # initial spot fail
4213,
2572, # initial spot fail
]
# Scenario settings: (lanes_count, vehicles_density)
scenario_settings = [
(4, 2.0), # setting 1
(4, 3.0), # setting 2
(5, 3.0), # setting 3
]
for seed in seeds:
# Cartesian product of configs
configs = itertools.product(
[True, False], # use_rules_in_reach
[True, False], # use_rules_in_prompt
["set-based", "most-likely"], # prediction type
scenario_settings
)
for use_rules_in_reach, use_rules_in_prompt, pred_type, (lanes, density) in configs:
config = SanDRAConfiguration()
# 1. rules in reachable set
config.use_rules_in_reach = use_rules_in_reach
# 2. rules in prompt
config.use_rules_in_prompt = use_rules_in_prompt
config.visualize_reach = False
# 3. prediction type
if pred_type == "set-based":
config.use_sonia = True
config.h = 8
else:
config.use_sonia = False
config.h = 15
# 4. scenario setup
config.highway_env.lanes_count = lanes
config.highway_env.vehicles_density = density
# Seed
config.highway_env.seeds = [seed]
# Run decider
save_path = config.highway_env.get_save_folder(
config.model_name,
seed,
config.use_sonia,
config.use_rules_in_prompt,
config.use_rules_in_reach
)
if os.path.exists(save_path + "/evaluation.csv"):
print(
f"\n=== Skipping seed {seed}, "
f"reach={use_rules_in_reach}, "
f"prompt={use_rules_in_prompt}, "
f"pred={pred_type}, "
f"lanes={lanes}, density={density} ==="
)
continue
print(
f"\n=== Running seed {seed}, "
f"reach={use_rules_in_reach}, "
f"prompt={use_rules_in_prompt}, "
f"pred={pred_type}, "
f"lanes={lanes}, density={density} ==="
)
decider = HighEnvDecider.configure(config=config, save_path=save_path)
decider.run()
if __name__ == "__main__":
main()