3 Reference
3.1 High-level API
| (require scs) | package: scs |
The scs module re-exports the matrix builders under the scs: prefix together with the cone, settings, and solve API.
3.1.1 Matrices and vectors
procedure
(scs:matrix nrow ncol val ...) → any/c
nrow : exact-nonnegative-integer? ncol : exact-nonnegative-integer? val : real?
procedure
(scs:sparse-matrix nrow ncol triple ...) → any/c
nrow : exact-nonnegative-integer? ncol : exact-nonnegative-integer?
triple :
(list/c exact-nonnegative-integer? exact-nonnegative-integer? real?)
procedure
(scs:matrix-ref m i j) → real?
m : any/c i : exact-nonnegative-integer? j : exact-nonnegative-integer?
procedure
m : any/c
procedure
m : any/c
procedure
(scs:matrix-x->vector m) → (vectorof real?)
m : any/c
procedure
m : any/c
procedure
v : (or/c (vectorof real?) (listof real?))
procedure
(scs:float-ptr->vector ptr len) → (vectorof real?)
ptr : cpointer? len : exact-nonnegative-integer?
3.1.2 Cones
procedure
(make-cone [ #:zero z #:positive l #:box-lower box-lower #:box-upper box-upper #:soc soc #:psd psd #:complex-psd complex-psd #:exp-primal exp-primal #:exp-dual exp-dual #:power power]) → scs-cone? z : exact-nonnegative-integer? = 0 l : exact-nonnegative-integer? = 0 box-lower : (listof real?) = '() box-upper : (listof real?) = '() soc : (listof exact-nonnegative-integer?) = '() psd : (listof exact-nonnegative-integer?) = '() complex-psd : (listof exact-nonnegative-integer?) = '() exp-primal : exact-nonnegative-integer? = 0 exp-dual : exact-nonnegative-integer? = 0 power : (listof real?) = '()
3.1.3 Settings
procedure
(make-settings [ #:verbose? verbose? #:normalize? normalize? #:max-iters max-iters #:eps-abs eps-abs #:eps-rel eps-rel #:eps-infeas eps-infeas #:time-limit-secs time-limit-secs #:warm-start? warm-start?]) → scs-settings? verbose? : boolean? = #f normalize? : boolean? = #t max-iters : (or/c #f exact-positive-integer?) = #f eps-abs : (or/c #f real?) = #f eps-rel : (or/c #f real?) = #f eps-infeas : (or/c #f real?) = #f time-limit-secs : (or/c #f real?) = #f warm-start? : boolean? = #f
3.1.4 Solving
procedure
(solve #:A A #:b b #:c c #:cone cone [ #:P P #:settings settings #:indirect? indirect? #:warm-start warm]) → scs-result? A : any/c b : (or/c (vectorof real?) (listof real?)) c : (or/c (vectorof real?) (listof real?)) cone : scs-cone? P : (or/c any/c #f) = #f settings : (or/c scs-settings? #f) = #f indirect? : boolean? = #f warm : exact-integer? = 0
struct
(struct scs-result ( exit-flag status status-val x y s pobj dobj gap iter solve-time setup-time) #:transparent) exit-flag : exact-integer? status : string? status-val : exact-integer? x : (vectorof real?) y : (vectorof real?) s : (vectorof real?) pobj : real? dobj : real? gap : real? iter : exact-integer? solve-time : real? setup-time : real?
procedure
r : scs-result?
procedure
(scs-version) → string?
3.2 Contracted FFI layer
| (require scs/foreign) | package: scs |
scs/foreign exposes the SCS cstructs and a contracted view of the C entry points, for callers building problems by hand or driving warm-started re-solves. The cstructs (make-scs-matrix, make-scs-data, make-scs-cone, make-scs-solution, new-scs-settings, new-scs-info) and their accessors are re-exported from the raw layer; make-cone and make-settings from scs build the cone and settings structs ergonomically.
3.2.1 Cstructs
The cstructs mirror the SCS C API (scs.h, SCS 3.2.11) one-to-one. Each provides a positional constructor (make-_), a predicate, and field accessors/mutators; the two configuration structs additionally provide a keyword constructor (new-_) that defaults every field to a type-appropriate zero. Most callers should prefer make-cone, make-settings, and solve from scs and reach for these only when driving the C API directly. Pointer fields store raw addresses, so a value placed in one must be kept alive with retain! for as long as the owning struct is live.
procedure
(make-scs-matrix x i p m n) → scs-matrix?
x : (or/c cpointer? #f) i : (or/c cpointer? #f) p : (or/c cpointer? #f) m : exact-integer? n : exact-integer?
procedure
(scs-matrix? v) → boolean?
v : any/c
procedure
(make-scs-data m n A P b c) → scs-data?
m : exact-integer? n : exact-integer? A : scs-matrix? P : (or/c scs-matrix? cpointer? #f) b : (or/c cpointer? #f) c : (or/c cpointer? #f)
procedure
v : any/c
procedure
(make-scs-cone z l bu bl bsize q qsize s ssize cs cssize ep ed p psize) → scs-cone? z : exact-integer? l : exact-integer? bu : (or/c cpointer? #f) bl : (or/c cpointer? #f) bsize : exact-integer? q : (or/c cpointer? #f) qsize : exact-integer? s : (or/c cpointer? #f) ssize : exact-integer? cs : (or/c cpointer? #f) cssize : exact-integer? ep : exact-integer? ed : exact-integer? p : (or/c cpointer? #f) psize : exact-integer?
procedure
v : any/c
procedure
(make-scs-solution x y s) → scs-solution?
x : (or/c cpointer? #f) y : (or/c cpointer? #f) s : (or/c cpointer? #f)
procedure
(scs-solution? v) → boolean?
v : any/c
procedure
(new-scs-settings [ #:normalize normalize #:scale scale #:adaptive_scale adaptive_scale #:rho_x rho_x #:max_iters max_iters #:eps_abs eps_abs #:eps_rel eps_rel #:eps_infeas eps_infeas #:alpha alpha #:time_limit_secs time_limit_secs #:verbose verbose #:warm_start warm_start #:acceleration_lookback acceleration_lookback #:acceleration_interval acceleration_interval #:write_data_filename write_data_filename #:log_csv_filename log_csv_filename]) → scs-settings? normalize : exact-integer? = 0 scale : real? = 0.0 adaptive_scale : exact-integer? = 0 rho_x : real? = 0.0 max_iters : exact-integer? = 0 eps_abs : real? = 0.0 eps_rel : real? = 0.0 eps_infeas : real? = 0.0 alpha : real? = 0.0 time_limit_secs : real? = 0.0 verbose : exact-integer? = 0 warm_start : exact-integer? = 0 acceleration_lookback : exact-integer? = 0 acceleration_interval : exact-integer? = 0 write_data_filename : (or/c string? #f) = #f log_csv_filename : (or/c string? #f) = #f
procedure
(scs-settings? v) → boolean?
v : any/c
procedure
procedure
v : any/c
3.2.2 C entry points
procedure
d : scs-data? k : scs-cone? stgs : scs-settings?
procedure
(scs-solve work sol info warm) → exact-integer?
work : cpointer? sol : scs-solution? info : scs-info? warm : exact-integer?
procedure
(scs-update work b c) → exact-integer?
work : cpointer? b : cpointer? c : cpointer?
procedure
(scs-init/indirect d k stgs) → cpointer?
d : scs-data? k : scs-cone? stgs : scs-settings?
procedure
(scs-solve/indirect work sol info warm) → exact-integer?
work : cpointer? sol : scs-solution? info : scs-info? warm : exact-integer?
procedure
(scs-update/indirect work b c) → exact-integer?
work : cpointer? b : cpointer? c : cpointer?
procedure
(scs-set-default-settings stgs) → void?
stgs : scs-settings?
3.2.3 Deterministic release
| (require (submod scs/foreign unsafe)) |
(require (submod scs/foreign unsafe)) additionally provides scs-finish and scs-finish/indirect for callers that need to release a workspace eagerly rather than waiting for the collector.
procedure
(scs-finish work) → void?
work : cpointer?
procedure
(scs-finish/indirect work) → void?
work : cpointer?
3.3 Raw FFI layer
| (require scs/foreign/raw) | package: scs |
scs/foreign/raw is the direct, uncontracted binding to the SCS C API. It provides the define-scs / define-scs-indirect FFI definers, the _scs-int and _scs-float C type aliases, the cstructs, retain!, and the solver functions without contracts. Prefer scs or scs/foreign unless you are extending the bindings.
syntax
(define-scs id type-expr option ...)
syntax
(define-scs-indirect id type-expr option ...)
value
value