diff options
Diffstat (limited to '')
-rw-r--r-- | sumofsquares/__init__.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sumofsquares/__init__.py b/sumofsquares/__init__.py index e6af1e7..bd5ec6a 100644 --- a/sumofsquares/__init__.py +++ b/sumofsquares/__init__.py @@ -53,9 +53,9 @@ Class diagram: Arrows denote inheritance, diamonds indicate composition. ┃ ┃ ┃ ┌─.canon───────────────────────────────────────────────────┐ ┌─.variable─────────────────┐ ┃ ┏━━━polymatrix package━━━━━━━━━┓ ┃ │ │ │ │ ┃ ┃ ┃ - ┃ │ ┌────────────────────┐ │ │ ┌───────────┐ │ ┃ ┃ ┌──────────┐ ┌──────────┐ ┃ - ┃ │ │ Canonicalization │ │ │ │OptVariable│──────────┼──╋───╋─▶│ Variable │ │Expression│ ┃ - ┃ │ └────────────────────┘ │ │ └───────────┘ │ ┃ ┃ └──────────┘ └──────────┘ ┃ + ┃ │ ┌────────────────────┐ │ │ ┌───────────┐ │ ┃ ┃ ┌────────┐ ┌──────────┐ ┃ + ┃ │ │ Canonicalization │ │ │ │OptSymbol │──────────┼──╋───╋─▶│ Symbol │ │Expression│ ┃ + ┃ │ └────────────────────┘ │ │ └───────────┘ │ ┃ ┃ └────────┘ └──────────┘ ┃ ┃ │ ▲ │ │ ▲ │ ┃ ┃ │ ┃ ┃ │ ├────────────────────┐ │ │ │ │ ┃ ┃ ┌─────────┘ ┃ ┃ │ │ │ │ │ │ │ ┃ ┃ ◇ ┃ @@ -97,7 +97,7 @@ def make_problem( cost: Expression | None = None, constraints: Iterable[Constraint] = (), solver: Solver = Solver.CVXOPT, - psatz: type[Canonicalization] | None = None, + psatz: type[Canonicalization] = PutinarPSatz, ) -> SOSProblem: """ Create a sum-of-squares optimization problem. @@ -108,7 +108,13 @@ def make_problem( cost = poly.from_number(0) prob = SOSProblem(cost, constraints, solver) - if psatz is not None: + + needs_psatz = any(c.domain is not None + for c in (constr + for constr in constraints + if isinstance(constr, NonNegative))) + + if needs_psatz: return psatz(SOSProblem(cost, constraints, solver)) return prob |