summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-06-07 16:28:37 +0200
committerNao Pross <np@0hm.ch>2024-06-07 16:28:37 +0200
commitdd514fbe8632ffda7351187377bd14d66affdfd9 (patch)
tree89b9ca63f1d0666519269cdc37adb11e72d2b066
parentImprove __str__ methods of constraints (diff)
downloadsumofsquares-dd514fbe8632ffda7351187377bd14d66affdfd9.tar.gz
sumofsquares-dd514fbe8632ffda7351187377bd14d66affdfd9.zip
Add __str__ method to InternalSOSProblem for debugging
Diffstat (limited to '')
-rw-r--r--sumofsquares/problems.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/sumofsquares/problems.py b/sumofsquares/problems.py
index cd182df..fb25fd9 100644
--- a/sumofsquares/problems.py
+++ b/sumofsquares/problems.py
@@ -309,6 +309,17 @@ class InternalSOSProblem(Problem):
polynomial_symbols: Sequence[Symbol]
solver: Solver
+ def __str__(self):
+ n = len(self.constraints)
+ s = f"Internal SumOfSquares Problem ({self.__class__.__qualname__}):\n\n" \
+ f"minimize {self.cost}\n" \
+ f"subject to ({n} constraint{'s' if n > 1 else ''})\n"
+
+ for i, c in enumerate(self.constraints):
+ s += f"nr. {i}:\n{str(c)}\n\n"
+
+ return s
+
def to_conic_problem(self, state: ExpressionState, verbose: bool = False) -> ConicProblem:
"""
Convert the SOS problem into a Conic program.