diff options
-rw-r--r-- | sumofsquares/__init__.py | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/sumofsquares/__init__.py b/sumofsquares/__init__.py index 44dad85..a29b055 100644 --- a/sumofsquares/__init__.py +++ b/sumofsquares/__init__.py @@ -99,7 +99,7 @@ def make_problem( cost: Expression | None = None, constraints: Iterable[Constraint] = (), solver: Solver = Solver.CVXOPT, - psatz: type[Canonicalization] = PutinarPSatz + psatz: type[Canonicalization] | None = None, ) -> SOSProblem: """ Create a sum-of-squares optimization problem. @@ -109,7 +109,10 @@ def make_problem( elif cost is None: cost = poly.from_number(0) - return psatz(SOSProblem(cost, constraints, solver)) + prob = SOSProblem(cost, constraints, solver) + if psatz is not None: + return psatz(SOSProblem(cost, constraints, solver)) + return prob def minimize(cost, *args, **kwargs) -> SOSProblem: @@ -122,18 +125,14 @@ def maximize(cost, *args, **kwargs) -> SOSProblem: return make_problem(-cost, *args, **kwargs) -def solve_problem( - cost: Expression, - constraints: Iterable[Constraint] = (), - solver: Solver = Solver.CVXOPT, - verbose: bool = False, - state: ExpressionState | None = None - ) -> tuple[Problem, Result]: +def solve_problem(*args, verbose: bool = True, **kwargs) -> tuple[Problem, Result]: """ Solve a sum-of-squares optimization problem. - """ - if state is None: - state = poly.make_state() + This function is just a shorthand for + .. py:: - prob = make_problem(cost, constraints, solver) - return prob, prob.solve(verbose) + prob = sos.make_problem(...) + result = prob.solve(verbose) + """ + prob = make_problem(*args, **kwargs) + return prob, prob.solve(verbose=verbose) |