Ejemplo n.º 1
0
    def run(self):
        self.GList = []

        # compute cost matrix from all endpoints
        self._calcCostMatrix()

        # solve assignment problem for cost matrix
        if self.solver == "ilp":
            binMatrix = AssignmentSolver.ilp(self.costMatrix)
        if self.solver == "hun":
            binMatrix = AssignmentSolver.hun(self.costMatrix)

        # create new endpoints with matching partners
        for x, y in numpy.argwhere(binMatrix):

            ep1 = self.EList_1[x]
            ep2 = self.EList_2[y]

            newGap = DataStructures.Gap()
            newGap.Ep1 = ep1
            newGap.Ep2 = ep2
            newGap.Position = (numpy.array(ep1.Position) +
                               numpy.array(ep2.Position)) / 2

            self.GList.append(newGap)

        return self.GList