On this page:
<require>
<provide>
<problem>
3.7.1 Choosing the indirect solver
<solve>
<run-example>
<*>

3.7 Indirect solver🔗ℹ

SCS can solve the linear system at the heart of each iteration two ways: a direct method that factorizes once and back-solves (the default), and an indirect method that uses conjugate gradients and never forms a factorization. The indirect solver scales better to very large, sparse problems where a factorization would be expensive or memory-hungry.

Switching is a one-keyword change: pass #:indirect? #t to solve. Here we re-solve the quadratic program of Quadratic program with the indirect solver; the answer is identical, x = (0.3, −0.7).

(require scs)

(provide run-example)

(define A
  (scs:matrix 3 2
              -1   1
               1   0
               0   1))
(define P
  (scs:sparse-matrix 2 2
                     '(0 0 3)
                     '(0 1 -1)
                     '(1 1 2)))

3.7.1 Choosing the indirect solver🔗ℹ

(solve #:A A
       #:b #(-1.0 0.3 -0.5)
       #:c #(-1.0 -1.0)
       #:P P
       #:cone (make-cone #:zero 1 #:positive 2)
       #:settings (make-settings #:eps-abs 1e-9 #:eps-rel 1e-9)
       #:indirect? #t)

(define (run-example)
  <problem>
  <solve>)

Running it.

(scs-result-x (run-example))   ; #(0.3 -0.7), same as the direct solver

<*> ::=