Solvers API#
Entry points. First-order solves are delegated to spacecore.optimize;
run_cvxpy_solver is the reference backend.
Uniform result of |
|
Optimize a regularized dual objective with the matching backend driver. |
|
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:
objectUniform result of
sdplab.solvers.run_regularized_solver().final_lossandloss_historyreport the maximized dual objective \(D_\varepsilon\), regardless of the minimization sign handling inside the underlying optimizer.rawcarries the untranslated result of the backend that ran (a SciPyOptimizeResult, a spacecoreOptaxResult, or aPredCorrResult).- 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#
- 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
BoundDualFunctionalto maximize; itseps_valandnormalizedselect the strength and the primal recovery.init_dual – Initial dual iterate, a plain
codelement. Defaults to zeros.method (str | None) –
"scipy"or"optax".Noneselects"optax"on a JAX backend and"scipy"otherwise.opt – Optax optimizer for the
optaxroute (defaultoptax.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
OptimizeResultwhosefinal_loss/loss_historyreport the maximized dual value \(D_\varepsilon\) and whoserawfield carries the untranslated backend result.- Return type:
- 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.Ais aConstraintOp(plainLinOpinputs are wrapped bySDPProblem).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
domand the equality dual reassembled intocod. Withreturn_problemthecvxpy.Problemis appended.- Return type:
(X, y)in the original problem context- Raises:
TypeError – If
sdpis not anSDPProblem.NotImplementedError – If the domain is not a single Hermitian space.
ValueError – If the solver does not return an optimal solution.