def actions_distance(self, distance):
     def entries(i, j):
         a1 = self.actions[i]
         a2 = self.actions[j]
         return distance(a1, a2)
     K = len(self.actions)
     return construct_matrix((K, K), entries)
Exemple #2
0
    def actions_distance(self, distance):
        def entries(i, j):
            a1 = self.actions[i]
            a2 = self.actions[j]
            return distance(a1, a2)

        K = len(self.actions)
        return construct_matrix((K, K), entries)
def get_domain(H, W, noise=0):
    """ returns points, distance """
    points = []
    for i, j in itertools.product(range(H), range(W)):
        p = np.array((i, j))
        p = p + np.random.randn(2) * noise
        points.append(p) 

    distance = lambda p1, p2: np.linalg.norm(np.array(p1) - np.array(p2))
    N = H * W
    D = construct_matrix((N, N), lambda i, j: distance(points[i], points[j]))
    return points, D
Exemple #4
0
 def get_distance_matrix(self, plans, action_distance):
     n = len(plans)
     D_ij = lambda i, j: self.plan_distance(plans[i], plans[j],
                                            action_distance)
     D = construct_matrix((n, n), D_ij)
     return plans, D
 def get_distance_matrix(self, plans, action_distance):
     n = len(plans)
     D_ij = lambda i, j: self.plan_distance(plans[i], plans[j], action_distance)
     D = construct_matrix((n, n), D_ij)
     return plans, D