diff options
Diffstat (limited to 'sumofsquares/mixins/sosexprmixin.py')
-rw-r--r-- | sumofsquares/mixins/sosexprmixin.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sumofsquares/mixins/sosexprmixin.py b/sumofsquares/mixins/sosexprmixin.py new file mode 100644 index 0000000..d0c0d17 --- /dev/null +++ b/sumofsquares/mixins/sosexprmixin.py @@ -0,0 +1,37 @@ +import abc +import polymatrix + +from sumofsquares.sosconstraint.abc import SOSConstraint +from sumofsquares.sosconstraint.initsosconstraint import init_sos_constraint +from sumofsquares.mixins.getsosconstraintmixin import GetSOSConstraintMixin +from sumofsquares.sosexprbase.abc import SOSExprBase + + +class SOSExprMixin(GetSOSConstraintMixin, abc.ABC): + @property + @abc.abstractmethod + def underlying(self) -> SOSExprBase: + ... + + @property + def expr(self) -> polymatrix.Expression: + return self.underlying.expr + + @property + def variables(self) -> polymatrix.Expression: + return self.underlying.variables + + @property + def dependence(self) -> polymatrix.Expression: + return self.underlying.dependence + + @property + def sos_matrix(self) -> polymatrix.Expression: + return self.underlying.sos_matrix + + @property + def sos_constraints(self) -> tuple[SOSConstraint]: + return (init_sos_constraint( + dependence=self.dependence, + constraint=self.underlying.sos_matrix_as_vector, + ),) |