{"id":2765,"library":"scs","title":"SCS: Splitting Conic Solver","description":"SCS (Splitting Conic Solver) is a numerical optimization package for solving large-scale convex cone problems, including linear programs (LPs), second-order cone programs (SOCPs), and semidefinite programs (SDPs). It uses an operator-splitting method (ADMM) with Anderson acceleration for fast convergence. The current version is 3.2.11, with frequent patch releases.","status":"active","version":"3.2.11","language":"en","source_language":"en","source_url":"https://github.com/bodono/scs-python","tags":["optimization","convex-optimization","conic-programming","LP","SOCP","SDP","ADMM","sparse-solvers"],"install":[{"cmd":"pip install scs","lang":"bash","label":"Standard installation"},{"cmd":"pip install scs -Csetup-args=-Dlink_mkl=true","lang":"bash","label":"Installation with MKL Pardiso direct solver (requires MKL)"},{"cmd":"pip install scs -Csetup-args=-Dlink_cudss=true -Csetup-args=-Dint32=true","lang":"bash","label":"Installation with GPU direct sparse solver (requires NVIDIA cuDSS)"}],"dependencies":[{"reason":"Required for numerical arrays (b, c vectors).","package":"numpy","optional":false},{"reason":"Required for sparse matrices (P, A matrices, specifically CSC format).","package":"scipy","optional":false},{"reason":"Optional for MKL Pardiso direct solver backend.","package":"mkl","optional":true},{"reason":"Optional for NVIDIA cuDSS GPU direct solver backend.","package":"cudss","optional":true}],"imports":[{"note":"The primary class `SCS` is typically accessed via the top-level `scs` module import.","wrong":"from scs import SCS (often leads to confusion with the package name in some IDEs or direct usage)","symbol":"SCS","correct":"import scs\nsolver = scs.SCS(data, cone)"}],"quickstart":{"code":"import numpy as np\nimport scipy.sparse as sp\nimport scs\n\n# Define problem dimensions\nm, n = 4, 2\n\n# Create problem data matrices (P, A as sparse CSC, b, c as numpy arrays)\nP = sp.eye(n, format=\"csc\") # Quadratic cost (identity for simplicity)\nA = sp.random(m, n, density=0.5, format=\"csc\", random_state=1)\nb = np.random.randn(m)\nc = np.random.randn(n)\n\ndata = {\"P\": P, \"A\": A, \"b\": b, \"c\": c}\n\n# Define the cone: 'l' for non-negative cone of length m\ncone = {\"l\": m}\n\n# Initialize the SCS solver\nsolver = scs.SCS(data, cone, verbose=False)\n\n# Solve the problem\nsol = solver.solve()\n\nprint(f\"Solver status: {sol['info']['status']}\")\nif sol['info']['status'] == 'solved':\n    print(f\"Primal solution (x): {sol['x']}\")\n    print(f\"Dual solution (y): {sol['y']}\")","lang":"python","description":"This quickstart solves a simple convex cone program with a non-negative cone. It demonstrates how to prepare the problem data (sparse matrices P, A and dense vectors b, c), define the cone, initialize the SCS solver, and retrieve the solution."},"warnings":[{"fix":"Consult the official documentation for detailed installation instructions for desired backends. Ensure all necessary system-level libraries are installed before attempting Python package installation.","message":"Installing SCS with optional backends (MKL, GPU) requires specific `pip install -Csetup-args` flags and pre-installed libraries (e.g., MKL, cuDSS, CUDA Toolkit). A standard `pip install scs` will use the default sparse direct solver (QDLDL), which may not be optimal for performance-critical applications.","severity":"gotcha","affected_versions":"3.x.x and earlier"},{"fix":"Always construct `P` and `A` as `scipy.sparse.csc_matrix` and `b`, `c` as 1D `numpy.ndarray` to ensure optimal performance and avoid implicit conversions.","message":"Problem data `P` and `A` must be `scipy.sparse.csc_matrix`, and `b` and `c` must be `numpy.ndarray`. While SCS attempts conversion, providing data in the correct format directly avoids potential overhead or unexpected behavior.","severity":"gotcha","affected_versions":"3.x.x and earlier"},{"fix":"For new projects, use SCS 3.x or higher, which has improved compatibility. If using older SCS versions, check for `numpy` version requirements in the specific release notes or issues.","message":"SCS versions before 3.x have experienced compatibility issues with newer NumPy versions, sometimes failing installation or requiring specific NumPy versions to be pre-installed.","severity":"gotcha","affected_versions":"<3.0.0"},{"fix":"Utilize the `warm_start` parameter in the `solve()` method when solving a series of problems where the current solution is a good approximation of the next. Pass the `sol` dictionary from a previous solve directly, or provide specific `x, y, s` arrays.","message":"Warm-starting solutions can significantly improve performance for solving sequences of similar problems, but incorrect use or stale warm-start data can lead to slower convergence or suboptimal results.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}