-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrun_on_benchmark_instances_missing_fields.py
205 lines (193 loc) · 8.81 KB
/
run_on_benchmark_instances_missing_fields.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
from itertools import product
import subprocess
from os.path import basename, exists, join, abspath
from os import getcwd
import time
import csv
#build = 'debug'
build = 'release'
timeout_seconds = 3600
mem_limit = '8g'
seed = 123
use_heuristic = True
focal_w = 1#.01
child_pref_budget = 5
max_child_pref_options = 20
prefer_f_cardinal = False
prefer_goal_conflicts = False
agents_dir = abspath('agents')
maps_dir = abspath('maps')
scen_dir = abspath('scen')
# output_file_name = 'benchmark_cbsh_no_lpa.csv'
output_file_name = 'benchmark_cbsh_no_lpa_timeout_3600.csv'
# output_file_name = 'benchmark_cbsh_no_lpa_prefer_goal_conflicts.csv'
# output_file_name = 'benchmark_cbsh_no_lpa_goal_conflict_aware_heuristic.csv'
# output_file_name = 'benchmark_cbsh_no_lpa_goal_conflict_aware_heuristic_prefer_goal_conflicts.csv'
# output_file_name = 'benchmark_cbsh_no_lpa_goal_conflict_aware_heuristic_prefer_f_cardinal.csv'
# output_file_name = 'benchmark_cbsh_lpa_up_and_down_5_child_pref_budget_20_pref_options_with_lpmdd_and_path_repair.csv'
# output_file_name = 'benchmark_ecbsh_1_05_lpa_up_and_down_5_child_pref_budget_20_pref_options_with_lpmdd_and_path_repair.csv'
# output_file_name = 'benchmark_ecbsh_1_01_lpa_up_and_down_5_child_pref_budget_20_pref_options_with_lpmdd_and_path_repair.csv'
# output_file_name = 'benchmark_idcbsh_lpa_with_lpmdd_and_path_repair.csv'
# output_file_name = 'benchmark_idcbsh_lpa_with_lpmdd_and_path_repair_timeout_3600.csv'
# output_file_name = 'benchmark_ecbsh_1_05_no_lpa.csv'
# output_file_name = 'benchmark_ecbsh_1_01_no_lpa.csv'
# output_file_name = 'benchmark_cbsh_lpa_up_and_down_with_lpmdd_and_path_repair_goal_conflict_heuristic.csv'
# output_file_name = 'benchmark_cbsh_lpa_up_and_down_5_with_lpmdd_and_path_repair_goal_conflict_heuristic_prefer_f_cardinals.csv'
# output_file_name = 'dao_cbsh_no_lpa_fcardinal.csv'
#output_file_name = 'dao_cbsh_no_lpa_latest_conflict.csv'
#output_file_name = 'dao_cbsh_no_lpa_up_and_down_0_budget.csv'
#output_file_name = 'dao_cbsh_no_lpa_up_and_down_0_budget_latest_conflict.csv'
#output_file_name = 'dao_cbsh_no_lpa_up_and_down_5_budget.csv'
#output_file_name = 'dao_cbsh_no_lpa_up_and_down_5_budget_latest_conflict.csv'
#output_file_name = 'dao_cbsh_no_lpa_up_and_down_5_budget_min_tree_distance_20_options_.csv'
#output_file_name = 'dao_cbsh_lpa.csv'
#output_file_name = 'dao_cbsh_lpa_up_and_down_0_budget.csv'
#output_file_name = 'dao_cbsh_lpa_up_and_down_0_budget_not_latest_conflict.csv'
#output_file_name = 'dao_cbsh_lpa_up_and_down_5_budget.csv'
#output_file_name = 'dao_cbsh_lpa_up_and_down_20_budget.csv'
#output_file_name = 'dao_cbsh_lpa_up_and_down_5_budget_not_latest_conflict.csv'
#output_file_name = 'dao_ecbs_no_h_1_05_lpa_up_and_down_5_budget.csv'
#output_file_name = 'dao_ecbsh_1_05_lpa_up_and_down_5_budget.csv'
#output_file_name = 'dao_ecbs_no_h_1_05_no_lpa_up_and_down_5_budget.csv'
#output_file_name = 'dao_ecbsh_1_05_no_lpa_up_and_down_5_budget.csv'
# output_file_name = 'dao_ecbsh_1_05_no_lpa_up_and_down_5_budget_latest_conflict.csv'
#output_file_name = 'dao_ecbsh_1_05_lpa.csv'
#output_file_name = 'dao_ecbsh_1_05_no_lpa.csv'
#output_file_name = 'dao_idcbsh_no_lpa.csv'
#output_file_name = 'dao_idcbsh_no_lpa_latest_conflict.csv'
#output_file_name = 'dao_idcbsh_lpa.csv'
#output_file_name = 'dao_ecbs_no_h_1_05_no_lpa.csv'
output_dir = getcwd()
output_file_path = join(output_dir, output_file_name)
executable_name = "ECBSH_no_lpa"
# executable_name = "ECBSH_no_lpa_goal_conflict_heuristic"
#executable_name = "ECBSH_no_lpa_latest_conflict"
#executable_name = "ECBSH_no_lpa_up_and_down"
# executable_name = "ECBSH_no_lpa_up_and_down_latest_conflict"
# executable_name = "ECBSH_lpa"
# executable_name = "ECBSH_lpa_not_latest_conflict"
#executable_name = "ECBSH_lpa_up_and_down"
# executable_name = "ECBSH_lpa_up_and_down_with_lpmdd_and_path_repair"
# executable_name = "ECBSH_lpa_up_and_down_with_lpmdd_and_path_repair_goal_conflict_heuristic"
#executable_name = "ECBSH_lpa_up_and_down_not_latest_conflict"
# executable_name = "IDCBSH_no_lpa"
# executable_name = "IDCBSH_no_lpa_latest_conflict"
# executable_name = "IDCBSH_lpa"
# executable_name = "IDCBSH_lpa_not_latest_conflict"
# executable_name = "IDECBSH_lpa_with_lpmdd_and_path_repair"
executable_path = join('/lpa', executable_name)
map_names = (
'ost003d',
'den502d',
'den520d',
'brc202d',
'empty-8-8',
'empty-16-16',
'empty-32-32',
'empty-48-48',
'random-32-32-10',
'random-32-32-20',
'random-64-64-10',
'random-64-64-20',
'maze-128-128-1',
'maze-128-128-2',
'maze-128-128-4',
'maze-128-128-10',
'maze-32-32-2',
'room-32-32-4',
'room-64-64-8',
'room-64-64-16',
'den312d',
'orz900d',
'ht_chantry',
'ht_mansion_n',
'lak303d',
'lt_gallowstemplar_n',
'w_woundedcoast',
'Berlin_1_256',
'Boston_0_256',
'Paris_1_256',
'warehouse-10-20-10-2-1',
'warehouse-10-20-10-2-2',
'warehouse-20-40-10-2-1',
'warehouse-20-40-10-2-2',
)
# USC maps (with .agents files):
# 'kiva_0.map',
# 'roundabout_2.map',
# 'maze_3.map',
# 'maze_2.map',
# 'roundabout_3.map',
# 'roundabout_1.map',
# 'roundabout_4.map',
# 'roundabout_5.map',
# 'maze_1_2.map',
# 'maze_1.map',
# 'maze_1_3.map',
# 'maze_4.map',
with open(output_file_path) as f:
output_csv = csv.DictReader(f)
for line in output_csv:
if line['Max Mem (kB)'] != '' and line['Wall Runtime'] != '#N/A':
continue
instance_file = line['instance']
assert instance_file.endswith('.scen')
instance_name = instance_file[:-len('.scen')]
scen_type = instance_name.rsplit('-', 2)[-2]
map_name = instance_name.rsplit('-', 2)[-3][len('/scen/'):]
scen_index = int(instance_name.rsplit('-', 2)[-1])
num_agents = int(line['Num of Agents'])
print(f'found line with missing memory usage data or wall runtime:')
print(f'instance={instance_file} - last_scen_type={scen_type}, last_map_name={map_name}, last_scen_index={scen_index}')
split_strategy = 'NON_DISJOINT'
# for , scen_index, map_name, scen_type in product(
# (
# #'MVC_BASED',
# ,
# ), range(1, 26), map_names, ('even', 'random')):
# # for split_strategy in ('WIDTH', ): # Looks like the best one
#
# num_agents_start = 2
map_file_name = f'{map_name}.map'
map_file_path = join(maps_dir, map_file_name)
if not exists(map_file_path):
continue
scen_file_name = f'{map_name}-{scen_type}-{scen_index}.scen'
scen_file_path = join(scen_dir, scen_file_name)
if not exists(scen_file_path):
continue
# GLOG_logtostderr=1 ./cmake-...
# docker run --memory-swap=10g to avoid swapping
cmd = f'docker run --rm -it --net=host --memory={mem_limit} --memory-swap={mem_limit} -v {scen_dir}:/scen ' \
f'-v {maps_dir}:/maps -v {output_dir}:/output ' \
f'search/mapf:cbs-lpa ' \
f'{executable_path} -m "/maps/{map_file_name}" ' \
f'-a "/scen/{scen_file_name}" ' \
f'-k {num_agents} ' \
f'-o /output/{output_file_name} -p {split_strategy} --screen 0 --seed {seed} ' \
f'--cutoffTime={timeout_seconds} --verbosity 0 --heuristic {1 if use_heuristic else 0} ' \
f'--focalW {focal_w} --childPrefBudget {child_pref_budget} --maxChildPrefOptions {max_child_pref_options} ' \
f'--prefer_f_cardinal {1 if prefer_f_cardinal else 0} ' \
f'--prefer_goal_conflicts {1 if prefer_goal_conflicts else 0}'
# cmd = f'./{executable_name} -m "maps/{map_file_name}" ' \
# f'-a "scen/{scen_file_name}" ' \
# f'-k {num_agents} ' \
# f'-o {output_file_name} -p {split_strategy} --screen 0 --seed {seed} ' \
# f'--cutoffTime={timeout_seconds} --verbosity 0 --heuristic {1 if use_heuristic else 0} ' \
# f'--focalW {focal_w} ' \
# f'--childPrefBudget {child_pref_budget} ' \
# f'--maxChildPrefOptions {max_child_pref_options} ' \
# f'--prefer_f_cardinal {1 if prefer_f_cardinal else 0} ' \
# f'--prefer_goal_conflicts {1 if prefer_goal_conflicts else 0}'
print(time.strftime('%Y-%m-%dT%H:%M:%S: ') + cmd)
start_time = time.time()
try:
subprocess.check_call(cmd, shell=True)
except subprocess.CalledProcessError as e:
if e.returncode == 1: # Solution not found - probably due to a timeout. No point in adding more agents
pass
elif e.returncode == 137: # Killed by the OOM killer
with open(output_file_path, 'a') as f:
f.write('-2,' + '=NA(),' * 23 + f'{time.time() - start_time},=NA(),{mem_limit},same as above,/scen/{scen_file_name},{num_agents}\n')
else:
raise