Ejemplo n.º 1
0
    def setUp(self):
        self.x0 = Variable('x0', ['a', 'b'])
        self.x1 = Variable('x1', ['a', 'b'])
        self.x2 = Variable('x2', ['a', 'b'])

        self.r0_1 = NAryMatrixRelation([self.x0, self.x1],
                                       np.array([[1, 2], [2, 3]]))
        self.r0_2 = NAryMatrixRelation([self.x0, self.x2],
                                       np.array([[5, 2], [3, 1]]))

        self.sender0 = DummySender()
        self.sender1 = DummySender()
        self.sender2 = DummySender()
        self.a0 = dpop.DpopAlgo(self.x0,
                                parent=None,
                                children=[self.x1.name, self.x2.name],
                                constraints=[],
                                msg_sender=self.sender0,
                                comp_def=MagicMock())
        self.a1 = dpop.DpopAlgo(self.x1,
                                parent=self.x0.name,
                                children=[],
                                constraints=[self.r0_1],
                                msg_sender=self.sender1,
                                comp_def=MagicMock())
        self.a2 = dpop.DpopAlgo(self.x2,
                                parent=self.x0.name,
                                children=[],
                                constraints=[self.r0_2],
                                msg_sender=self.sender2,
                                comp_def=MagicMock())
Ejemplo n.º 2
0
    def setup_method(self):
        self.x0 = Variable("x0", ["a", "b"])
        self.x1 = Variable("x1", ["a", "b"])

        self.r0_1 = NAryMatrixRelation([self.x0, self.x1],
                                       np.array([[1, 2], [4, 3]]))

        self.sender0 = DummySender()
        self.sender1 = DummySender()
        compdef = MagicMock()
        compdef.algo.algo = "dpop"
        compdef.algo.mode = "max"
        self.a0 = dpop.DpopAlgo(
            self.x0,
            parent=None,
            children=[self.x1.name],
            constraints=[],
            comp_def=compdef,
        )
        self.a1 = dpop.DpopAlgo(
            self.x1,
            parent=self.x0.name,
            children=[],
            constraints=[self.r0_1],
            comp_def=compdef,
        )

        self.a0.message_sender = self.sender0
        self.a1.message_sender = self.sender1