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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/LICENSE.txt +1 -1
  4. data/lib/scs/ffi.rb +18 -0
  5. data/lib/scs/solver.rb +11 -7
  6. data/lib/scs/version.rb +1 -1
  7. data/vendor/scs/CITATION.cff +2 -3
  8. data/vendor/scs/CLAUDE.md +115 -0
  9. data/vendor/scs/CMakeLists.txt +330 -201
  10. data/vendor/scs/CONTRIBUTING.md +49 -0
  11. data/vendor/scs/Makefile +90 -43
  12. data/vendor/scs/README.md +96 -2
  13. data/vendor/scs/include/aa.h +59 -11
  14. data/vendor/scs/include/aa_stats.h +47 -0
  15. data/vendor/scs/include/cones.h +16 -7
  16. data/vendor/scs/include/glbopts.h +113 -26
  17. data/vendor/scs/include/linalg.h +5 -1
  18. data/vendor/scs/include/linsys.h +1 -2
  19. data/vendor/scs/include/normalize.h +6 -2
  20. data/vendor/scs/include/rw.h +9 -3
  21. data/vendor/scs/include/scs.h +17 -1
  22. data/vendor/scs/include/scs_blas.h +8 -0
  23. data/vendor/scs/include/scs_types.h +2 -2
  24. data/vendor/scs/include/scs_work.h +22 -1
  25. data/vendor/scs/include/util.h +3 -6
  26. data/vendor/scs/include/util_spectral_cones.h +3 -3
  27. data/vendor/scs/linsys/accelerate/direct/private.c +126 -0
  28. data/vendor/scs/linsys/accelerate/direct/private.h +34 -0
  29. data/vendor/scs/linsys/cpu/dense/private.c +250 -0
  30. data/vendor/scs/linsys/cpu/dense/private.h +31 -0
  31. data/vendor/scs/linsys/cpu/direct/private.c +86 -44
  32. data/vendor/scs/linsys/cpu/indirect/private.c +647 -113
  33. data/vendor/scs/linsys/cpu/indirect/private.h +28 -0
  34. data/vendor/scs/linsys/csparse.c +9 -3
  35. data/vendor/scs/linsys/csparse.h +4 -2
  36. data/vendor/scs/linsys/cudss/direct/private.c +77 -43
  37. data/vendor/scs/linsys/cudss/direct/private.h +33 -7
  38. data/vendor/scs/linsys/gpu/indirect/private.c +6 -2
  39. data/vendor/scs/linsys/mkl/direct/private.c +63 -31
  40. data/vendor/scs/linsys/mkl/direct/private.h +0 -1
  41. data/vendor/scs/linsys/scs_matrix.c +291 -165
  42. data/vendor/scs/linsys/scs_matrix.h +7 -9
  43. data/vendor/scs/scs.mk +35 -13
  44. data/vendor/scs/src/aa.c +673 -166
  45. data/vendor/scs/src/cones.c +545 -223
  46. data/vendor/scs/src/ctrlc.c +59 -16
  47. data/vendor/scs/src/exp_cone.c +70 -50
  48. data/vendor/scs/src/linalg.c +21 -2
  49. data/vendor/scs/src/normalize.c +24 -26
  50. data/vendor/scs/src/rw.c +596 -124
  51. data/vendor/scs/src/scs.c +990 -513
  52. data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_IPM.c +240 -187
  53. data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_Newton.c +108 -85
  54. data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_wrapper.c +62 -63
  55. data/vendor/scs/src/spectral_cones/logdeterminant/logdet_cone.c +85 -78
  56. data/vendor/scs/src/spectral_cones/nuclear/ell1_cone.c +92 -97
  57. data/vendor/scs/src/spectral_cones/nuclear/nuclear_cone.c +39 -28
  58. data/vendor/scs/src/spectral_cones/sum-largest/sum_largest_cone.c +59 -40
  59. data/vendor/scs/src/spectral_cones/sum-largest/sum_largest_eval_cone.c +37 -29
  60. data/vendor/scs/src/spectral_cones/util_spectral_cones.c +12 -6
  61. data/vendor/scs/src/util.c +37 -7
  62. data/vendor/scs/test/mkl_interface_mismatch.c +97 -0
  63. data/vendor/scs/test/packaging/CMakeLists.txt +21 -0
  64. data/vendor/scs/test/packaging/consume.c +50 -0
  65. data/vendor/scs/test/problem_utils.h +9 -2
  66. data/vendor/scs/test/problems/dense_qp.h +64 -0
  67. data/vendor/scs/test/problems/hs21_tiny_qp.h +6 -2
  68. data/vendor/scs/test/problems/hs21_tiny_qp_rw.h +10 -2
  69. data/vendor/scs/test/problems/infeasible_lp.h +66 -0
  70. data/vendor/scs/test/problems/infeasible_socp.h +75 -0
  71. data/vendor/scs/test/problems/lp_update.h +110 -0
  72. data/vendor/scs/test/problems/qafiro_tiny_qp.h +3 -1
  73. data/vendor/scs/test/problems/rob_gauss_cov_est.h +6 -3
  74. data/vendor/scs/test/problems/small_qp.h +5 -0
  75. data/vendor/scs/test/problems/test_box_cone.h +92 -0
  76. data/vendor/scs/test/problems/test_dual_exp_cone.h +96 -0
  77. data/vendor/scs/test/problems/test_inaccurate.h +212 -0
  78. data/vendor/scs/test/problems/test_mixed_cones.h +113 -0
  79. data/vendor/scs/test/problems/test_normalize_roundtrip.h +279 -0
  80. data/vendor/scs/test/problems/test_power_cone.h +414 -0
  81. data/vendor/scs/test/problems/test_psd_metric.h +109 -0
  82. data/vendor/scs/test/problems/test_psd_n1.h +84 -0
  83. data/vendor/scs/test/problems/test_root_plus.h +191 -0
  84. data/vendor/scs/test/problems/test_rw_settings.h +112 -0
  85. data/vendor/scs/test/problems/test_soc_sizes.h +393 -0
  86. data/vendor/scs/test/problems/test_solver_options.h +558 -0
  87. data/vendor/scs/test/problems/test_validation.h +263 -24
  88. data/vendor/scs/test/problems/test_zero_cone.h +81 -0
  89. data/vendor/scs/test/problems/unbounded_lp.h +66 -0
  90. data/vendor/scs/test/problems/unbounded_socp.h +71 -0
  91. data/vendor/scs/test/run_from_file.c +6 -0
  92. data/vendor/scs/test/run_tests.c +71 -0
  93. data/vendor/scs/test/rw_settings.c +7 -0
  94. data/vendor/scs/test/spectral_cones_problems/test_ell1_and_nuc.h +128 -0
  95. data/vendor/scs/test/spectral_cones_problems/test_ell1_cone.h +115 -0
  96. metadata +35 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ff5e9f042f1fd5244d1b1bc59c6308c8f70586b473d38272157fcbe05463aeb
4
- data.tar.gz: 0ebb6044270c3eaa020c9965d08f51b35591f74e83594c756e901274eb001bf8
3
+ metadata.gz: ec3e1c1e0a72a5f66811dee0e533de60349c2f2c7fdda5a97041e729a3a50e6c
4
+ data.tar.gz: a71c167273d92064b8b24828bc78c6f62fda6a3b3b5c8b04fd5beeba0262a2d9
5
5
  SHA512:
6
- metadata.gz: 4794fed3a60f87162b82a45d1acf90ca5008b29e87325bf3de074dc99b1100c130e03516d83b13655caa1cc43dd00cb91d19fc454ed463a1f29ce06e3d195038
7
- data.tar.gz: 0e501a4181f3263fae54d4d98ab8b94284978cd94ccbf2c23b8d02699f35e63855011098fe2d580d5c1492cd61605a5914ef53b4c59456283f726cd28df13e3d
6
+ metadata.gz: 77fdb9295bf706e2730ac438d4ed570a012430878e26c72e0832da0453734ed1bf5aba09f9c1238094f914bc6dcc6551c5ef73197371b92d0dd4d2cf37e9f204
7
+ data.tar.gz: 76b6070b6898235cf070ab65598eb619e9a323f037df4dba4f4504232fd03c86d44a7783de1e0c5d760f69ae38093b1a1ce31212194c60b5d60f33d29b6afab9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.6.0 (2026-09-05)
2
+
3
+ - Updated SCS to 3.3.1
4
+ - Dropped support for Ruby < 3.3
5
+
6
+ ## 0.5.6 (2026-02-27)
7
+
8
+ - Fixed memory leak in `solve` method
9
+
1
10
  ## 0.5.5 (2026-01-11)
2
11
 
3
12
  - Updated SCS to 3.2.11
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-2025 Andrew Kane
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
- solution = calloc(ffi::Solution.size) # alloc clear memory
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
@@ -1,3 +1,3 @@
1
1
  module SCS
2
- VERSION = "0.5.5"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -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.2.11
14
- date-released: 2023
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`.