diff options
author | Nao Pross <np@0hm.ch> | 2024-06-02 12:50:22 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-06-02 12:50:22 +0200 |
commit | 56cd34cade0da3744260648eb1c7635406a3761a (patch) | |
tree | 777fcc3155b1a5c33f4b0f9f0ce0795b3a44fc76 | |
parent | Add numpy and sympy as dependencies (diff) | |
download | sumofsquares-56cd34cade0da3744260648eb1c7635406a3761a.tar.gz sumofsquares-56cd34cade0da3744260648eb1c7635406a3761a.zip |
Fix PSatz canon multiplier degrees
Diffstat (limited to '')
-rw-r--r-- | sumofsquares/canon.py | 16 |
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. |