Exemplo n.º 1
0
    def select(self):
        QtQ = self.W.gram().dense_matrix()
        n = self.domain_shape[0]
        err, inv, weights, queries = self._GreedyHierByLv(QtQ,
                                                          n,
                                                          0,
                                                          withRoot=False)

        # form matrix from queries and weights
        row_list = []
        for q, w in zip(queries, weights):
            if w > 0:
                row = np.zeros(self.domain_shape[0])
                row[q[0]:q[1] + 1] = w
                row_list.append(row)
        mat = np.vstack(row_list)
        mat = sparse.csr_matrix(mat) if sparse.issparse(mat) is False else mat

        return matrix.EkteloMatrix(mat)
Exemplo n.º 2
0
    def setUp(self):
        
        self.prng = np.random.RandomState(0)
        
        self.domain = (2,3,4)
        I = lambda n: workload.Identity(n)
        T = lambda n: workload.Total(n)
        P = lambda n: workload.Prefix(n)
        R = lambda n: matrix.EkteloMatrix(self.prng.rand(n,n))
    
        W1 = workload.Kronecker([I(2), T(3), P(4)])
        W2 = workload.Kronecker([T(2), T(3), I(4)])
        W3 = workload.Kronecker([I(2), I(3), T(4)])
        
        self.W = workload.VStack([W1, W2, W3])

        # three representations of Identity matrix
        self.A1 = I(2*3*4)
        self.A2 = workload.Kronecker([I(2),I(3),I(4)])
        self.A3 = workload.Marginals.fromtuples(self.domain, {(0,1,2) : 1.0 })

        self.A4 = workload.Marginals(self.domain, self.prng.rand(8))
        self.A5 = workload.Kronecker([R(2), R(3), R(4)])
Exemplo n.º 3
0
 def strategy(self):
     return matrix.EkteloMatrix(self.ans)
Exemplo n.º 4
0
 def strategy(self):
     tri = np.zeros((self.n, self.n))
     tri[self._mask] = self._params
     X = np.eye(self.n) + tri + tri.T
     A = np.linalg.cholesky(X).T
     return matrix.EkteloMatrix(A)
Exemplo n.º 5
0
 def strategy(self):
     B = sparse.csr_matrix(self._params.reshape(self.p, self.n))
     I = sparse.eye(self.n, format='csr')
     A = sparse.vstack([I, B], format='csr')
     return matrix.EkteloMatrix(A / A.sum(axis=0))
Exemplo n.º 6
0
 def strategy(self):
     A = self._params.reshape(self.shape)
     return matrix.EkteloMatrix(A)
Exemplo n.º 7
0
 def select(self):
     mat = sparse.vstack(
         (self.M_hat, support.complement(self.M_hat, self.grid_size)))
     return matrix.EkteloMatrix(mat)