cvxpy-debug
Diagnostic tools for CVXPY optimization problems. When your problem is infeasible, unbounded, or numerically inaccurate, cvxpy-debug tells you why and how to fix it.
Installation
pip install cvxpy-debug
Quick Start
import cvxpy as cp
import cvxpy_debug
# Create an infeasible problem
x = cp.Variable(3, nonneg=True)
constraints = [
cp.sum(x) <= 100,
x[0] >= 50,
x[1] >= 40,
x[2] >= 30, # Sum of minimums = 120 > 100
]
prob = cp.Problem(cp.Minimize(cp.sum(x)), constraints)
# Debug it - automatically solves and diagnoses
report = cvxpy_debug.debug(prob)
Output:
════════════════════════════════════════════════════════════════
INFEASIBILITY REPORT
════════════════════════════════════════════════════════════════
Problem has 4 constraints. Found 4 that conflict.
CONFLICTING CONSTRAINTS
───────────────────────
Constraint Slack needed
──────────────────── ─────────────
sum(x) <= 100 20.0
x[0] >= 50 0.0
x[1] >= 40 0.0
x[2] >= 30 0.0
SUGGESTED FIXES
───────────────
• Increase budget to at least 120
• Reduce one of the minimum bounds
Features
- Infeasibility diagnosis: Find which constraints conflict using IIS (Irreducible Infeasible Subsystem)
- Unboundedness diagnosis: Identify which variables are unbounded and in which direction
- Numerical issues: Detect scaling problems, ill-conditioning, and constraint violations
- Performance analysis: Detect anti-patterns like loop-generated constraints
- Full cone support: Linear, SOC, SDP, and exponential cone constraints
- Human-readable reports: Clear explanations and actionable fix suggestions
Examples
See the examples/ folder for comprehensive usage examples:
Quick Start Examples
basic_infeasibility.py- Diagnose conflicting constraintsbasic_unboundedness.py- Diagnose unbounded objectivesbasic_numerical.py- Diagnose scaling issuesbasic_performance.py- Detect performance anti-patterns
Problem Type Examples
infeasibility_diagnosis.py- Full IIS workflowunboundedness_diagnosis.py- Ray analysis and boundsnumerical_issues.py- Conditioning and violationscone_constraints.py- SOC, PSD, ExpCone examples
Real-World Scenarios
portfolio_optimization.py- Markowitz mean-varianceresource_allocation.py- Budget allocationscheduling.py- Task schedulingregression.py- Constrained regression
API
Main Function
cvxpy_debug.debug(
problem,
solver=None, # Override solver for diagnostic solves
find_minimal_iis=False, # Find minimal conflicting constraint set
include_conditioning=False, # Analyze condition numbers (slower)
include_performance=True, # Include performance analysis
)
Focused Diagnostics
# Infeasibility analysis
cvxpy_debug.debug_infeasibility(problem, report)
# Unboundedness analysis
cvxpy_debug.debug_unboundedness(problem, report)
# Numerical issues analysis
cvxpy_debug.debug_numerical_issues(problem, report)
# Performance analysis
cvxpy_debug.debug_performance(problem, report)
License
Apache 2.0
Metadata
Release files for cvxpy-debug 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cvxpy_debug-0.1.0.tar.gz | 166.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cvxpy_debug-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 214.3 kB
Release files / cvxpy_debug-0.1.0.tar.gz
| Download URL | cvxpy_debug-0.1.0.tar.gz |
|---|---|
| Size | 166.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
899df215baf6c7396f8cd1bf6b3edaa01d89b8cf53f1c419a35c486f7714c51f
|
|
BLAKE2b-256 checksum How to use checksums |
7d6d5000b8b2251534881af061cdf167c38873d12203648335d29a66f3267e3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / cvxpy_debug-0.1.0-py3-none-any.whl
| Download URL | cvxpy_debug-0.1.0-py3-none-any.whl |
|---|---|
| Size | 47.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
942c3c1e3c98bff6172a7e469a297eb7dbc3441c8ebbf6554b433a5fe7593178
|
|
BLAKE2b-256 checksum How to use checksums |
12f4b7b970eaef947230cce3eccdf1cb7df633ab23a7b035d0bb57358fc1074b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|