Skip to content

Commit feb9066

Browse files
author
sfalkner
committed
introduced memlimit for fanova as cli-argument for spysmac_analyze, and spysmac_run for the default config now
creates the output directory if it doesn't existsy
1 parent 9f4a63b commit feb9066

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

SpySMAC_analyze.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ def parse_args(argv):
107107
opt_params.add_argument("-d", "--disable_fanova", action="store_true", default=False,
108108
help="disables fANOVA")
109109

110+
opt_params.add_argument("-m", "--memlimit_fanova", default=512,
111+
help="sets memory limit in MB for fANOVA")
110112

111113
# Process arguments
112114
args = parser.parse_args(argv[1:])
@@ -149,8 +151,8 @@ def analyze_simulations(args):
149151
"Most likely you did not run SpySMAC_run with --seed 0.")
150152

151153
tmp = obj.data[0]['test_performances']
152-
baseline_train = np.array([tmp[j] for j in train_indices]).flatten()
153-
baseline_test = np.array([tmp[j] for j in test_indices]).flatten()
154+
baseline_train = np.array([list(tmp[j]) for j in train_indices]).flatten()
155+
baseline_test = np.array([list(tmp[j]) for j in test_indices]).flatten()
154156

155157

156158
# import the data for the configuration runs
@@ -163,14 +165,13 @@ def analyze_simulations(args):
163165
# get performance for each run
164166
for i in list(obj.data.keys()):
165167
tmp = obj.data[i]['test_performances']
166-
tmp_train = np.array([tmp[j] for j in train_indices]).flatten()
167-
tmp_test = np.array([tmp[j] for j in test_indices]).flatten()
168168

169+
tmp_train = np.array([list(tmp[j]) for j in train_indices]).flatten()
170+
tmp_test = np.array([list(tmp[j]) for j in test_indices]).flatten()
169171
run_ids.append(i)
170172
train_performances.append(tmp_train)
171173
test_performances.append(tmp_test)
172174

173-
174175
# each ROW contains the measured performance for the instances
175176
train_performances = np.array(train_performances)
176177
test_performances = np.array(test_performances)
@@ -216,15 +217,15 @@ def analyze_simulations(args):
216217

217218
# fANOVA
218219
try:
219-
p_not_imps, fanova_not_plots = get_fanova(obj.get_pyfanova_obj(check_scenario_files = False, improvement_over="NOTHING"),
220+
p_not_imps, fanova_not_plots = get_fanova(obj.get_pyfanova_obj(check_scenario_files = False, improvement_over="NOTHING", heap_size = options['memlimit_fanova']),
220221
cs, options['outputdir'], improvement_over="NOTHING")
221222
except:
222223
traceback.print_exc()
223224
logging.warn("fANOVA (without capping) failed")
224225
p_not_imps, fanova_not_plots = [],[]
225226

226227
try:
227-
p_def_imps, fanova_def_plots = get_fanova(obj.get_pyfanova_obj(check_scenario_files = False, improvement_over="DEFAULT"),
228+
p_def_imps, fanova_def_plots = get_fanova(obj.get_pyfanova_obj(check_scenario_files = False, improvement_over="DEFAULT", heap_size = options['memlimit_fanova']),
228229
cs, options['outputdir'], improvement_over="DEFAULT")
229230
except:
230231
traceback.print_exc()

SpySMAC_run.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import signal
1818
import resource
1919
import imp
20+
import errno
2021

2122
import logging
2223
import random
@@ -305,7 +306,14 @@ def run_simulations(args):
305306

306307
# for the special seed 0,
307308
if options['seed'] == 0:
308-
# store meta information in a file for the report
309+
310+
# make sure that the output directory exists
311+
try:
312+
os.makedirs(options['outputdir'])
313+
except OSError as exception:
314+
if exception.errno != errno.EEXIST:
315+
raise
316+
# store meta information in a file for the report
309317
with open(os.path.join(options['outputdir'], 'spysmac.meta'),'w') as fh:
310318

311319
# os information

0 commit comments

Comments
 (0)