def __init__(self, domain: Domain, seed: int = None): """Initialise the :class:`RandomSearch` search space. Args: domain: :class:`Domain`. The domain of the objective function. It will be sampled uniformly using the :py:meth:`sample()` method of the :class:`Domain`. seed: (optional) :obj:`int`. The seed for the domain sampling. """ if seed is not None: domain = Domain(domain.as_dict(), seed=seed) super(RandomSearch, self).__init__(domain)
def __init__(self, domain, seed=None): """Initialise the optimiser's domain. Args: domain: :class:`Domain`. The domain of the objective function. seed: (optional) :obj:`int`. The seed of the optimiser. Used for reproducibility purposes. """ np.random.seed(seed) domain = Domain(domain.as_dict(), seed=seed) super(BayesianOptimisation, self).__init__(domain) converted_and_mappers = self._convert_to_gpyopt_domain(self.domain) self.gpyopt_domain, self._categorical_value_mapper, self._discrete_type_mapper = converted_and_mappers self._inv_categorical_value_mapper = { name: {v: k for k, v in mapping.items()} for name, mapping in self._categorical_value_mapper.items() } self._data_x = np.array([[]]) self._data_fx = np.array([[]]) self.__is_empty_data = True
def test_as_dict(): dict_domain = {"a": {"b": [2, 3]}, "c": [0, 0.1]} domain = Domain(dict_domain) assert domain.as_dict() == dict_domain