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 calcDriftVector(self): """ calculates drift vector. Drift vector is the following vector: u(t) = e(t) + Δv(t), where Δv(t) = v(t) - v'(t) """ # calculate Δv(t) self.dv = VectorOps.subFrom(self.cm.localStatistics, \ self.cm.lastStatistics) # calculate drift vector self.cm.drift = VectorOps.addTo(self.cm.estimate,\ self.dv)
def calc_drift(self): """ calculates drift vector. Drift vector is computed as follows: u(t) = e(t) + delta-v(t), where delta-v(t) = v(t) = v'(t) """ # calculate delta-v self.dv = VectorOps.subFrom(self.cm.localStatistics,\ self.cm.lastStatistics) # calculate drift vector self.cm.drift = VectorOps.addTo(self.cm.estimate, self.dv) # now check if ball is monochromatic if not self.check_ball(self.cm.localStatistics): # if it is not, then send a REP-message to coordinator # (the algorithm here is exactly the same as in REQ_receipt()) self.REQ_receipt()
def calc_drift(self): """ calculates drift vector. Drift vector is computed as follows: u(t) = e(t) + delta-v(t), where delta-v(t) = v(t) = v'(t) """ # calculate delta-v self.dv = VectorOps.subFrom(self.cm.localStatistics,\ self.cm.lastStatistics) # calculate drift vector self.cm.drift = VectorOps.addTo(self.cm.estimate, self.dv) # now check if ball is monochromatic if not self.check_ball(self.cm.localStatistics): # if it is not, then initiate a balancing process, self.coord_elem = self.createBalancingElement(self.node_name,\ self.cm.localStatistics, self.cm.drift, self.weight) # initiating the balancing group with this very element self.bp.addToBalancing(self.coord_elem)
def testSubFrom(self): """ tests the subFrom(self, a, b) method """ self.true_result = [0, 0, 0, 0, 0] self.test_result = VectorOps.subFrom(self.target, self.operand) self.assertEqual(self.true_result, self.test_result)