Commit 768432e6 authored by kerry-he's avatar kerry-he
Browse files

Remove zero rows from A

parent 32c1b5e4
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -601,6 +601,7 @@ class QICSSolver(Solver):

    def _solve(self):
        import qics
        import scipy
        
        options = {}

@@ -627,6 +628,21 @@ class QICSSolver(Solver):
        if self.ext.options.timelimit is not None:
            options["max_time"] = self.ext.options.timelimit

        # Remove zero rows from A, and make sure corresponding b is consistent
        JP = list(set(self.int["A"].tocoo().row))
        IP = range(len(JP))
        VP = [1] * len(JP)

        if any([b for (i, b) in enumerate(self.int["b"]) if i not in JP]):
            return Solution(
                primals=None, duals=None, problem=self.ext, solver="PICOS",
                primalStatus=SS_INFEASIBLE, dualStatus=SS_UNKNOWN,
                problemStatus=PS_INFEASIBLE, vectorizedPrimals=True)

        P = scipy.sparse.csr_matrix((VP, (IP, JP)), shape=(len(IP), self.int["A"].shape[0]))
        self.int["A"] = P @ self.int["A"]
        self.int["b"] = P @ self.int["b"]

        # Attempt to solve the problem.
        with self._header(), self._stopwatch():
            model  = qics.Model(**self.int)
@@ -654,7 +670,7 @@ class QICSSolver(Solver):

                if isinstance(constraint, AffineConstraint):
                    if constraint.is_equality():
                        dual = -cvxopt.matrix(result["y_opt"][indices, 0])
                        dual = -cvxopt.matrix((P.T @ result["y_opt"])[indices, 0])
                    else:
                        dual = cvxopt.matrix(result["z_opt"][indices][0])
                elif isinstance(constraint, LMIConstraint):