Example #1
0
 def compute_balanced_vec(self):
     """ computes the balanced vector from the elements that are
     contained in balancing group only.
     @return the balanced vector
     """
     # initialize a balanced vector b
     self.b = [0] * self.mf.getDimension()
     self.total_weight = 0.0
     # compute the balanced vector b
     for elem in self.balancing_group:
         self.w = elem.weight
         self.total_weight += self.w
         self.b = VectorOps.multAndAddTo(self.b, self.w, elem.drift)
     self.b = VectorOps.multBy(self.b, 1.0/self.total_weight)
     return self.b
Example #2
0
 def compute_balanced_vec(self):
     """ computes the balanced vector from the elements that are
     contained in balancing group only.
     @return the balanced vector
     """
     # initialize a balanced vector b
     self.b = [0] * self.mf.getDimension()
     self.total_weight = 0.0
     # compute the balanced vector b
     for elem in self.balancing_group:
         self.w = elem.weight
         self.total_weight += self.w
         self.b = VectorOps.multAndAddTo(self.b, self.w, elem.drift)
     self.b = VectorOps.multBy(self.b, 1.0 / self.total_weight)
     return self.b
Example #3
0
    def computeBalancedVector(self):
        """ computes the balanced_vector.

        b = sum(w(i) * u(i))/sum(w(i)), where node i ε balancing_group.
        """
        # initialize a balanced vector b
        self.b = [0] * self.mf.getDimension()
        self.total_weight = 0.0
        # compute the balanced vector b
        for elem in self.balancing_group:
            self.w = elem.weight
            self.total_weight += self.w
            self.b = VectorOps.multAndAddTo(self.b, self.w, elem.drift)
        self.b = VectorOps.multBy(self.b, 1.0 / self.total_weight)
        # check if ball B(e(t), b) is monochromatic (step 1 of coord)
        if self.mf.isMonochromatic(self.coord.cm.estimate, self.b):
            self.successfulBalancing(self.b)
        else:
            self.unsuccessfulBalancing()
Example #4
0
    def computeBalancedVector(self):
        """ computes the balanced_vector.

        b = sum(w(i) * u(i))/sum(w(i)), where node i ε balancing_group.
        """
        # initialize a balanced vector b
        self.b = [0] * self.mf.getDimension()
        self.total_weight = 0.0
        # compute the balanced vector b
        for elem in self.balancing_group:
            self.w = elem.weight
            self.total_weight += self.w
            self.b = VectorOps.multAndAddTo(self.b, self.w, elem.drift)
        self.b = VectorOps.multBy(self.b, 1.0/self.total_weight)
        # check if ball B(e(t), b) is monochromatic (step 1 of coord)
        if self.mf.isMonochromatic(self.coord.cm.estimate, self.b):
            self.successfulBalancing(self.b)
        else:
            self.unsuccessfulBalancing()
Example #5
0
 def testMultBy(self):
     """ tests the multBy(self, a b) method """
     self.true_result = [1, 1, 1, 1, 1]
     self.test_result = VectorOps.multBy(self.target, self.operand)
     self.assertEquals(self.true_result, self.test_result)
Example #6
0
 def testMultBy(self):
     """ tests the multBy(self, a b) method """
     self.true_result = [1, 1, 1, 1, 1]
     self.test_result = VectorOps.multBy(self.target, self.operand)
     self.assertEquals(self.true_result, self.test_result)