diff options
Diffstat (limited to 'sumofsquares/canon.py')
-rw-r--r-- | sumofsquares/canon.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sumofsquares/canon.py b/sumofsquares/canon.py index 94759f2..02c9266 100644 --- a/sumofsquares/canon.py +++ b/sumofsquares/canon.py @@ -7,6 +7,7 @@ from dataclasses import replace from typing_extensions import override from polymatrix.expression.from_ import Expression +from polymatrix.expression.init import init_variable_expr from polymatrix.expressionstate import ExpressionState from .abc import Problem, Solver, Constraint, Result @@ -67,12 +68,9 @@ class Canonicalization(Problem): """ The problem that will be canonicalized """ @override - def solve(self, verbose: bool = False, state: ExpressionState | None = None) -> Result: - if state is None: - state = poly.make_state() - + def solve(self, state: ExpressionState, verbose: bool = False) -> tuple[ExpressionState, Result]: state, internal_prob = self.apply(state) - return internal_prob.solve(verbose) + return internal_prob.solve(state, verbose) @abstractmethod def apply(self, state: ExpressionState) -> tuple[ExpressionState, InternalSOSProblem]: @@ -139,10 +137,12 @@ class PutinarPSatz(Canonicalization): "Degree of domain polynomial is higher than constraint polynomial!" # Degree of multiplier must be even - if d % 2 != 0: + if d.read(state).scalar().constant() % 2 != 0: d += 1 - x = poly.v_stack((1,) + prob.polynomial_variables) + x = poly.v_stack((1,) + tuple( + init_variable_expr(v, state.get_shape(v)) + for v in prob.polynomial_variables)) # FIXME: need to check that there is not a \gamma_{i} already! # TODO: deterministically generate unique names |