On this page:
1.1 Installing
1.2 Your first solve
1.3 Running the examples
9.2.0.5

1 Getting started🔗ℹ

1.1 Installing🔗ℹ

The package ships a pre-built native SCS library (version 3.2.11, with LAPACK and both linear-system solvers), so installing the Racket package is all that is needed:

  raco pkg install scs

To work from a checkout of the source repository instead:

  raco pkg install --copy ./scs

The repository also provides a Nix flake that builds the package, runs the test suite, and drops you into a development shell with Racket, the bindings, and the upstream Python scs (handy for cross-checking results):

  nix build      # build + run tests and examples

  nix develop    # dev shell

Solver workspaces are reclaimed by Racket’s garbage collector, so user code never allocates or frees native memory directly when using the high-level scs API.

1.2 Your first solve🔗ℹ

A complete program that minimizes a linear objective over a box, then prints the solution:

(require scs)
 
(define result
  (solve #:A (scs:matrix 4 2
                          1 0      ; x0 <= 1
                          0 1      ; x1 <= 1
                         -1 0      ; x0 >= 0
                          0 -1)    ; x1 >= 0
         #:b #(1.0 1.0 0.0 0.0)
         #:c #(-1.0 -1.0)          ; maximize x0 + x1
         #:cone (make-cone #:positive 4)))
 
(scs-result-status result)        ; "solved"
(scs-result-x result)             ; #(1.0 1.0)

The four ingredients of every problem are the constraint matrix #:A, the right-hand side #:b, the objective #:c (plus an optional quadratic #:P), and the cone #:cone. Guide explains each in turn; Examples walks through complete, runnable programs.

1.3 Running the examples🔗ℹ

Every worked example in Examples lives in the package’s "scs/examples/" directory as a literate program that provides a run-example thunk, with a companion harness in "scs/examples/test/". From a checkout you can run an example’s tests or its main:

  raco test scs/examples/test/01-linear-program.rkt

  racket scs/examples/test/01-linear-program.rkt