SCS: Splitting Conic Solver

3.2.11 · active · verified Fri Apr 10

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.

Warnings

Install

Imports

Quickstart

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.

import numpy as np
import scipy.sparse as sp
import scs

# Define problem dimensions
m, n = 4, 2

# Create problem data matrices (P, A as sparse CSC, b, c as numpy arrays)
P = sp.eye(n, format="csc") # Quadratic cost (identity for simplicity)
A = sp.random(m, n, density=0.5, format="csc", random_state=1)
b = np.random.randn(m)
c = np.random.randn(n)

data = {"P": P, "A": A, "b": b, "c": c}

# Define the cone: 'l' for non-negative cone of length m
cone = {"l": m}

# Initialize the SCS solver
solver = scs.SCS(data, cone, verbose=False)

# Solve the problem
sol = solver.solve()

print(f"Solver status: {sol['info']['status']}")
if sol['info']['status'] == 'solved':
    print(f"Primal solution (x): {sol['x']}")
    print(f"Dual solution (y): {sol['y']}")

view raw JSON →