def calcSlackVector(self, element, b): """ calculates the slack vector adjustments for a particular node. @param element is the element from the node we want to send slack. @param b is the balanced vector. @return is the slack vector for the particular node. """ self.slack = VectorOps.subFrom(VectorOps.mult(b, element.weight),\ VectorOps.mult(element.drift, element.weight)) return self.slack
def recalcEstimateVector(self): """ calculates the estimate vector. """ # init sum of weights in the minimum permitted value # (so as to avoid division with zero) self.sumw = 0.000000000001 # for every single node for node in self.all_vectors: # get the weight and the last statistic vector self.w = float(self.all_vectors[node][0]) self.v = self.all_vectors[node][1] # compute the denominator self.sumw += self.w # and compute the numerator self.cm.estimate = VectorOps.addTo(self.cm.estimate, VectorOps.mult(self.v, self.w)) # calculate the final estimate vector self.cm.estimate = VectorOps.multBy\ (self.cm.estimate, 1.0/self.sumw)