@@ -450,42 +450,6 @@ def run_smbo(self):
450450 (1 , - 1 ))
451451 self .logger .info (list (meta_features_dict .keys ()))
452452
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)
489453 else :
490454 meta_features = None
491455 self .logger .warning ('Could not find meta-data directory %s' %
@@ -514,13 +478,13 @@ def run_smbo(self):
514478 startup_time = self .watcher .wall_elapsed (self .dataset_name )
515479 total_walltime_limit = self .total_walltime_limit - startup_time - 5
516480 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 ,
520484 'output-dir' :
521485 self .backend .get_smac_output_directory (self .seed ),
522486 'shared-model' : self .shared_mode ,
523- 'run-obj ' : 'quality' ,
487+ 'run_obj ' : 'quality' ,
524488 'deterministic' : 'true' ,
525489 'instances' : instances }
526490
@@ -631,31 +595,6 @@ def run_smbo(self):
631595 else :
632596 raise ValueError (self .configuration_mode )
633597
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-
659598 smac .solver .stats .start_timing ()
660599 # == first, evaluate all metelearning and default configurations
661600 smac .solver .incumbent = smac .solver .initial_design .run ()
@@ -670,9 +609,10 @@ def run_smbo(self):
670609 time_bound = self .total_walltime_limit )
671610
672611 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+ )
676616
677617 if smac .solver .stats .is_budget_exhausted ():
678618 break
@@ -687,14 +627,7 @@ def run_smbo(self):
687627 logger = self .logger )
688628
689629 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 )
698631 time_for_choose_next = time .time () - choose_next_start_time
699632 self .logger .info ('Used %g seconds to find next '
700633 'configurations' % (time_for_choose_next ))
@@ -708,9 +641,10 @@ def run_smbo(self):
708641 time_bound = time_for_choose_next )
709642
710643 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+ )
714648
715649 if smac .solver .stats .is_budget_exhausted ():
716650 break
@@ -737,18 +671,8 @@ def choose_next(self, smac):
737671 (1. - dataset_minimum ))
738672 Y_cfg [:, 0 ][Y_cfg [:, 0 ] > 2 ] = 2
739673
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:
748674 X_cfg = X_cfg .copy ()
749675 Y_cfg = Y_cfg .copy ()
750- # else:
751- # raise ValueError('No training data for SMAC random forest!')
752676
753677 self .logger .info ('Using %d training points for SMAC.' %
754678 X_cfg .shape [0 ])
0 commit comments