def __init__(self, config_space: ConfigurationSpace, source_hpo_data: List, seed: int, history_dataset_features: List = None, num_src_hpo_trial: int = 50, surrogate_type='rf'): self.method_id = None self.config_space = config_space self.random_seed = seed self.num_src_hpo_trial = num_src_hpo_trial self.source_hpo_data = source_hpo_data self.source_surrogates = None self.target_surrogate = None self.history_dataset_features = history_dataset_features # The number of source problems. if source_hpo_data is not None: self.K = len(source_hpo_data) if history_dataset_features is not None: assert len(history_dataset_features) == self.K self.surrogate_type = surrogate_type self.types, self.bounds = get_types(config_space) self.instance_features = None self.var_threshold = VERY_SMALL_NUMBER self.w = None self.eta_list = list() # meta features. self.meta_feature_scaler = None self.meta_feature_imputer = None self.target_weight = list() self.logger = get_logger(self.__class__.__name__)
def __init__(self, task_id): self.task_id = task_id self.data = collections.OrderedDict() self.config_counter = 0 self.incumbent_value = MAXINT self.incumbents = list() self.logger = get_logger(self.__class__.__name__)
def __init__(self, task_id, ref_point=None): self.task_id = task_id self.data = collections.OrderedDict() self.config_counter = 0 self.pareto = collections.OrderedDict() self.num_objs = None self.mo_incumbent_value = None self.mo_incumbents = None self.ref_point = ref_point self.hv_data = list() self.logger = get_logger(self.__class__.__name__)
def __init__(self, config_space, initial_trials=10, initial_configurations=None, init_strategy='random_explore_first', history_bo_data=None, optimization_strategy='bo', surrogate_type='prf', output_dir='logs', task_id=None, rng=None): # Create output (logging) directory. # Init logging module. # Random seed generator. self.init_strategy = init_strategy self.output_dir = output_dir if rng is None: run_id, rng = get_rng() self.rng = rng self.logger = get_logger(self.__class__.__name__) # Basic components in Advisor. self.optimization_strategy = optimization_strategy self.default_obj_value = MAXINT self.configurations = list() self.failed_configurations = list() self.perfs = list() self.scale_perc = 5 self.perc = None self.min_y = None self.max_y = None # Init the basic ingredients in Bayesian optimization. self.history_bo_data = history_bo_data self.surrogate_type = surrogate_type self.init_num = initial_trials self.config_space = config_space self.config_space.seed(rng.randint(MAXINT)) if initial_configurations is not None and len( initial_configurations) > 0: self.initial_configurations = initial_configurations self.init_num = len(initial_configurations) else: self.initial_configurations = self.create_initial_design( self.init_strategy) self.init_num = len(self.initial_configurations) self.history_container = HistoryContainer(task_id) self.surrogate_model = None self.acquisition_function = None self.optimizer = None self.setup_bo_basics()
def _get_logger(self, name): logger_name = 'lite-bo-%s' % name setup_logger(os.path.join(self.output_dir, '%s.log' % str(logger_name))) return get_logger(logger_name)
def _get_logger(self, name): logger_name = 'Lite-BO-%s' % name self.logger_name = os.path.join(self.output_dir, '%s.log' % str(logger_name)) setup_logger(self.logger_name) return get_logger(logger_name)
def __init__(self, config_space, task_info, initial_trials=10, initial_configurations=None, init_strategy='random_explore_first', history_bo_data=None, optimization_strategy='bo', surrogate_type=None, acq_type=None, acq_optimizer_type='local_random', ref_point=None, use_trust_region=False, output_dir='logs', task_id=None, random_state=None): # Create output (logging) directory. # Init logging module. # Random seed generator. self.task_info = task_info self.num_objs = task_info['num_objs'] self.num_constraints = task_info['num_constraints'] self.init_strategy = init_strategy self.output_dir = output_dir self.rng = np.random.RandomState(random_state) self.logger = get_logger(self.__class__.__name__) history_folder = os.path.join(self.output_dir, 'bo_history') if not os.path.exists(history_folder): os.makedirs(history_folder) self.history_file = os.path.join(history_folder, 'bo_history_%s.json' % task_id) # Basic components in Advisor. self.optimization_strategy = optimization_strategy self.default_obj_value = [MAXINT] * self.num_objs self.configurations = list() self.failed_configurations = list() self.perfs = list() self.scale_perc = 5 self.perc = None self.min_y = None self.max_y = None if self.num_constraints > 0: self.constraint_perfs = [ list() for _ in range(self.num_constraints) ] # Init the basic ingredients in Bayesian optimization. self.history_bo_data = history_bo_data self.surrogate_type = surrogate_type self.constraint_surrogate_type = None self.acq_type = acq_type self.acq_optimizer_type = acq_optimizer_type self.init_num = initial_trials self.config_space = config_space self.config_space.seed(self.rng.randint(MAXINT)) self.ref_point = ref_point if initial_configurations is not None and len( initial_configurations) > 0: self.initial_configurations = initial_configurations self.init_num = len(initial_configurations) else: self.initial_configurations = self.create_initial_design( self.init_strategy) self.init_num = len(self.initial_configurations) if use_trust_region: self.history_container = MultiStartHistoryContainer( task_id, self.num_objs, ref_point) elif self.num_objs == 1: self.history_container = HistoryContainer(task_id) else: # multi-objectives self.history_container = MOHistoryContainer(task_id, ref_point) self.surrogate_model = None self.constraint_models = None self.acquisition_function = None self.optimizer = None self.check_setup() self.setup_bo_basics()