diff options
-rw-r--r-- | sumofsquares/problems.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sumofsquares/problems.py b/sumofsquares/problems.py index f16eac7..52a36ca 100644 --- a/sumofsquares/problems.py +++ b/sumofsquares/problems.py @@ -249,7 +249,8 @@ class SOSProblem(Problem): "your vector)") for row in range(nrows): - state, deg = c.expression.linear_monomials(x).degree().max().apply(state) + row_expr = c.expression[row, :] + state, deg = row_expr.linear_monomials(x).degree().max().apply(state) d = deg.scalar().constant() # Polynomial non-negativity contraints is converted to PSD @@ -261,12 +262,12 @@ class SOSProblem(Problem): f"because it has degree {deg.scalar().constant()}, which " "is not even.") - cnew = c.expression.quadratic_in(x).symmetric() + cnew = row_expr.quadratic_in(x).symmetric() constraints.append(PositiveSemiDefinite(cnew)) # A normal (affine) constraint else: - constraints.append(c) + constraints.append(replace(c, expression=row_expr)) elif isinstance(c, PositiveSemiDefinite): state, pm = c.expression.cache().apply(state) @@ -426,7 +427,7 @@ class InternalSOSProblem(Problem): elif isinstance(c, ExponentialCone): # Interpret row-wise - dims["e"].extend(tuple(1 for _ in range(nrows))) + dims["e"].append(nrows) for i in range(nrows): constraints["e"].append(( tuple(m[i, :] for m in linear), |