{"id":2432,"library":"clarabel","title":"Clarabel Conic Interior Point Solver for Rust / Python","description":"Clarabel is an interior point numerical solver for convex optimization problems, implemented in Rust and featuring a Python interface. It efficiently solves a variety of conic programs including Linear Programs (LPs), Quadratic Programs (QPs), Second-Order Cone Programs (SOCPs), Semidefinite Programs (SDPs), and problems with exponential and power cone constraints. The current version is 0.11.1, and the library maintains an active release cadence.","status":"active","version":"0.11.1","language":"en","source_language":"en","source_url":"https://github.com/oxfordcontrol/Clarabel.rs","tags":["optimization","solver","conic programming","quadratic programming","SOCP","SDP","convex optimization","interior point method"],"install":[{"cmd":"pip install clarabel","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required Python version.","package":"python","version":">=3.9","optional":false},{"reason":"Commonly used for numerical array operations with problem data.","package":"numpy","optional":false},{"reason":"Required for sparse matrix (CSC format) representation of problem data.","package":"scipy","optional":false},{"reason":"Optional: Can be used as an interface for modeling problems to be solved by Clarabel.","package":"cvxpy","optional":true}],"imports":[{"symbol":"clarabel","correct":"import clarabel"},{"symbol":"numpy","correct":"import numpy as np"},{"symbol":"sparse","correct":"from scipy import sparse"},{"note":"Classes like DefaultSolver, DefaultSettings, and cone types are typically accessed via the top-level 'clarabel' module after `import clarabel`.","wrong":"from clarabel import DefaultSolver","symbol":"DefaultSolver","correct":"clarabel.DefaultSolver"},{"note":"Prior to version 0.11.0, `__version__` was a callable method. It is now a direct attribute.","wrong":"clarabel.__version__()","symbol":"__version__","correct":"clarabel.__version__"}],"quickstart":{"code":"import clarabel\nimport numpy as np\nfrom scipy import sparse\n\n# Define problem data for a simple QP: minimize 0.5 * x.T * P * x + q.T * x\n# subject to A * x + s = b, s in K\n\nP = sparse.csc_matrix([[3., 1., -1.], [1., 4., 2.], [-1., 2., 5.]])\nP = sparse.triu(P).tocsc() # Clarabel expects upper triangular part in CSC format\nq = np.array([1., 2., -3.])\n\nA = sparse.csc_matrix([\n    [1., 1., -1.], # Equality constraint (ZeroConeT)\n    [0., 1., 0.],  # Inequality constraint (NonnegativeConeT)\n    [0., 0., 1.],  # Inequality constraint (NonnegativeConeT)\n    [0., 0., 0.]   # Placeholder for SOC (SecondOrderConeT)\n])\n\nb = np.array([1., 2., 2., 0.])\n\n# Define cone constraints: ZeroConeT(dim), NonnegativeConeT(dim), SecondOrderConeT(dim)\ncones = [clarabel.ZeroConeT(1), clarabel.NonnegativeConeT(2), clarabel.SecondOrderConeT(1)]\n\n# Instantiate and solve the solver\nsettings = clarabel.DefaultSettings()\nsettings.verbose = False # Disable verbose output\nsolver = clarabel.DefaultSolver(P, q, A, b, cones, settings)\nsolver.solve()\n\n# Print results\nprint(f\"Solution x: {solver.solution.x}\")\nprint(f\"Objective value: {solver.solution.obj_val}\")\nprint(f\"Solver status: {solver.solution.status}\")","lang":"python","description":"This quickstart demonstrates how to define and solve a simple quadratic program (QP) using Clarabel. It shows how to define the objective function matrix (P) and vector (q), constraint matrix (A) and vector (b), and the cone structure (K). The problem data is expected in `numpy` arrays and `scipy.sparse.csc_matrix` format."},"warnings":[{"fix":"Ensure problem data (P, q, A, b) is provided in 64-bit float format (`np.float64`). If 32-bit precision is required, adjust solver settings like `settings.tol_gap_abs` and `settings.tol_gap_rel` accordingly.","message":"Clarabel's default solver settings are optimized for 64-bit float data. Using 32-bit floats (e.g., `np.float32`) may lead to suboptimal performance or numerical inaccuracies unless solver tolerances are explicitly relaxed.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If the cone structure or presolve/chordal decomposition settings need to change, a new solver instance must be created. For allowed data updates, ensure the sparsity pattern and problem dimensions remain constant.","message":"When updating problem data (e.g., in iterative algorithms), modifications to the `cones` array are not permitted. Additionally, data updates are disallowed if `settings.chordal_decomposition_enable = True` or `settings.presolve_enable = True`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always convert sparse matrices to `scipy.sparse.csc_matrix`. For the 'P' matrix, use `P = sparse.triu(P).tocsc()` to ensure correct format and content.","message":"Clarabel expects sparse matrix data (P and A) to be in Compressed Sparse Column (CSC) format, as produced by `scipy.sparse`. For the quadratic objective matrix `P`, only its upper triangular part should be provided in CSC format.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update any code that retrieves the Clarabel version from `clarabel.__version__()` to `clarabel.__version__`.","message":"From Clarabel version 0.11.0 onwards, the version string is accessed via `clarabel.__version__` (an attribute) instead of `clarabel.__version__()` (a method).","severity":"breaking","affected_versions":">=0.11.0"},{"fix":"If experiencing issues with Clarabel as the default in CVXPY, explicitly specify a different solver (e.g., `problem.solve(solver='ECOS')` if ECOS is installed, or `solver='SCS'`). Consider installing ECOS manually if needed with CVXPY >=1.6.","message":"Starting with CVXPY 1.5, Clarabel has become the default interior-point solver, replacing ECOS. CVXPY 1.6 will entirely remove ECOS as a dependency. Users relying on ECOS's specific behavior via CVXPY might experience regressions.","severity":"deprecated","affected_versions":"CVXPY >=1.5 (indirectly affects Clarabel users)"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}