scs 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/lib/scs/ffi.rb +18 -0
- data/lib/scs/solver.rb +11 -7
- data/lib/scs/version.rb +1 -1
- data/vendor/scs/CITATION.cff +2 -3
- data/vendor/scs/CLAUDE.md +115 -0
- data/vendor/scs/CMakeLists.txt +330 -201
- data/vendor/scs/CONTRIBUTING.md +49 -0
- data/vendor/scs/Makefile +90 -43
- data/vendor/scs/README.md +96 -2
- data/vendor/scs/include/aa.h +59 -11
- data/vendor/scs/include/aa_stats.h +47 -0
- data/vendor/scs/include/cones.h +16 -7
- data/vendor/scs/include/glbopts.h +113 -26
- data/vendor/scs/include/linalg.h +5 -1
- data/vendor/scs/include/linsys.h +1 -2
- data/vendor/scs/include/normalize.h +6 -2
- data/vendor/scs/include/rw.h +9 -3
- data/vendor/scs/include/scs.h +17 -1
- data/vendor/scs/include/scs_blas.h +8 -0
- data/vendor/scs/include/scs_types.h +2 -2
- data/vendor/scs/include/scs_work.h +22 -1
- data/vendor/scs/include/util.h +3 -6
- data/vendor/scs/include/util_spectral_cones.h +3 -3
- data/vendor/scs/linsys/accelerate/direct/private.c +126 -0
- data/vendor/scs/linsys/accelerate/direct/private.h +34 -0
- data/vendor/scs/linsys/cpu/dense/private.c +250 -0
- data/vendor/scs/linsys/cpu/dense/private.h +31 -0
- data/vendor/scs/linsys/cpu/direct/private.c +86 -44
- data/vendor/scs/linsys/cpu/indirect/private.c +647 -113
- data/vendor/scs/linsys/cpu/indirect/private.h +28 -0
- data/vendor/scs/linsys/csparse.c +9 -3
- data/vendor/scs/linsys/csparse.h +4 -2
- data/vendor/scs/linsys/cudss/direct/private.c +77 -43
- data/vendor/scs/linsys/cudss/direct/private.h +33 -7
- data/vendor/scs/linsys/gpu/indirect/private.c +6 -2
- data/vendor/scs/linsys/mkl/direct/private.c +63 -31
- data/vendor/scs/linsys/mkl/direct/private.h +0 -1
- data/vendor/scs/linsys/scs_matrix.c +291 -165
- data/vendor/scs/linsys/scs_matrix.h +7 -9
- data/vendor/scs/scs.mk +35 -13
- data/vendor/scs/src/aa.c +673 -166
- data/vendor/scs/src/cones.c +545 -223
- data/vendor/scs/src/ctrlc.c +59 -16
- data/vendor/scs/src/exp_cone.c +70 -50
- data/vendor/scs/src/linalg.c +21 -2
- data/vendor/scs/src/normalize.c +24 -26
- data/vendor/scs/src/rw.c +596 -124
- data/vendor/scs/src/scs.c +990 -513
- data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_IPM.c +240 -187
- data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_Newton.c +108 -85
- data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_wrapper.c +62 -63
- data/vendor/scs/src/spectral_cones/logdeterminant/logdet_cone.c +85 -78
- data/vendor/scs/src/spectral_cones/nuclear/ell1_cone.c +92 -97
- data/vendor/scs/src/spectral_cones/nuclear/nuclear_cone.c +39 -28
- data/vendor/scs/src/spectral_cones/sum-largest/sum_largest_cone.c +59 -40
- data/vendor/scs/src/spectral_cones/sum-largest/sum_largest_eval_cone.c +37 -29
- data/vendor/scs/src/spectral_cones/util_spectral_cones.c +12 -6
- data/vendor/scs/src/util.c +37 -7
- data/vendor/scs/test/mkl_interface_mismatch.c +97 -0
- data/vendor/scs/test/packaging/CMakeLists.txt +21 -0
- data/vendor/scs/test/packaging/consume.c +50 -0
- data/vendor/scs/test/problem_utils.h +9 -2
- data/vendor/scs/test/problems/dense_qp.h +64 -0
- data/vendor/scs/test/problems/hs21_tiny_qp.h +6 -2
- data/vendor/scs/test/problems/hs21_tiny_qp_rw.h +10 -2
- data/vendor/scs/test/problems/infeasible_lp.h +66 -0
- data/vendor/scs/test/problems/infeasible_socp.h +75 -0
- data/vendor/scs/test/problems/lp_update.h +110 -0
- data/vendor/scs/test/problems/qafiro_tiny_qp.h +3 -1
- data/vendor/scs/test/problems/rob_gauss_cov_est.h +6 -3
- data/vendor/scs/test/problems/small_qp.h +5 -0
- data/vendor/scs/test/problems/test_box_cone.h +92 -0
- data/vendor/scs/test/problems/test_dual_exp_cone.h +96 -0
- data/vendor/scs/test/problems/test_inaccurate.h +212 -0
- data/vendor/scs/test/problems/test_mixed_cones.h +113 -0
- data/vendor/scs/test/problems/test_normalize_roundtrip.h +279 -0
- data/vendor/scs/test/problems/test_power_cone.h +414 -0
- data/vendor/scs/test/problems/test_psd_metric.h +109 -0
- data/vendor/scs/test/problems/test_psd_n1.h +84 -0
- data/vendor/scs/test/problems/test_root_plus.h +191 -0
- data/vendor/scs/test/problems/test_rw_settings.h +112 -0
- data/vendor/scs/test/problems/test_soc_sizes.h +393 -0
- data/vendor/scs/test/problems/test_solver_options.h +558 -0
- data/vendor/scs/test/problems/test_validation.h +263 -24
- data/vendor/scs/test/problems/test_zero_cone.h +81 -0
- data/vendor/scs/test/problems/unbounded_lp.h +66 -0
- data/vendor/scs/test/problems/unbounded_socp.h +71 -0
- data/vendor/scs/test/run_from_file.c +6 -0
- data/vendor/scs/test/run_tests.c +71 -0
- data/vendor/scs/test/rw_settings.c +7 -0
- data/vendor/scs/test/spectral_cones_problems/test_ell1_and_nuc.h +128 -0
- data/vendor/scs/test/spectral_cones_problems/test_ell1_cone.h +115 -0
- metadata +35 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec3e1c1e0a72a5f66811dee0e533de60349c2f2c7fdda5a97041e729a3a50e6c
|
|
4
|
+
data.tar.gz: a71c167273d92064b8b24828bc78c6f62fda6a3b3b5c8b04fd5beeba0262a2d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 77fdb9295bf706e2730ac438d4ed570a012430878e26c72e0832da0453734ed1bf5aba09f9c1238094f914bc6dcc6551c5ef73197371b92d0dd4d2cf37e9f204
|
|
7
|
+
data.tar.gz: 76b6070b6898235cf070ab65598eb619e9a323f037df4dba4f4504232fd03c86d44a7783de1e0c5d760f69ae38093b1a1ce31212194c60b5d60f33d29b6afab9
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2012 Brendan O'Donoghue (bodonoghue85@gmail.com)
|
|
4
|
-
Copyright (c) 2019-
|
|
4
|
+
Copyright (c) 2019-2026 Andrew Kane
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
data/lib/scs/ffi.rb
CHANGED
|
@@ -63,6 +63,19 @@ module SCS
|
|
|
63
63
|
"scs_float *s"
|
|
64
64
|
]
|
|
65
65
|
|
|
66
|
+
m::AaStats = struct [
|
|
67
|
+
"scs_int iter",
|
|
68
|
+
"scs_int n_accept",
|
|
69
|
+
"scs_int n_reject_lapack",
|
|
70
|
+
"scs_int n_reject_rank0",
|
|
71
|
+
"scs_int n_reject_nonfinite",
|
|
72
|
+
"scs_int n_reject_weight_cap",
|
|
73
|
+
"scs_int n_safeguard_reject",
|
|
74
|
+
"scs_int last_rank",
|
|
75
|
+
"scs_float last_aa_norm",
|
|
76
|
+
"scs_float last_regularization"
|
|
77
|
+
]
|
|
78
|
+
|
|
66
79
|
m::Info = struct [
|
|
67
80
|
"scs_int iter",
|
|
68
81
|
"char status[128]",
|
|
@@ -81,6 +94,7 @@ module SCS
|
|
|
81
94
|
"scs_float solve_time",
|
|
82
95
|
"scs_float scale",
|
|
83
96
|
"scs_float comp_slack",
|
|
97
|
+
{aa_stats: m::AaStats},
|
|
84
98
|
"scs_int rejected_accel_steps",
|
|
85
99
|
"scs_int accepted_accel_steps",
|
|
86
100
|
"scs_float lin_sys_time",
|
|
@@ -92,6 +106,7 @@ module SCS
|
|
|
92
106
|
"scs_int normalize",
|
|
93
107
|
"scs_float scale",
|
|
94
108
|
"scs_int adaptive_scale",
|
|
109
|
+
"scs_int adaptive_diag_scale",
|
|
95
110
|
"scs_float rho_x",
|
|
96
111
|
"scs_int max_iters",
|
|
97
112
|
"scs_float eps_abs",
|
|
@@ -103,6 +118,9 @@ module SCS
|
|
|
103
118
|
"scs_int warm_start",
|
|
104
119
|
"scs_int acceleration_lookback",
|
|
105
120
|
"scs_int acceleration_interval",
|
|
121
|
+
"scs_int acceleration_type_1",
|
|
122
|
+
"scs_float acceleration_regularization",
|
|
123
|
+
"scs_float acceleration_relaxation",
|
|
106
124
|
"const char* write_data_filename",
|
|
107
125
|
"const char *log_csv_filename"
|
|
108
126
|
]
|
data/lib/scs/solver.rb
CHANGED
|
@@ -10,12 +10,21 @@ module SCS
|
|
|
10
10
|
settings = create_settings(settings)
|
|
11
11
|
ccone = create_cone(cone)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
# alloc pointers and hold refs
|
|
14
|
+
solution_ptr = Fiddle::Pointer["\x00" * ffi::Solution.size] # alloc clear memory
|
|
15
|
+
x_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE * cdata.n, Fiddle::RUBY_FREE)
|
|
16
|
+
y_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE * cdata.m, Fiddle::RUBY_FREE)
|
|
17
|
+
s_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE * cdata.m, Fiddle::RUBY_FREE)
|
|
18
|
+
|
|
19
|
+
solution = ffi::Solution.new(solution_ptr)
|
|
20
|
+
solution.x = x_ptr
|
|
21
|
+
solution.y = y_ptr
|
|
22
|
+
solution.s = s_ptr
|
|
23
|
+
|
|
14
24
|
info = ffi::Info.malloc(Fiddle::RUBY_FREE)
|
|
15
25
|
|
|
16
26
|
ffi.scs(cdata, ccone, settings, solution, info)
|
|
17
27
|
|
|
18
|
-
solution = ffi::Solution.new(solution)
|
|
19
28
|
x = read_float_array(solution.x, cdata.n)
|
|
20
29
|
y = read_float_array(solution.y, cdata.m)
|
|
21
30
|
s = read_float_array(solution.s, cdata.m)
|
|
@@ -185,11 +194,6 @@ module SCS
|
|
|
185
194
|
end
|
|
186
195
|
end
|
|
187
196
|
|
|
188
|
-
# alloc clear memory
|
|
189
|
-
def calloc(size)
|
|
190
|
-
Fiddle::Pointer["\x00" * size]
|
|
191
|
-
end
|
|
192
|
-
|
|
193
197
|
def ffi
|
|
194
198
|
@ffi
|
|
195
199
|
end
|
data/lib/scs/version.rb
CHANGED
data/vendor/scs/CITATION.cff
CHANGED
|
@@ -10,8 +10,8 @@ authors:
|
|
|
10
10
|
- family-names: "Boyd"
|
|
11
11
|
given-names: "Stephen"
|
|
12
12
|
title: "SCS: Splitting Conic Solver"
|
|
13
|
-
version: 3.
|
|
14
|
-
date-released:
|
|
13
|
+
version: 3.3.1
|
|
14
|
+
date-released: '2026-09-05'
|
|
15
15
|
url: "https://github.com/cvxgrp/scs"
|
|
16
16
|
|
|
17
17
|
# Original SCS paper:
|
|
@@ -36,4 +36,3 @@ preferred-citation:
|
|
|
36
36
|
year: 2016
|
|
37
37
|
doi: 10.1007/s10957-016-0892-3
|
|
38
38
|
url: https://dx.doi.org/10.1007/s10957-016-0892-3
|
|
39
|
-
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What This Is
|
|
6
|
+
|
|
7
|
+
SCS (Splitting Conic Solver) is a C library for solving large-scale convex cone optimization problems (LP, SOCP, SDP, ECP, PCP, complex SDP, spectral cones) using the ADMM splitting algorithm with optional Anderson acceleration.
|
|
8
|
+
|
|
9
|
+
## Build Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
make # Build with BLAS/LAPACK (default)
|
|
13
|
+
make USE_LAPACK=0 # Build without LAPACK (no SDP support)
|
|
14
|
+
make DLONG=1 # Build with 64-bit integer indexing
|
|
15
|
+
make USE_SPECTRAL_CONES=1 # Build with spectral cone support (requires LAPACK)
|
|
16
|
+
make USE_OPENMP=1 # Build with OpenMP parallelization
|
|
17
|
+
make purge # Clean all build artifacts
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
CMake alternative:
|
|
21
|
+
```bash
|
|
22
|
+
mkdir build && cd build
|
|
23
|
+
cmake -DBUILD_TESTING=ON -DUSE_LAPACK=ON ..
|
|
24
|
+
cmake --build .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Outputs go to `out/`: static libs (`libscsdir.a`, `libscsindir.a`), shared libs, and demo/test binaries.
|
|
28
|
+
|
|
29
|
+
## Testing
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
make test # Build test binaries
|
|
33
|
+
./out/run_tests_direct # Run direct solver tests
|
|
34
|
+
./out/run_tests_indirect # Run indirect solver tests
|
|
35
|
+
|
|
36
|
+
# With options:
|
|
37
|
+
make test DLONG=1 USE_LAPACK=1
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Tests use the `minunit.h` framework in `test/`. Individual test problems are in `test/problems/` and `test/spectral_cones_problems/`.
|
|
41
|
+
|
|
42
|
+
## Architecture
|
|
43
|
+
|
|
44
|
+
### Algorithm
|
|
45
|
+
SCS uses ADMM to split convex cone problems into two alternating steps:
|
|
46
|
+
1. **Linear system solve** — factorizes/solves a KKT-like system
|
|
47
|
+
2. **Cone projection** — projects onto the constraint cone
|
|
48
|
+
|
|
49
|
+
Anderson acceleration (`src/aa.c`) speeds convergence. Problem normalization/equilibration (`src/normalize.c`) improves conditioning before solving.
|
|
50
|
+
|
|
51
|
+
### Key Interfaces
|
|
52
|
+
- **`include/linsys.h`** — abstract interface that all linear system solvers must implement; `ScsLinSysWork` is the opaque solver-specific workspace
|
|
53
|
+
- **`include/cones.h`** — cone projection interface; `ScsConeWork` holds precomputed cone data
|
|
54
|
+
- **`include/scs.h`** — public API: `ScsMatrix`, `ScsData`, `ScsCone`, `ScsSettings`, `ScsSolution`
|
|
55
|
+
|
|
56
|
+
### Linear Solver Backends (in `linsys/`)
|
|
57
|
+
- `cpu/direct/` — QDLDL sparse Cholesky (default, bundled in `linsys/external/qdldl/`)
|
|
58
|
+
- `cpu/indirect/` — iterative (conjugate gradient / LSQR)
|
|
59
|
+
- `mkl/direct/` — Intel MKL Pardiso (enabled via `MKLROOT`)
|
|
60
|
+
- `accelerate/direct/` — Apple Accelerate sparse LDLt (macOS only, `make accelerate`)
|
|
61
|
+
- `cudss/direct/` — NVIDIA cuDSS GPU solver
|
|
62
|
+
- `gpu/indirect/` — GPU iterative solver
|
|
63
|
+
|
|
64
|
+
The Makefile selects which backend to compile based on flags. Only one direct or indirect backend is linked per build.
|
|
65
|
+
|
|
66
|
+
### Cone Types
|
|
67
|
+
Supported cones are registered in `src/cones.c`. The `ScsCone` struct fields map to: `z` (zero), `l` (non-negative), `q` (second-order), `s` (PSD), `cs` (complex PSD), `p` (power), `ep`/`ed` (exponential primal/dual). Spectral cones (`USE_SPECTRAL_CONES=1`) add log-determinant, nuclear norm, and sum-of-largest-eigenvalues support via `src/spectral_cones/`.
|
|
68
|
+
|
|
69
|
+
### Compiler Flags
|
|
70
|
+
Defined in `scs.mk`: `-Wall -Wwrite-strings -pedantic -funroll-loops -Werror=incompatible-pointer-types`. Type aliases `scs_float` and `scs_int` in `include/scs_types.h` change with `SFLOAT` and `DLONG` flags.
|
|
71
|
+
|
|
72
|
+
## Key Data Flow
|
|
73
|
+
|
|
74
|
+
The main solve lifecycle is:
|
|
75
|
+
1. **`scs_init`** — validates data, deep-copies and normalizes `A`/`P`/`b`/`c`, sets up linear system solver (factorization for direct), sets up cone workspace
|
|
76
|
+
2. **`scs_solve`** — ADMM loop:
|
|
77
|
+
- Solve linear system (KKT) to get search direction (`project_lin_sys`)
|
|
78
|
+
- Project onto dual cone via Moreau decomposition (`project_cones`)
|
|
79
|
+
- Apply Anderson acceleration every `acceleration_interval` iterations
|
|
80
|
+
- Check convergence / infeasibility / time limit
|
|
81
|
+
- Optionally update scale parameter (adaptive scaling)
|
|
82
|
+
3. **`scs_finish`** — frees all workspace memory
|
|
83
|
+
|
|
84
|
+
`scs_update` allows changing `b`/`c` between solves without re-factorizing.
|
|
85
|
+
|
|
86
|
+
## Adding a New Linear Solver Backend
|
|
87
|
+
|
|
88
|
+
1. Create a new directory under `linsys/`, e.g. `linsys/mybackend/direct/`
|
|
89
|
+
2. Implement the 5 functions declared in `include/linsys.h`:
|
|
90
|
+
- `scs_init_lin_sys_work()` — allocate workspace, factorize if direct
|
|
91
|
+
- `scs_solve_lin_sys()` — solve the KKT system
|
|
92
|
+
- `scs_update_lin_sys_diag_r()` — handle R diagonal updates
|
|
93
|
+
- `scs_free_lin_sys_work()` — deallocate workspace
|
|
94
|
+
- `scs_get_lin_sys_method()` — return a descriptive string
|
|
95
|
+
3. Create `private.h` defining `struct SCS_LIN_SYS_WORK` with your backend's fields
|
|
96
|
+
4. Add Makefile rules following the pattern of the existing backends (see `mkl`, `cudss`)
|
|
97
|
+
5. Add CMake rules following the same pattern in `CMakeLists.txt`
|
|
98
|
+
6. Add a CI workflow in `.github/workflows/`
|
|
99
|
+
|
|
100
|
+
See `linsys/cpu/direct/` for the reference implementation.
|
|
101
|
+
|
|
102
|
+
## Adding a New Cone Type
|
|
103
|
+
|
|
104
|
+
1. Add the new field(s) to `ScsCone` in `include/scs.h`
|
|
105
|
+
2. In `src/cones.c`:
|
|
106
|
+
- Update `SCS(validate_cones)` to validate the new cone's parameters
|
|
107
|
+
- Update `SCS(init_cone)` to compute cone boundaries and allocate workspace
|
|
108
|
+
- Update `SCS(proj_dual_cone)` to project onto the new cone
|
|
109
|
+
- Update `SCS(get_cone_header)` for printing
|
|
110
|
+
- Update `SCS(set_r_y)` for the R diagonal entries
|
|
111
|
+
3. If the projection is complex, put it in a separate source file (like `src/exp_cone.c`)
|
|
112
|
+
4. Update the Makefile object lists and CMakeLists.txt source lists
|
|
113
|
+
5. Add a test in `test/problems/`
|
|
114
|
+
|
|
115
|
+
Cone ordering in the rows of `A` must match the order in `proj_dual_cone`.
|