From dd514fbe8632ffda7351187377bd14d66affdfd9 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 7 Jun 2024 16:28:37 +0200 Subject: Add __str__ method to InternalSOSProblem for debugging --- sumofsquares/problems.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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. -- cgit v1.2.1