diff options
Diffstat (limited to '')
-rw-r--r-- | sumofsquares/canon.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/sumofsquares/canon.py b/sumofsquares/canon.py index 17ad187..3cde57d 100644 --- a/sumofsquares/canon.py +++ b/sumofsquares/canon.py @@ -14,7 +14,7 @@ from polymatrix.statemonad import init_state_monad from polymatrix.polymatrix.mixins import PolyMatrixMixin from polymatrix.variable import Variable -from .abc import Constraint, Result +from .abc import Problem, Solver, Constraint, Result from .constraints import NonNegative, PositiveSemiDefinite, ExponentialCone from .error import AlgebraicError from .problems import SOSProblem, InternalSOSProblem @@ -22,7 +22,7 @@ from .variable import OptVariable, from_name as opt_variable_from_name from .utils import partition -class Canonicalization: +class Canonicalization(Problem): """ Transform a problem into another problem. """ @@ -31,7 +31,6 @@ class Canonicalization: s = f"Apply canonicalization procedure {self.__class__.__qualname__} to\n" return s + str(self.problem) - @abstractmethod def __call__(self, problem : SOSProblem | None = None) -> SOSProblem: # TODO: is this a good idea? probably not but I don't want to introduce # a new type of class for "horizontal" function in the commutative @@ -48,12 +47,32 @@ class Canonicalization: without having to apply the state. I.e. it is not stateful in the problem. """ + raise NotImplementedError + + @property + @override + def cost(self) -> Expression: + # TODO: error message + raise AttributeError + + @property + @override + def constraints(self) -> Expression: + # TODO: error message + raise AttributeError + + @property + @override + def solver(self) -> Solver: + # TODO: error message + raise AttributeError @property @abstractmethod def problem(self) -> SOSProblem: """ 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() |