@@ -450,42 +450,6 @@ def run_smbo(self):
450
450
(1 , - 1 ))
451
451
self .logger .info (list (meta_features_dict .keys ()))
452
452
453
- # meta_runs = meta_base.get_all_runs(METRIC_TO_STRING[self.metric])
454
- # meta_runs_index = 0
455
- # try:
456
- # meta_durations = meta_base.get_all_runs('runtime')
457
- # read_runtime_data = True
458
- # except KeyError:
459
- # read_runtime_data = False
460
- # self.logger.critical('Cannot read runtime data.')
461
- # if self.acquisition_function == 'EIPS':
462
- # self.logger.critical('Reverting to acquisition function EI!')
463
- # self.acquisition_function = 'EI'
464
-
465
- # for meta_dataset in meta_runs.index:
466
- # meta_dataset_start_index = meta_runs_index
467
- # for meta_configuration in meta_runs.columns:
468
- # if np.isfinite(meta_runs.loc[meta_dataset, meta_configuration]):
469
- # try:
470
- # config = meta_base.get_configuration_from_algorithm_index(
471
- # meta_configuration)
472
- # cost = meta_runs.loc[meta_dataset, meta_configuration]
473
- # if read_runtime_data:
474
- # runtime = meta_durations.loc[meta_dataset,
475
- # meta_configuration]
476
- # else:
477
- # runtime = 1
478
- # # TODO read out other status types!
479
- # meta_runhistory.add(config, cost, runtime,
480
- # StatusType.SUCCESS,
481
- # instance_id=meta_dataset)
482
- # meta_runs_index += 1
483
- # except:
484
- # # TODO maybe add warning
485
- # pass
486
- #
487
- # meta_runs_dataset_indices[meta_dataset] = (
488
- # meta_dataset_start_index, meta_runs_index)
489
453
else :
490
454
meta_features = None
491
455
self .logger .warning ('Could not find meta-data directory %s' %
@@ -514,13 +478,13 @@ def run_smbo(self):
514
478
startup_time = self .watcher .wall_elapsed (self .dataset_name )
515
479
total_walltime_limit = self .total_walltime_limit - startup_time - 5
516
480
scenario_dict = {'cs' : self .config_space ,
517
- 'cutoff-time ' : self .func_eval_time_limit ,
518
- 'memory-limit ' : self .memory_limit ,
519
- 'wallclock-limit ' : total_walltime_limit ,
481
+ 'cutoff_time ' : self .func_eval_time_limit ,
482
+ 'memory_limit ' : self .memory_limit ,
483
+ 'wallclock_limit ' : total_walltime_limit ,
520
484
'output-dir' :
521
485
self .backend .get_smac_output_directory (self .seed ),
522
486
'shared-model' : self .shared_mode ,
523
- 'run-obj ' : 'quality' ,
487
+ 'run_obj ' : 'quality' ,
524
488
'deterministic' : 'true' ,
525
489
'instances' : instances }
526
490
@@ -631,31 +595,6 @@ def run_smbo(self):
631
595
else :
632
596
raise ValueError (self .configuration_mode )
633
597
634
- # Build a runtime model
635
- # runtime_rf = RandomForestWithInstances(types,
636
- # instance_features=meta_features_list,
637
- # seed=1, num_trees=10)
638
- # runtime_rh2EPM = RunHistory2EPM4EIPS(num_params=num_params,
639
- # scenario=self.scenario,
640
- # success_states=None,
641
- # impute_censored_data=False,
642
- # impute_state=None)
643
- # X_runtime, y_runtime = runtime_rh2EPM.transform(meta_runhistory)
644
- # runtime_rf.train(X_runtime, y_runtime[:, 1].flatten())
645
- # X_meta, Y_meta = rh2EPM.transform(meta_runhistory)
646
- # # Transform Y_meta on a per-dataset base
647
- # for meta_dataset in meta_runs_dataset_indices:
648
- # start_index, end_index = meta_runs_dataset_indices[meta_dataset]
649
- # end_index += 1 # Python indexing
650
- # Y_meta[start_index:end_index, 0]\
651
- # [Y_meta[start_index:end_index, 0] >2.0] = 2.0
652
- # dataset_minimum = np.min(Y_meta[start_index:end_index, 0])
653
- # Y_meta[start_index:end_index, 0] = 1 - (
654
- # (1. - Y_meta[start_index:end_index, 0]) /
655
- # (1. - dataset_minimum))
656
- # Y_meta[start_index:end_index, 0]\
657
- # [Y_meta[start_index:end_index, 0] > 2] = 2
658
-
659
598
smac .solver .stats .start_timing ()
660
599
# == first, evaluate all metelearning and default configurations
661
600
smac .solver .incumbent = smac .solver .initial_design .run ()
@@ -670,9 +609,10 @@ def run_smbo(self):
670
609
time_bound = self .total_walltime_limit )
671
610
672
611
if smac .solver .scenario .shared_model :
673
- pSMAC .write (run_history = smac .solver .runhistory ,
674
- output_directory = smac .solver .scenario .output_dir ,
675
- num_run = self .seed )
612
+ pSMAC .write (
613
+ run_history = smac .solver .runhistory ,
614
+ output_directory = smac .solver .scenario .output_dir ,
615
+ )
676
616
677
617
if smac .solver .stats .is_budget_exhausted ():
678
618
break
@@ -687,14 +627,7 @@ def run_smbo(self):
687
627
logger = self .logger )
688
628
689
629
choose_next_start_time = time .time ()
690
- try :
691
- challengers = self .choose_next (smac )
692
- except Exception as e :
693
- self .logger .error (e )
694
- self .logger .error ("Error in getting next configurations "
695
- "with SMAC. Using random configuration!" )
696
- next_config = self .config_space .sample_configuration ()
697
- challengers = [next_config ]
630
+ challengers = self .choose_next (smac )
698
631
time_for_choose_next = time .time () - choose_next_start_time
699
632
self .logger .info ('Used %g seconds to find next '
700
633
'configurations' % (time_for_choose_next ))
@@ -708,9 +641,10 @@ def run_smbo(self):
708
641
time_bound = time_for_choose_next )
709
642
710
643
if smac .solver .scenario .shared_model :
711
- pSMAC .write (run_history = smac .solver .runhistory ,
712
- output_directory = smac .solver .scenario .output_dir ,
713
- num_run = self .seed )
644
+ pSMAC .write (
645
+ run_history = smac .solver .runhistory ,
646
+ output_directory = smac .solver .scenario .output_dir ,
647
+ )
714
648
715
649
if smac .solver .stats .is_budget_exhausted ():
716
650
break
@@ -737,18 +671,8 @@ def choose_next(self, smac):
737
671
(1. - dataset_minimum ))
738
672
Y_cfg [:, 0 ][Y_cfg [:, 0 ] > 2 ] = 2
739
673
740
- # if len(X_meta) > 0 and len(X_cfg) > 0:
741
- # pass
742
- # X_cfg = np.concatenate((X_meta, X_cfg))
743
- # Y_cfg = np.concatenate((Y_meta, Y_cfg))
744
- # elif len(X_meta) > 0:
745
- # X_cfg = X_meta.copy()
746
- # Y_cfg = Y_meta.copy()
747
- # elif len(X_cfg) > 0:
748
674
X_cfg = X_cfg .copy ()
749
675
Y_cfg = Y_cfg .copy ()
750
- # else:
751
- # raise ValueError('No training data for SMAC random forest!')
752
676
753
677
self .logger .info ('Using %d training points for SMAC.' %
754
678
X_cfg .shape [0 ])
0 commit comments