예제 #1
0
    def initialize(self, **kwargs):
        # compute embedded domain
        domain = kwargs.get('domain')
        self.n_dims = domain.d
        self.n_embedding_dims = self.config.emb_d
        
        # Determine random embedding matrix
        self.A = np.random.normal(size=(self.n_dims, self.n_embedding_dims))
        self._boundaries = np.array([[l,u] for l,u in zip(domain.l, domain.u)])
        # Compute boundaries on embedded space
        self._boundaries_embedded = self._compute_boundaries_embedding(self._boundaries)
        self._embbeded_domain = ContinuousDomain(l=self._boundaries_embedded[:,0], u=self._boundaries_embedded[:,1])
        self._embbded_solver = ScipySolver(self._embbeded_domain)

        # set model_domain to embbeded_domain
        kwargs['model_domain'] = self._embbeded_domain

        # We manually add x_emb into the data for initial_data        
        A_inv = np.linalg.pinv(self.A)
        
        # Init the x_emb in inital_data
        initial_data = kwargs['initial_data']
        aug_initial_data = []
        add_data = np.empty(shape=(), dtype=self.dtype)
        for ea_d in initial_data:
            add_data['x_emb'] = A_inv.dot(ea_d['x'])
            
            aug_data_dtype = join_dtypes(ea_d.dtype, add_data.dtype)
            ea_aug_data = join_dtype_arrays(ea_d, add_data, aug_data_dtype).view(np.recarray)
            
            aug_initial_data.append(ea_aug_data)
        kwargs['initial_data'] = aug_initial_data
        super().initialize(**kwargs)
예제 #2
0
    def __init__(self, bench, path=None, min_value=-np.inf):
        super().__init__(path)
        self._bench = bench
        info = bench.get_meta_information()
        self._max_value = -info['f_opt']

        l = np.array([b[0] for b in info['bounds']])
        u = np.array([b[1] for b in info['bounds']])
        self._domain = ContinuousDomain(l, u)
        self._x0 = l + 0.1 * self._domain.range
        self._min_value = min_value
예제 #3
0
def get_subspace(effective_dimensions):
    """
        Calculates the effective search domain Y as given in the REMBO paper
        $$
         Y = [ −1/eps* max{log(de), 1}, 1/eps *  max{log(de), 1} ] ^ de
        $$
    :param effective_dimensions:
    :return:
    """
    eps = np.log(effective_dimensions) / np.sqrt(effective_dimensions) * (
        2.)  # This modifies the chance that we get a bad entry!

    span_high = np.ones((effective_dimensions, ))
    span_high = np.log(span_high)
    span_high = np.maximum(span_high, 1) / eps

    return ContinuousDomain(-1 * span_high, span_high)
예제 #4
0
    def __init__(self, path=None):
        super().__init__(path)

        if not isinstance(self._domain, ContinuousDomain):
            raise Exception("Can only augment a ContinuousDomain!")
        self._orig_domain = self._domain

        l = np.concatenate((self._domain.l, -np.ones(self.config.aug_d)))
        u = np.concatenate((self._domain.u, np.ones(self.config.aug_d)))
        total_d = self._domain.d + self.config.aug_d

        # define permutation
        self._per = np.arange(total_d)
        if self.config.random_permutation:
            self._per = np.random.permutation(total_d)
        # compute inverse permutation
        self._inv_per = np.argsort(self._per)

        self._domain = ContinuousDomain(l[self._per],u[self._per])
        self._x0 = np.concatenate((self._x0, np.zeros(self.config.aug_d)))
예제 #5
0
    def initialize(self, **kwargs):
        # compute embedded domain
        domain = kwargs.get('domain')
        self.n_dims = domain.d
        self.n_embedding_dims = self.config.emb_d

        # Determine random embedding matrix
        self.A = np.random.normal(size=(self.n_dims, self.n_embedding_dims))
        self._boundaries = np.array([[l, u]
                                     for l, u in zip(domain.l, domain.u)])
        # Compute boundaries on embedded space
        self._boundaries_embedded = self._compute_boundaries_embedding(
            self._boundaries)
        self._embbeded_domain = ContinuousDomain(
            l=self._boundaries_embedded[:, 0],
            u=self._boundaries_embedded[:, 1])
        self._embbded_solver = ScipySolver(self._embbeded_domain)

        # set model_domain to embbeded_domain
        kwargs['model_domain'] = self._embbeded_domain
        super().initialize(**kwargs)
 def __init__(self, fn):
     super().__init__(path=None)
     self.fn = fn
     self.mlflow_logging = self.fn.mlflow_logging
     dim = self.fn.domain.dimension
     L = []
     U = []
     # Number of points per dimension
     n_points = []
     # Go through each domain of the dimension and find the l and u
     for d in self.fn.domain.combined_domain:
         L.append(np.min(d))
         U.append(np.max(d))
         n_points.append(len(d))
         
     self._domain = ContinuousDomain(np.array(L), np.array(U))
     #GridSolverConfig.points_per_dimension = np.max(n_points)
     
     RemboConfig.emb_d = self.fn.get_emb_dim()
     
     # ??
     #self._domain = DiscreteDomain(np.array([[0.0, 0.0], [1.0, 1.0]]))
     
     self._max_value = -self.mlflow_logging.y_opt
예제 #7
0
 def __init__(self, path=None):
     super().__init__(synthetic_functions.Camelback(), path)
     # overwrite domain to get a reasonable range of function values
     self._domain = ContinuousDomain(np.array([-2, -1]), np.array([2, 1]))