def __init__( self, space, seed=None, n_initial_points=20, n_ei_candidates=24, gamma=0.25, equal_weight=False, prior_weight=1.0, full_weight_num=25, max_retry=100, parallel_strategy=None, ): if n_initial_points < 2: n_initial_points = 2 logger.warning( "n_initial_points %s is not valid, set n_initial_points = 2", str(n_initial_points), ) if n_ei_candidates < 1: n_ei_candidates = 1 logger.warning( "n_ei_candidates %s is not valid, set n_ei_candidates = 1", str(n_ei_candidates), ) if parallel_strategy is None: parallel_strategy = { "of_type": "StatusBasedParallelStrategy", "strategy_configs": { "broken": { "of_type": "MaxParallelStrategy", }, }, } self.strategy = strategy_factory.create(**parallel_strategy) super(TPE, self).__init__( space, seed=seed, n_initial_points=n_initial_points, n_ei_candidates=n_ei_candidates, gamma=gamma, equal_weight=equal_weight, prior_weight=prior_weight, full_weight_num=full_weight_num, max_retry=max_retry, parallel_strategy=parallel_strategy, )
def create_strategy(self, config=None, **kwargs): """Create the parallel strategy based on config. Parameters ---------- config: dict, optional The configuration for the parallel strategy. ``self.config`` will be used if ``config`` is ``None``. kwargs: dict Values to override strategy configuration. """ config = copy.deepcopy(config or self.config) config.update(kwargs) return strategy_factory.create(**self.config)
def __init__( self, space, seed=None, min_points_in_model=None, top_n_percent=15, num_samples=64, random_fraction=1 / 3, bandwidth_factor=3, min_bandwidth=1e-3, parallel_strategy=None, ): # pylint: disable=too-many-arguments if parallel_strategy is None: parallel_strategy = { "of_type": "StatusBasedParallelStrategy", "strategy_configs": { "broken": { "of_type": "MaxParallelStrategy", }, }, } self.strategy = strategy_factory.create(**parallel_strategy) super().__init__( space, seed=seed, min_points_in_model=min_points_in_model, top_n_percent=top_n_percent, num_samples=num_samples, random_fraction=random_fraction, bandwidth_factor=bandwidth_factor, min_bandwidth=min_bandwidth, parallel_strategy=parallel_strategy, ) self.trial_meta = {} self.trial_results = {} self.iteration = 0 self.iterations = [] fidelity_index = self.fidelity_index if fidelity_index is None: raise RuntimeError(SPACE_ERROR) fidelity_dim = self.space[fidelity_index] fidelity_dim: Fidelity = space[self.fidelity_index] # NOTE: This isn't a Fidelity, it's a TransformedDimension<Fidelity> from orion.core.worker.transformer import TransformedDimension # NOTE: Currently bypassing (possibly more than one) `TransformedDimension` wrappers to get # the 'low', 'high' and 'base' attributes. while isinstance(fidelity_dim, TransformedDimension): fidelity_dim = fidelity_dim.original_dimension assert isinstance(fidelity_dim, Fidelity) self.min_budget = fidelity_dim.low self.max_budget = fidelity_dim.high self.eta = fidelity_dim.base self._setup()
def __init__( self, space: Space, seed: int | Sequence[int] | None = None, n_initial_points: int = 20, n_ei_candidates: int = 24, gamma: float = 0.25, equal_weight: bool = False, prior_weight: float = 1.0, full_weight_num: int = 25, max_retry: int = 100, parallel_strategy: dict | None = None, ): if n_initial_points < 2: n_initial_points = 2 logger.warning( "n_initial_points %s is not valid, set n_initial_points = 2", str(n_initial_points), ) if n_ei_candidates < 1: n_ei_candidates = 1 logger.warning( "n_ei_candidates %s is not valid, set n_ei_candidates = 1", str(n_ei_candidates), ) if parallel_strategy is None: parallel_strategy = { "of_type": "StatusBasedParallelStrategy", "strategy_configs": { "broken": { "of_type": "MaxParallelStrategy", }, }, } self.strategy: ParallelStrategy = strategy_factory.create(**parallel_strategy) super().__init__( space, seed=seed, n_initial_points=n_initial_points, n_ei_candidates=n_ei_candidates, gamma=gamma, equal_weight=equal_weight, prior_weight=prior_weight, full_weight_num=full_weight_num, max_retry=max_retry, parallel_strategy=parallel_strategy, ) # TODO: Setting the attributes here so their types are registered. Need to get rid of # overlap with super().__init__ somehow. self.seed = seed self.n_initial_points = n_initial_points self.n_ei_candidates = n_ei_candidates self.gamma = gamma self.equal_weight = equal_weight self.prior_weight = prior_weight self.full_weight_num = full_weight_num self.max_retry = max_retry self.parallel_strategy = parallel_strategy self._verify_space()