On this page:
<require>
<provide>
3.3.1 Encoding cone membership
<matrix>
<solve>
<run-example>
<*>

3.3 Second-order cone🔗ℹ

The second-order (Lorentz) cone {(t, u) : ‖u‖₂ ≤ t} lets us minimize a Euclidean norm. We solve

minimize t
subject to ‖(u, v)‖₂ ≤ t, u = 3, v = 4

over x = (t, u, v). With u and v pinned, the cone forces t ≥ √(3² + 4²) = 5, so the optimum is (t, u, v) = (5, 3, 4).

(require scs)

(provide run-example)

3.3.1 Encoding cone membership🔗ℹ

A slack lands in a cone when s = b − Ax. To put (t, u, v) itself into the SOC block we use A = −I with b = 0 on those rows, so s = (t, u, v). The two equality rows (u = 3, v = 4) come first, as the zero cone; then the three-row SOC block:

(define A
  (scs:matrix 5 3
 
               0   1   0    ; u = 3 (zero cone)
               0   0   1    ; v = 4
              -1   0   0    ; SOC block: s = (t, u, v)
               0  -1   0
               0   0  -1))

#:soc takes a list of block sizes; here a single block of size 3. The first entry of each block is the cone’s scale t, the rest are u.

(solve #:A A
       #:b #(3.0 4.0 0.0 0.0 0.0)
       #:c #(1.0 0.0 0.0)
       #:cone (make-cone #:zero 2 #:soc '(3))
       #:settings (make-settings #:eps-abs 1e-9 #:eps-rel 1e-9))

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

Running it.

(scs-result-x (run-example))   ; #(5.0 3.0 4.0)

<*> ::=