Exceptions#
Solver Exceptions#
Exceptions raised by Cvxium’s solvers and their numerical building blocks.
The exceptions fall into four groups:
ProblemInfeasibleError, for a problem shown or judged to have no feasible point.optimizationdefines two subclasses, for a certified and for a suspected infeasibility.NewtonStepError, for a Newton step that cannot be computed, typically because a structured solve met a matrix that is not positive definite.BacktrackingLineSearchErrorand its subclasses, for each way the backtracking line search can fail to accept a step.OptimizationErrorand its subclasses, for a solve that stops before reaching its tolerance. These carry the last (or best) iterate so a caller can recover a partial solution.
ConeBoundaryError stands apart: a cone operation that needs a strictly interior
point was given one on the boundary.
- exception cvxium.exceptions.ProblemInfeasibleError[source]#
Bases:
ExceptionError raised when a problem has, or appears to have, no feasible point.
Raised, for example, when the equality constraints A x = b have no solution because b is not in the range of A, or when Phase I finds no strictly interior point. The subclasses
ProblemCertifiablyInfeasibleErrorandProblemMarginallyFeasibleErrordistinguish a proof of infeasibility from a failure to find a feasible point.
- exception cvxium.exceptions.NewtonStepError(message)[source]#
Bases:
ExceptionError raised when a Newton step cannot be computed.
Raised by the structured linear-system solvers when the purported Hessian (or KKT system) is not positive definite, is singular, or yields a non-finite result. A solver that catches it can fall back rather than take a corrupt step.
- Parameters:
message (str) – Description of the failure.
- exception cvxium.exceptions.BacktrackingLineSearchError(message)[source]#
Bases:
ExceptionBase error for a backtracking line search that cannot accept a step.
The line search raises one of the subclasses, which name the cause:
ConstraintBoundaryError,InvalidDescentDirectionErrororSevereCurvatureError. Catch this class to handle any of them.- Parameters:
message (str) – Description of the failure.
- exception cvxium.exceptions.ConstraintBoundaryError(message)[source]#
Bases:
BacktrackingLineSearchErrorError raised when even tiny steps would leave the feasible region.
Raised by the line search when the largest step that keeps every constraint strictly satisfied is below the minimum step size, so the iterate is pinned against a constraint boundary.
- Parameters:
message (str) – Description of the failure.
- exception cvxium.exceptions.InvalidDescentDirectionError(message, grad_ft_dot_delta_x)[source]#
Bases:
BacktrackingLineSearchErrorError raised when the Newton step is not a descent direction.
A Newton step Δx should satisfy
∇f^T Δx ≤ 0.
When it does not, the Hessian is usually nearly singular and the step was computed inaccurately.
- exception cvxium.exceptions.SevereCurvatureError(message, required_improvement, actual_improvement)[source]#
Bases:
BacktrackingLineSearchErrorError raised when no step size meets the sufficient-decrease condition.
The line search backtracked to its minimum step size without the objective decreasing enough. Usually the linear approximation fails even for small steps, a sign of severe curvature.
- exception cvxium.exceptions.OptimizationError(message, suboptimality, last_iterate)[source]#
Bases:
ExceptionBase error for a solve that stops before reaching its tolerance.
Carries the last iterate and how far it was from optimal, so a caller can inspect or reuse a partial solution.
- exception cvxium.exceptions.CenteringStepError(message, suboptimality, last_iterate, equality_multipliers=None, inequality_multipliers=None)[source]#
Bases:
OptimizationErrorError raised when a centering step of the barrier method fails.
Raised when the Newton step cannot be computed, the line search fails, or the centering Newton iterations do not converge. When available, the error also carries the multiplier estimates at the last iterate.
- Parameters:
message (str) – Description of the failure.
suboptimality (float) – Suboptimality bound of the centering subproblem at
last_iterate.last_iterate (npt.NDArray[np.float64]) – The iterate when the centering step stopped.
equality_multipliers (npt.NDArray[np.float64] | None) – Equality multiplier estimates ν at
last_iterate, when available.inequality_multipliers (npt.NDArray[np.float64] | None) – Inequality multiplier estimates λ at
last_iterate, when available.
- exception cvxium.exceptions.InteriorPointMethodError(message, remaining_steps, suboptimality, last_iterate, result=None)[source]#
Bases:
OptimizationErrorError raised when the interior-point method cannot reach its tolerance.
When available, the error carries the best primal-dual result found before stopping. That result may not meet the soft tolerance, but it is often good enough; inspect its objective and duality gap before re-running with a looser tolerance.
- Parameters:
message (str) – Description of the failure.
remaining_steps (int) – Number of outer barrier steps left in the schedule when the method stopped.
suboptimality (float) – Bound on the suboptimality of
last_iterate.last_iterate (npt.NDArray[np.float64]) – The iterate when the method stopped.
result (SolveResult | None) – The best result found before stopping, when available.
Infeasibility#
- exception cvxium.solvers.optimization.ProblemCertifiablyInfeasibleError(message, result)[source]#
Bases:
ProblemInfeasibleErrorError raised when a problem is certifiably infeasible.
Raised when a feasibility (Phase I) solve certifies that no feasible point exists, typically through a strictly positive dual value of the Phase I problem. Carries the best-effort result of the solve.
- Parameters:
message (str) – Description of the failure, returned by
str.result (SolveResult) – The best-effort result of the solve.
- property solve_result#
Return the best-effort result of the solve.
- Returns:
result – The result given at construction.
- Return type:
- exception cvxium.solvers.optimization.ProblemMarginallyFeasibleError(message, result)[source]#
Bases:
ProblemInfeasibleErrorError raised when a problem may be infeasible but cannot be certified as such.
Raised when a feasibility (Phase I) solve neither finds a strictly feasible point nor certifies infeasibility. Carries the best-effort result of the solve.
- Parameters:
message (str) – Description of the failure, returned by
str.result (SolveResult) – The best-effort result of the solve.
- property solve_result#
Return the best-effort result of the solve.
- Returns:
result – The result given at construction.
- Return type:
Result Access#
- exception cvxium.problems.result.NoObjectiveError[source]#
Bases:
AttributeErrorError raised when objective fields are read from a feasibility result.
- exception cvxium.problems.result.NoDualsError[source]#
Bases:
AttributeErrorError raised when reading multipliers from a result that has none.
- exception cvxium.problems.result.NoDualValueError[source]#
Bases:
AttributeErrorError raised when
dual_valueis read but the solver did not compute one.
Structure#
- exception cvxium.linalg.systems.IncompatibleStructureError[source]#
Bases:
ValueErrorError raised when two
MatrixSystemshapes cannot be summed structurally.Bases of the same shape, or a base and a strictly simpler one, combine through
MatrixSystem.plus; an incompatible pair, such as a banded matrix and a block-diagonal one, raises this rather than silently forming a dense matrix. A low-rank update sits on top of any base, so it never raises this by itself.