From f1c5af5c23efd6830b5ac47e0d9cb9cde21fe9bd Mon Sep 17 00:00:00 2001 From: jinningwang Date: Thu, 14 Nov 2024 22:26:20 -0500 Subject: [PATCH] Fix OModel.Param.evaluate when its value is a number --- ams/opt/omodel.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ams/opt/omodel.py b/ams/opt/omodel.py index 831b47d6..d81f9143 100644 --- a/ams/opt/omodel.py +++ b/ams/opt/omodel.py @@ -359,7 +359,10 @@ def evaluate(self): self.v = sps.csr_matrix(self.v) # Create the cvxpy.Parameter object - self.optz = cp.Parameter(shape=self.v.shape, **config) + if isinstance(self.v, np.ndarray): + self.optz = cp.Parameter(shape=self.v.shape, **config) + else: + self.optz = cp.Parameter(**config) self.optz.value = self.v except ValueError: msg = f"Parameter <{self.name}> has non-numeric value, "