Solvers API#

Entry points. First-order solves are delegated to spacecore.optimize; run_cvxpy_solver is the reference backend.

sdplab.solvers.OptimizeResult

Uniform result of sdplab.solvers.run_regularized_solver().

sdplab.solvers.run_regularized_solver

Optimize a regularized dual objective with the matching backend driver.

sdplab.solvers.run_cvxpy_solver

Solve a Hermitian-domain SDP through CVXPY in per-constraint form.

class sdplab.solvers.OptimizeResult(dual, converged, num_iters, final_loss, final_grad_norm, elapsed_seconds, loss_history=None, grad_norm_history=None, primal=None, raw=None, extra=<factory>)[source]#

Bases: object

Uniform result of sdplab.solvers.run_regularized_solver().

final_loss and loss_history report the maximized dual objective \(D_\varepsilon\), regardless of the minimization sign handling inside the underlying optimizer. raw carries the untranslated result of the backend that ran (a SciPy OptimizeResult, a spacecore OptaxResult, or a PredCorrResult).

Parameters:
  • dual (Any)

  • converged (bool)

  • num_iters (int)

  • final_loss (float)

  • final_grad_norm (float)

  • elapsed_seconds (float)

  • loss_history (list[float] | None)

  • grad_norm_history (list[float] | None)

  • primal (Any)

  • raw (Any)

  • extra (dict)

dual: Any#
converged: bool#
num_iters: int#
final_loss: float#
final_grad_norm: float#
elapsed_seconds: float#
loss_history: list[float] | None = None#
grad_norm_history: list[float] | None = None#
primal: Any = None#
raw: Any = None#
extra: dict#
summary()[source]#

Return a one-paragraph human-readable summary.

Return type:

str

sdplab.solvers.run_regularized_solver(problem, init_dual=None, *, method=None, opt=None, learning_rate=0.01, max_iter=1000, tol=1e-06, verbose=1, **kwargs)[source]#

Optimize a regularized dual objective with the matching backend driver.

Parameters:
  • problem (BoundDualFunctional) – The BoundDualFunctional to maximize; its eps_val and normalized select the strength and the primal recovery.

  • init_dual – Initial dual iterate, a plain cod element. Defaults to zeros.

  • method (str | None) – "scipy" or "optax". None selects "optax" on a JAX backend and "scipy" otherwise.

  • opt – Optax optimizer for the optax route (default optax.adam(learning_rate)).

  • **kwargs – Forwarded to the underlying driver (spacecore.minimize_scipy() / spacecore.minimize_optax()).

  • learning_rate (float)

  • max_iter (int)

  • tol (float)

  • verbose (int)

Returns:

An OptimizeResult whose final_loss/loss_history report the maximized dual value \(D_\varepsilon\) and whose raw field carries the untranslated backend result.

Return type:

OptimizeResult

sdplab.solvers.run_cvxpy_solver(sdp, solver='MOSEK', verbose=False, return_problem=False, *args, **kwargs)[source]#

Solve a Hermitian-domain SDP through CVXPY in per-constraint form.

Parameters:
  • sdp (SDPProblem) – Problem data (C, A, b) with a Hermitian domain. A is a ConstraintOp (plain LinOp inputs are wrapped by SDPProblem).

  • solver (str) – CVXPY solver name, e.g. "MOSEK" or "CLARABEL".

  • verbose (bool) – Whether CVXPY prints solver progress.

  • return_problem (bool) – Also return the cvxpy.Problem.

  • *args – Extra positional arguments passed to Problem.solve.

  • **kwargs – Extra keyword arguments passed to Problem.solve.

Returns:

the optimized primal element of dom and the equality dual reassembled into cod. With return_problem the cvxpy.Problem is appended.

Return type:

(X, y) in the original problem context

Raises:
  • TypeError – If sdp is not an SDPProblem.

  • NotImplementedError – If the domain is not a single Hermitian space.

  • ValueError – If the solver does not return an optimal solution.