Пример #1
0
    def setup_bo_basics(self):
        if self.num_objs == 1:
            self.surrogate_model = build_surrogate(func_str=self.surrogate_type,
                                                   config_space=self.config_space,
                                                   rng=self.rng,
                                                   history_hpo_data=self.history_bo_data)
        else:  # multi-objectives
            self.surrogate_model = [build_surrogate(func_str=self.surrogate_type,
                                                    config_space=self.config_space,
                                                    rng=self.rng,
                                                    history_hpo_data=self.history_bo_data)
                                    for _ in range(self.num_objs)]

        if self.num_constraints > 0:
            self.constraint_models = [build_surrogate(func_str=self.constraint_surrogate_type,
                                                      config_space=self.config_space,
                                                      rng=self.rng) for _ in range(self.num_constraints)]

        self.acquisition_function = build_acq_func(func_str=self.acq_type, model=self.surrogate_model,
                                                   constraint_models=self.constraint_models,
                                                   mc_times=self.mc_times, ref_point=self.ref_point)

        self.optimizer = build_optimizer(func_str=self.acq_optimizer_type,
                                         acq_func=self.acquisition_function,
                                         config_space=self.config_space,
                                         rng=self.rng)

        if self.use_trust_region:
            types, bounds = get_types(self.config_space)
            cont_dim = np.sum(types == 0)
            self.turbo_state = TurboState(cont_dim)
Пример #2
0
    def setup_bo_basics(self, acq_type='ei', acq_optimizer_type='local_random'):
        self.surrogate_model = build_surrogate(func_str=self.surrogate_type,
                                               config_space=self.config_space,
                                               rng=self.rng,
                                               history_hpo_data=self.history_bo_data)

        self.acquisition_function = build_acq_func(func_str=acq_type, model=self.surrogate_model)

        self.optimizer = build_optimizer(func_str=acq_optimizer_type,
                                         acq_func=self.acquisition_function,
                                         config_space=self.config_space,
                                         rng=self.rng)
Пример #3
0
    def setup_bo_basics(self):
        """
        Prepare the basic BO components.
        Returns
        -------
        An optimizer object.
        """
        if self.num_objs == 1 or self.acq_type == 'parego':
            self.surrogate_model = build_surrogate(
                func_str=self.surrogate_type,
                config_space=self.config_space,
                rng=self.rng,
                history_hpo_data=self.history_bo_data)
        else:  # multi-objectives
            self.surrogate_model = [
                build_surrogate(func_str=self.surrogate_type,
                                config_space=self.config_space,
                                rng=self.rng,
                                history_hpo_data=self.history_bo_data)
                for _ in range(self.num_objs)
            ]

        if self.num_constraints > 0:
            self.constraint_models = [
                build_surrogate(func_str=self.constraint_surrogate_type,
                                config_space=self.config_space,
                                rng=self.rng)
                for _ in range(self.num_constraints)
            ]

        if self.acq_type in ['mesmo', 'mesmoc', 'mesmoc2', 'usemo']:
            types, bounds = get_types(self.config_space)
            self.acquisition_function = build_acq_func(
                func_str=self.acq_type,
                model=self.surrogate_model,
                constraint_models=self.constraint_models,
                types=types,
                bounds=bounds)
        else:
            self.acquisition_function = build_acq_func(
                func_str=self.acq_type,
                model=self.surrogate_model,
                constraint_models=self.constraint_models,
                ref_point=self.ref_point)
        if self.acq_type == 'usemo':
            self.acq_optimizer_type = 'usemo_optimizer'
        elif self.acq_type.startswith('mesmo'):
            self.acq_optimizer_type = 'mesmo_optimizer'
        self.optimizer = build_optimizer(func_str=self.acq_optimizer_type,
                                         acq_func=self.acquisition_function,
                                         config_space=self.config_space,
                                         rng=self.rng)