def passiveProcess(self, stopper): self.mover.passive(self.skeleton, stopper) # Non-trivial for Smooth moveData = cfiddler.Recv_MoveData(stopper, tag=self.move_channel) node = self.skeleton.getNodeWithIndex(moveData.index) ## REPORT("HELPING", stopper, "FOR NODE #", node.remoteIndex(stopper)) # recording energy-before (should this use periodic neighbor Elements?) neighbors = node.aperiodicNeighborElements(self.skeleton) reportData = [el.energyHomogeneity(self.skeleton) for el in neighbors] reportData += [el.energyShape() for el in neighbors] # move to the position -- self.skeleton is a DeputySkeleton self.skeleton.moveNodeTo( node, primitives.Point(moveData.x, moveData.y)) # Check & send illegality mpitools.Send_Bool(bool(node.illegal()), stopper, tag=self.illegal_channel) # if illegal in any processes, it should be aborted if mpitools.Recv_Bool( stopper, tag=self.verdict_channel): # True:continue, False:abort # recording energy-after reportData += [el.energyHomogeneity(self.skeleton) for el in neighbors] reportData += [el.energyShape() for el in neighbors] # reporting mpitools.Send_DoubleVec(reportData, stopper, tag=self.report_channel) # receiving verdivt, True:stay, False:move back if not mpitools.Recv_Bool(stopper, self.verdict_channel): self.skeleton.moveNodeBack(node) else: # Illegal! self.skeleton.moveNodeBack(node)
def passiveProcess(self, stopper): # the node to move myindex = mpitools.Recv_Int(stopper, tag=self.move_channel) node = self.skeleton.getNodeWithIndex(myindex) self.mover.passive(self.skeleton, node, stopper) # getting no. of move candidates nmoves = mpitools.Recv_Int(stopper, tag=self.move_channel) for i in range(nmoves): moveData = cfiddler.Recv_MoveData(stopper, tag=self.move_channel) ## REPORT("HELPING", stopper, "FOR NODE #", node.remoteIndex(stopper)) # recording energy-before neighbors = node.aperiodicNeighborElements(self.skeleton) reportData = [ el.energyHomogeneity(self.skeleton) for el in neighbors ] reportData += [el.energyShape() for el in neighbors] # move to the position -- self.skeleton is a DeputySkeleton self.skeleton.moveNodeTo(node, primitives.Point(moveData.x, moveData.y)) # Check & send illegality mpitools.Send_Bool(bool(node.illegal()), stopper, tag=self.illegal_channel) # if illegal in any processes, it should be aborted if mpitools.Recv_Bool( stopper, tag=self.verdict_channel): # True:continue, False:abort # recording energy-after reportData += [ el.energyHomogeneity(self.skeleton) for el in neighbors ] reportData += [el.energyShape() for el in neighbors] # reporting mpitools.Send_DoubleVec(reportData, stopper, tag=self.report_channel) # reset for the next one self.skeleton.moveNodeBack(node) ## REPORT("DONE HELPING", moveData.master, " ON NODE #", ## node.remoteIndex(moveData.master)) # receiving verdivt, True:stay, False:move back if mpitools.Recv_Bool(stopper, self.verdict_channel): x, y = mpitools.Recv_DoubleVec(stopper, tag=self.move_channel, size=2) self.skeleton.moveNodeTo(node, primitives.Point(x, y))