summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-05-03 11:33:51 +0200
committerNao Pross <np@0hm.ch>2024-05-03 11:33:51 +0200
commit51685e602a685b2d6ab320a740f71438ed81817c (patch)
tree28e23b35a9d9e4b16b6dfa3161c6280b23d38def
parentCreate OptVariableExpression (diff)
downloadsumofsquares-51685e602a685b2d6ab320a740f71438ed81817c.tar.gz
sumofsquares-51685e602a685b2d6ab320a740f71438ed81817c.zip
Remove OptVariableExpression, just return a VariableExpression with OptVariableMixin
Diffstat (limited to '')
-rw-r--r--sumofsquares/optvariable.py33
1 files changed, 4 insertions, 29 deletions
diff --git a/sumofsquares/optvariable.py b/sumofsquares/optvariable.py
index cf4e99b..4c687de 100644
--- a/sumofsquares/optvariable.py
+++ b/sumofsquares/optvariable.py
@@ -3,7 +3,7 @@ from typing_extensions import override
from dataclasses import replace
from dataclassabc import dataclassabc
-from polymatrix.expression.expression import Expression, init_expression
+from polymatrix.expression.expression import VariableExpression, init_variable_expression
from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin
from polymatrix.expressionstate.abc import ExpressionState
from polymatrix.polymatrix.abc import PolyMatrix
@@ -39,36 +39,11 @@ class OptVariableImpl(OptVariableMixin):
def init_opt_variable_expr(name, shape):
return OptVariableImpl(name, shape)
-
-class OptVariableExpression(Expression, Variable):
- """
- Expression that is an optimization (decision) variable, i.e. an expression
- that cannot be reduced further.
- """
- @override
- @property
- def name(self):
- return self.underlyng.name
-
- @override
- @property
- def shape(self):
- return self.underlyng.shape
-
-
-@dataclassabc(frozen=True)
-class OptVariableExpressionImpl(OptVariableExpression):
- underlying: ExpressionBaseMixin
-
- def copy(self, underlying: ExpressionBaseMixin) -> Expression:
- return init_expression(underlying)
-
-
-def init_opt_variable_expression(underlying: OptVariableMixin) -> OptVariableExpression:
- return OptVariableExpressionImpl(underlying=underlying)
+def init_opt_variable_expression(underlying: OptVariableMixin) -> VariableExpression:
+ return init_variable_expression(underlying=underlying)
-def from_names(names: str, shape: tuple[int, int] = (1,1)) -> tuple[OptVariableExpression] | OptVariableExpression:
+def from_names(names: str, shape: tuple[int, int] = (1,1)) -> tuple[VariableExpression] | VariableExpression:
""" Construct one or multiple variables from comma separated a list of names. """
variables = tuple(init_opt_variable_expression(
underlying=init_opt_variable_expr(name.strip(), shape))