Esempio n. 1
0
 def calcNodeDriftVector(self):
     """ calculates the drift vector of a node.
     """
     self.weightEstimate = 1.0
     self.ratioW = self.weightEstimate/self.weight
     # compute statistics delta vector.
     # delta = (weight*localStatistics - weightEstimate*localEstimate -
     # (weight - weightEstimate)*globalEstimate) / weight
     self.cm.delta = VectorOps.multAndAdd(self.cm.localStatistics, \
                     self.weight, self.localEstimate)
     VectorOps.multAndAddTo(self.cm.delta, self.ratioW-self.weight,\
                             self.cm.globalV)
     # update drift vector
     VectorOps.cpy(self.cm.drift, self.cm.globalV)
     VectorOps.addTo(self.cm.drift, self.cm.delta)
     VectorOps.multAndAddTo(self.cm.drift, 1.0/self.weight, self.cm.slack)
Esempio n. 2
0
 def calcNodeDriftVector(self):
     """ calculates the drift vector of a node.
     """
     self.weightEstimate = 1.0
     self.ratioW = self.weightEstimate / self.weight
     # compute statistics delta vector.
     # delta = (weight*localStatistics - weightEstimate*localEstimate -
     # (weight - weightEstimate)*globalEstimate) / weight
     self.cm.delta = VectorOps.multAndAdd(self.cm.localStatistics, \
                     self.weight, self.localEstimate)
     VectorOps.multAndAddTo(self.cm.delta, self.ratioW-self.weight,\
                             self.cm.globalV)
     # update drift vector
     VectorOps.cpy(self.cm.drift, self.cm.globalV)
     VectorOps.addTo(self.cm.drift, self.cm.delta)
     VectorOps.multAndAddTo(self.cm.drift, 1.0 / self.weight, self.cm.slack)
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
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()
Esempio n. 6
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()