def test_comm_not_enough_place(self): f1 = relation_from_str('f1', 'v1 * 0.5 + v2 + v3', [v1, v2, v3]) cv1 = VariableComputationNode(v1, ['f1']) cv2 = VariableComputationNode(v2, ['f1']) cv3 = VariableComputationNode(v3, ['f1']) cf1 = FactorComputationNode(f1) cg = ComputationsFactorGraph([cv1, cv2, cv3], [cf1]) a1 = AgentDef("a1", capacity=200, default_hosting_cost=1, hosting_costs={ "v1": 0, "v2": 0 }) a2 = AgentDef("a2", capacity=200, default_hosting_cost=1) a1.capacity = 15 agent_mapping = distribute(cg, [a1, a2], hints=None, computation_memory=ms.computation_memory, communication_load=ms.communication_load) # As there is enough not capacity on a1, factor f1 and variable v3 # must go on a2 self.assertEqual(agent_mapping.agent_for('f1'), 'a2') self.assertEqual(agent_mapping.agent_for('v3'), 'a2')
def test_comm(self): f1 = relation_from_str('f1', 'v1 * 0.5 + v2 + v3', [v1, v2, v3]) cv1 = VariableComputationNode(v1, ['f1']) cv2 = VariableComputationNode(v2, ['f1']) cv3 = VariableComputationNode(v3, ['f1']) cf1 = FactorComputationNode(f1) cg = ComputationsFactorGraph([cv1, cv2, cv3], [cf1]) a1 = AgentDef("a1", capacity=200, default_hosting_cost=1, hosting_costs={ "v1": 0, "v2": 0 }) a2 = AgentDef("a2", capacity=200, default_hosting_cost=1) a1.capacity = 1000 agent_mapping = distribute(cg, [a1, a2], hints=None, computation_memory=ms.computation_memory, communication_load=ms.communication_load) # As there is enough capacity on a1, factor f1 must go there (where # most of its variable are already hosted) while v3 must go on a2 to # make sure that all agents are used self.assertEqual(agent_mapping.agent_for('f1'), 'a1') self.assertEqual(agent_mapping.agent_for('v3'), 'a2')