summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sumofsquares/canon.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/sumofsquares/canon.py b/sumofsquares/canon.py
index 3cde57d..109a763 100644
--- a/sumofsquares/canon.py
+++ b/sumofsquares/canon.py
@@ -1,24 +1,18 @@
""" Canonicalization of Problems """
-import math
import polymatrix as poly
from abc import abstractmethod
from dataclassabc import dataclassabc
from dataclasses import replace
-from typing import Sequence
from typing_extensions import override
from polymatrix.expression.from_ import Expression
from polymatrix.expressionstate import ExpressionState
-from polymatrix.statemonad import init_state_monad
-from polymatrix.polymatrix.mixins import PolyMatrixMixin
-from polymatrix.variable import Variable
from .abc import Problem, Solver, Constraint, Result
from .constraints import NonNegative, PositiveSemiDefinite, ExponentialCone
-from .error import AlgebraicError
from .problems import SOSProblem, InternalSOSProblem
-from .variable import OptVariable, from_name as opt_variable_from_name
+from .variable import from_name as opt_variable_from_name
from .utils import partition
@@ -137,7 +131,11 @@ class PutinarPSatz(Canonicalization):
constr_deg = constr.expression.eval({v: 1. for v in prob.variables}).degree()
domain_deg = domain_poly.eval({v: 1. for v in prob.variables}).degree()
+ # Degree of multiplier needs to be an integer
d = constr_deg - domain_deg
+ if d % 2 != 0:
+ d += 1
+
x = poly.v_stack((1,) + prob.polynomial_variables)
# FIXME: proper error here
@@ -163,6 +161,10 @@ class LogDet(Canonicalization):
# TODO: reconsider extension of polymatrix Expression objects to introduce
# logdet expression. The current solution works but is not ideal, as it may
# be a bit counterintuitive.
+
+ # Does this trick work with the det(A) instead of logdet?
+ # No, because then the inequality on the diagonal of Z is not a sum of log
+ # but a product of variables, i.e. non linear.
"""
Create a new problem, whose cost function is the logdet of the given
problem's cost function.