scs 0.5.6 → 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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE.txt +1 -1
  4. data/lib/scs/ffi.rb +18 -0
  5. data/lib/scs/version.rb +1 -1
  6. data/vendor/scs/CITATION.cff +2 -3
  7. data/vendor/scs/CLAUDE.md +115 -0
  8. data/vendor/scs/CMakeLists.txt +330 -201
  9. data/vendor/scs/CONTRIBUTING.md +49 -0
  10. data/vendor/scs/Makefile +90 -43
  11. data/vendor/scs/README.md +96 -2
  12. data/vendor/scs/include/aa.h +59 -11
  13. data/vendor/scs/include/aa_stats.h +47 -0
  14. data/vendor/scs/include/cones.h +16 -7
  15. data/vendor/scs/include/glbopts.h +113 -26
  16. data/vendor/scs/include/linalg.h +5 -1
  17. data/vendor/scs/include/linsys.h +1 -2
  18. data/vendor/scs/include/normalize.h +6 -2
  19. data/vendor/scs/include/rw.h +9 -3
  20. data/vendor/scs/include/scs.h +17 -1
  21. data/vendor/scs/include/scs_blas.h +8 -0
  22. data/vendor/scs/include/scs_types.h +2 -2
  23. data/vendor/scs/include/scs_work.h +22 -1
  24. data/vendor/scs/include/util.h +3 -6
  25. data/vendor/scs/include/util_spectral_cones.h +3 -3
  26. data/vendor/scs/linsys/accelerate/direct/private.c +126 -0
  27. data/vendor/scs/linsys/accelerate/direct/private.h +34 -0
  28. data/vendor/scs/linsys/cpu/dense/private.c +250 -0
  29. data/vendor/scs/linsys/cpu/dense/private.h +31 -0
  30. data/vendor/scs/linsys/cpu/direct/private.c +86 -44
  31. data/vendor/scs/linsys/cpu/indirect/private.c +647 -113
  32. data/vendor/scs/linsys/cpu/indirect/private.h +28 -0
  33. data/vendor/scs/linsys/csparse.c +9 -3
  34. data/vendor/scs/linsys/csparse.h +4 -2
  35. data/vendor/scs/linsys/cudss/direct/private.c +77 -43
  36. data/vendor/scs/linsys/cudss/direct/private.h +33 -7
  37. data/vendor/scs/linsys/gpu/indirect/private.c +6 -2
  38. data/vendor/scs/linsys/mkl/direct/private.c +63 -31
  39. data/vendor/scs/linsys/mkl/direct/private.h +0 -1
  40. data/vendor/scs/linsys/scs_matrix.c +291 -165
  41. data/vendor/scs/linsys/scs_matrix.h +7 -9
  42. data/vendor/scs/scs.mk +35 -13
  43. data/vendor/scs/src/aa.c +673 -166
  44. data/vendor/scs/src/cones.c +545 -223
  45. data/vendor/scs/src/ctrlc.c +59 -16
  46. data/vendor/scs/src/exp_cone.c +70 -50
  47. data/vendor/scs/src/linalg.c +21 -2
  48. data/vendor/scs/src/normalize.c +24 -26
  49. data/vendor/scs/src/rw.c +596 -124
  50. data/vendor/scs/src/scs.c +990 -513
  51. data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_IPM.c +240 -187
  52. data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_Newton.c +108 -85
  53. data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_wrapper.c +62 -63
  54. data/vendor/scs/src/spectral_cones/logdeterminant/logdet_cone.c +85 -78
  55. data/vendor/scs/src/spectral_cones/nuclear/ell1_cone.c +92 -97
  56. data/vendor/scs/src/spectral_cones/nuclear/nuclear_cone.c +39 -28
  57. data/vendor/scs/src/spectral_cones/sum-largest/sum_largest_cone.c +59 -40
  58. data/vendor/scs/src/spectral_cones/sum-largest/sum_largest_eval_cone.c +37 -29
  59. data/vendor/scs/src/spectral_cones/util_spectral_cones.c +12 -6
  60. data/vendor/scs/src/util.c +37 -7
  61. data/vendor/scs/test/mkl_interface_mismatch.c +97 -0
  62. data/vendor/scs/test/packaging/CMakeLists.txt +21 -0
  63. data/vendor/scs/test/packaging/consume.c +50 -0
  64. data/vendor/scs/test/problem_utils.h +9 -2
  65. data/vendor/scs/test/problems/dense_qp.h +64 -0
  66. data/vendor/scs/test/problems/hs21_tiny_qp.h +6 -2
  67. data/vendor/scs/test/problems/hs21_tiny_qp_rw.h +10 -2
  68. data/vendor/scs/test/problems/infeasible_lp.h +66 -0
  69. data/vendor/scs/test/problems/infeasible_socp.h +75 -0
  70. data/vendor/scs/test/problems/lp_update.h +110 -0
  71. data/vendor/scs/test/problems/qafiro_tiny_qp.h +3 -1
  72. data/vendor/scs/test/problems/rob_gauss_cov_est.h +6 -3
  73. data/vendor/scs/test/problems/small_qp.h +5 -0
  74. data/vendor/scs/test/problems/test_box_cone.h +92 -0
  75. data/vendor/scs/test/problems/test_dual_exp_cone.h +96 -0
  76. data/vendor/scs/test/problems/test_inaccurate.h +212 -0
  77. data/vendor/scs/test/problems/test_mixed_cones.h +113 -0
  78. data/vendor/scs/test/problems/test_normalize_roundtrip.h +279 -0
  79. data/vendor/scs/test/problems/test_power_cone.h +414 -0
  80. data/vendor/scs/test/problems/test_psd_metric.h +109 -0
  81. data/vendor/scs/test/problems/test_psd_n1.h +84 -0
  82. data/vendor/scs/test/problems/test_root_plus.h +191 -0
  83. data/vendor/scs/test/problems/test_rw_settings.h +112 -0
  84. data/vendor/scs/test/problems/test_soc_sizes.h +393 -0
  85. data/vendor/scs/test/problems/test_solver_options.h +558 -0
  86. data/vendor/scs/test/problems/test_validation.h +263 -24
  87. data/vendor/scs/test/problems/test_zero_cone.h +81 -0
  88. data/vendor/scs/test/problems/unbounded_lp.h +66 -0
  89. data/vendor/scs/test/problems/unbounded_socp.h +71 -0
  90. data/vendor/scs/test/run_from_file.c +6 -0
  91. data/vendor/scs/test/run_tests.c +71 -0
  92. data/vendor/scs/test/rw_settings.c +7 -0
  93. data/vendor/scs/test/spectral_cones_problems/test_ell1_and_nuc.h +128 -0
  94. data/vendor/scs/test/spectral_cones_problems/test_ell1_cone.h +115 -0
  95. metadata +35 -3
@@ -1,46 +1,285 @@
1
1
  #include "glbopts.h"
2
+ #include "cones.h"
2
3
  #include "minunit.h"
3
4
  #include "problem_utils.h"
4
5
  #include "scs.h"
5
6
  #include "util.h"
6
7
 
8
+ /* Shared minimal problem setup for validation tests. */
9
+ static void _setup_validation_prob(ScsData *d, ScsCone *k, ScsSolution *opt,
10
+ int seed) {
11
+ scs_float p_f = 0.1;
12
+ scs_int n = 1, m = 3;
13
+ scs_int col_nnz = 1, nnz = 1;
14
+ k->z = (scs_int)(m * p_f);
15
+ k->l = m - k->z;
16
+ d->m = m;
17
+ d->n = n;
18
+ gen_random_prob_data(nnz, col_nnz, d, k, opt, seed);
19
+ }
20
+
7
21
  static const char *test_validation(void) {
8
22
  scs_printf("Testing that SCS handles bad inputs correctly:\n");
9
23
 
10
- ScsCone *k = (ScsCone *)scs_calloc(1, sizeof(ScsCone));
11
- ScsData *d = (ScsData *)scs_calloc(1, sizeof(ScsData));
12
- ScsSettings *stgs = (ScsSettings *)scs_calloc(1, sizeof(ScsSettings));
13
- ScsSolution *sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution));
14
- ScsSolution *opt_sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution));
24
+ ScsCone *k;
25
+ ScsData *d;
26
+ ScsSettings *stgs;
27
+ ScsSolution *sol, *opt_sol;
15
28
  ScsInfo info = {0};
16
- scs_float p_f = 0.1;
17
- int seed = 1234;
18
- scs_int n = 1;
19
- scs_int m = 3;
20
- scs_int col_nnz = (scs_int)ceil(sqrt(n));
21
- scs_int nnz = n * col_nnz;
22
29
  scs_int exitflag;
23
30
 
24
- k->z = (scs_int)floor(m * p_f);
25
- k->l = m - k->z;
31
+ #define VALIDATION_SETUP() \
32
+ do { \
33
+ k = (ScsCone *)scs_calloc(1, sizeof(ScsCone)); \
34
+ d = (ScsData *)scs_calloc(1, sizeof(ScsData)); \
35
+ stgs = (ScsSettings *)scs_calloc(1, sizeof(ScsSettings)); \
36
+ sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution)); \
37
+ opt_sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution)); \
38
+ _setup_validation_prob(d, k, opt_sol, 1234); \
39
+ scs_set_default_settings(stgs); \
40
+ } while (0)
26
41
 
27
- d->m = m;
28
- d->n = n;
29
- gen_random_prob_data(nnz, col_nnz, d, k, opt_sol, seed);
30
- scs_set_default_settings(stgs);
42
+ #define VALIDATION_CLEANUP() \
43
+ do { \
44
+ SCS(free_data)(d); \
45
+ SCS(free_cone)(k); \
46
+ SCS(free_sol)(sol); \
47
+ SCS(free_sol)(opt_sol); \
48
+ scs_free(stgs); \
49
+ } while (0)
31
50
 
32
- /* TODO test more failure modes */
51
+ /* eps_abs < 0 */
52
+ VALIDATION_SETUP();
33
53
  stgs->eps_abs = -1;
54
+ exitflag = scs(d, k, stgs, sol, &info);
55
+ mu_assert("validation: eps_abs < 0 should fail", exitflag == SCS_FAILED);
56
+ VALIDATION_CLEANUP();
57
+
58
+ /* eps_abs NaN */
59
+ VALIDATION_SETUP();
60
+ stgs->eps_abs = NAN;
61
+ exitflag = scs(d, k, stgs, sol, &info);
62
+ mu_assert("validation: eps_abs NaN should fail", exitflag == SCS_FAILED);
63
+ VALIDATION_CLEANUP();
64
+
65
+ /* eps_rel < 0 */
66
+ VALIDATION_SETUP();
67
+ stgs->eps_rel = -1;
68
+ exitflag = scs(d, k, stgs, sol, &info);
69
+ mu_assert("validation: eps_rel < 0 should fail", exitflag == SCS_FAILED);
70
+ VALIDATION_CLEANUP();
71
+
72
+ /* eps_infeas < 0 */
73
+ VALIDATION_SETUP();
74
+ stgs->eps_infeas = -1;
75
+ exitflag = scs(d, k, stgs, sol, &info);
76
+ mu_assert("validation: eps_infeas < 0 should fail", exitflag == SCS_FAILED);
77
+ VALIDATION_CLEANUP();
78
+
79
+ /* max_iters <= 0 */
80
+ VALIDATION_SETUP();
81
+ stgs->max_iters = 0;
82
+ exitflag = scs(d, k, stgs, sol, &info);
83
+ mu_assert("validation: max_iters <= 0 should fail", exitflag == SCS_FAILED);
84
+ VALIDATION_CLEANUP();
85
+
86
+ /* alpha <= 0 */
87
+ VALIDATION_SETUP();
88
+ stgs->alpha = 0.0;
89
+ exitflag = scs(d, k, stgs, sol, &info);
90
+ mu_assert("validation: alpha <= 0 should fail", exitflag == SCS_FAILED);
91
+ VALIDATION_CLEANUP();
92
+
93
+ /* alpha >= 2 */
94
+ VALIDATION_SETUP();
95
+ stgs->alpha = 2.0;
96
+ exitflag = scs(d, k, stgs, sol, &info);
97
+ mu_assert("validation: alpha >= 2 should fail", exitflag == SCS_FAILED);
98
+ VALIDATION_CLEANUP();
99
+
100
+ /* rho_x <= 0 */
101
+ VALIDATION_SETUP();
102
+ stgs->rho_x = 0.0;
103
+ exitflag = scs(d, k, stgs, sol, &info);
104
+ mu_assert("validation: rho_x <= 0 should fail", exitflag == SCS_FAILED);
105
+ VALIDATION_CLEANUP();
106
+
107
+ /* scale <= 0 */
108
+ VALIDATION_SETUP();
109
+ stgs->scale = 0.0;
110
+ exitflag = scs(d, k, stgs, sol, &info);
111
+ mu_assert("validation: scale <= 0 should fail", exitflag == SCS_FAILED);
112
+ VALIDATION_CLEANUP();
113
+
114
+ /* time_limit_secs NaN */
115
+ VALIDATION_SETUP();
116
+ stgs->time_limit_secs = NAN;
117
+ exitflag = scs(d, k, stgs, sol, &info);
118
+ mu_assert("validation: time_limit_secs NaN should fail",
119
+ exitflag == SCS_FAILED);
120
+ VALIDATION_CLEANUP();
121
+
122
+ /* acceleration_interval <= 0 */
123
+ VALIDATION_SETUP();
124
+ stgs->acceleration_interval = 0;
125
+ exitflag = scs(d, k, stgs, sol, &info);
126
+ mu_assert("validation: acceleration_interval <= 0 should fail",
127
+ exitflag == SCS_FAILED);
128
+ VALIDATION_CLEANUP();
34
129
 
130
+ /* --- Cone validation tests --- */
131
+
132
+ /* cone dimension mismatch: total cone dims != m */
133
+ VALIDATION_SETUP();
134
+ k->l += 99; /* inflate l so total dims > m */
135
+ exitflag = scs(d, k, stgs, sol, &info);
136
+ mu_assert("validation: cone dims != m should fail", exitflag == SCS_FAILED);
137
+ VALIDATION_CLEANUP();
138
+
139
+ /* negative zero-cone dimension */
140
+ VALIDATION_SETUP();
141
+ k->l = 0;
142
+ k->z = -1;
143
+ d->m = -1; /* match total so cone-dims == m check passes */
35
144
  exitflag = scs(d, k, stgs, sol, &info);
145
+ mu_assert("validation: z < 0 should fail", exitflag == SCS_FAILED);
146
+ VALIDATION_CLEANUP();
147
+
148
+ /* box cone bl > bu */
149
+ {
150
+ scs_float bl_bad[] = {5.0};
151
+ scs_float bu_bad[] = {1.0};
152
+ VALIDATION_SETUP();
153
+ k->l = 0;
154
+ k->z = 0;
155
+ k->bsize = 2; /* 1 t-var + 1 bounded var */
156
+ k->bl = bl_bad;
157
+ k->bu = bu_bad;
158
+ d->m = 2;
159
+ exitflag = scs(d, k, stgs, sol, &info);
160
+ mu_assert("validation: bl > bu should fail", exitflag == SCS_FAILED);
161
+ k->bl = SCS_NULL; /* prevent double-free */
162
+ k->bu = SCS_NULL;
163
+ VALIDATION_CLEANUP();
164
+ }
165
+
166
+ /* box cone one-sided infinite bounds are valid */
167
+ {
168
+ ScsData d_box = {0};
169
+ ScsCone k_box = {0};
170
+ scs_float bl_inf[] = {-INFINITY, -1.0};
171
+ scs_float bu_inf[] = {1.0, INFINITY};
172
+ d_box.m = 3;
173
+ k_box.bsize = 3; /* 1 t-var + 2 bounded vars */
174
+ k_box.bl = bl_inf;
175
+ k_box.bu = bu_inf;
176
+ mu_assert("validation: box infinite bounds should pass",
177
+ SCS(validate_cones)(&d_box, &k_box) == 0);
178
+ }
179
+
180
+ /* box cone NaN bound */
181
+ {
182
+ ScsData d_box = {0};
183
+ ScsCone k_box = {0};
184
+ scs_float bl_nan[] = {NAN};
185
+ scs_float bu_nan[] = {1.0};
186
+ d_box.m = 2;
187
+ k_box.bsize = 2; /* 1 t-var + 1 bounded var */
188
+ k_box.bl = bl_nan;
189
+ k_box.bu = bu_nan;
190
+ mu_assert("validation: box NaN bound should fail",
191
+ SCS(validate_cones)(&d_box, &k_box) < 0);
192
+ }
193
+
194
+ /* box cone infinities must point in the valid bound direction */
195
+ {
196
+ ScsData d_box = {0};
197
+ ScsCone k_box = {0};
198
+ scs_float bl_bad_inf[] = {INFINITY};
199
+ scs_float bu_bad_inf[] = {INFINITY};
200
+ d_box.m = 2;
201
+ k_box.bsize = 2; /* 1 t-var + 1 bounded var */
202
+ k_box.bl = bl_bad_inf;
203
+ k_box.bu = bu_bad_inf;
204
+ mu_assert("validation: box +inf lower bound should fail",
205
+ SCS(validate_cones)(&d_box, &k_box) < 0);
206
+ }
207
+
208
+ /* power cone p out of range */
209
+ {
210
+ scs_float p_bad[] = {2.0}; /* must be in [-1, 1] */
211
+ VALIDATION_SETUP();
212
+ k->l = 0;
213
+ k->z = 0;
214
+ k->psize = 1;
215
+ k->p = p_bad;
216
+ d->m = 3;
217
+ exitflag = scs(d, k, stgs, sol, &info);
218
+ mu_assert("validation: p > 1 should fail", exitflag == SCS_FAILED);
219
+ k->p = SCS_NULL; /* prevent double-free */
220
+ VALIDATION_CLEANUP();
221
+ }
222
+
223
+ /* soc cone array missing */
224
+ VALIDATION_SETUP();
225
+ k->l = 0;
226
+ k->z = 0;
227
+ k->qsize = 1;
228
+ k->q = SCS_NULL;
229
+ d->m = 1;
230
+ exitflag = scs(d, k, stgs, sol, &info);
231
+ mu_assert("validation: missing soc cone array should fail",
232
+ exitflag == SCS_FAILED);
233
+ VALIDATION_CLEANUP();
36
234
 
37
- mu_assert("test_fails: SCS failed to produce outputflag SCS_FAILED",
235
+ /* missing settings */
236
+ VALIDATION_SETUP();
237
+ exitflag = scs(d, k, SCS_NULL, sol, &info);
238
+ mu_assert("validation: missing settings should fail",
38
239
  exitflag == SCS_FAILED);
39
- SCS(free_data)(d);
40
- SCS(free_cone)(k);
41
- SCS(free_sol)(sol);
42
- SCS(free_sol)(opt_sol);
43
- scs_free(stgs);
240
+ VALIDATION_CLEANUP();
241
+
242
+ /* missing A */
243
+ VALIDATION_SETUP();
244
+ SCS(free_scs_matrix)(d->A);
245
+ d->A = SCS_NULL;
246
+ exitflag = scs(d, k, stgs, sol, &info);
247
+ mu_assert("validation: missing A should fail", exitflag == SCS_FAILED);
248
+ VALIDATION_CLEANUP();
249
+
250
+ /* A dimensions inconsistent with ScsData */
251
+ VALIDATION_SETUP();
252
+ d->A->m = d->m + 1;
253
+ exitflag = scs(d, k, stgs, sol, &info);
254
+ mu_assert("validation: A dims inconsistent with data should fail",
255
+ exitflag == SCS_FAILED);
256
+ VALIDATION_CLEANUP();
257
+
258
+ /* A has negative row index */
259
+ VALIDATION_SETUP();
260
+ d->A->i[0] = -1;
261
+ exitflag = scs(d, k, stgs, sol, &info);
262
+ mu_assert("validation: A negative row index should fail",
263
+ exitflag == SCS_FAILED);
264
+ VALIDATION_CLEANUP();
265
+
266
+ /* A column pointers must be nondecreasing */
267
+ VALIDATION_SETUP();
268
+ d->A->p[0] = 1;
269
+ exitflag = scs(d, k, stgs, sol, &info);
270
+ mu_assert("validation: A invalid column pointer should fail",
271
+ exitflag == SCS_FAILED);
272
+ VALIDATION_CLEANUP();
273
+
274
+ /* A has non-finite data */
275
+ VALIDATION_SETUP();
276
+ d->A->x[0] = NAN;
277
+ exitflag = scs(d, k, stgs, sol, &info);
278
+ mu_assert("validation: A NaN entry should fail", exitflag == SCS_FAILED);
279
+ VALIDATION_CLEANUP();
280
+
281
+ #undef VALIDATION_SETUP
282
+ #undef VALIDATION_CLEANUP
44
283
 
45
284
  return 0;
46
285
  }
@@ -0,0 +1,81 @@
1
+ #include "glbopts.h"
2
+ #include "linalg.h"
3
+ #include "minunit.h"
4
+ #include "problem_utils.h"
5
+ #include "scs.h"
6
+ #include "util.h"
7
+
8
+ /*
9
+ * Pure zero-cone problem: only equality constraints, no inequality cones.
10
+ * The zero-cone projection (src/cones.c) simply memsets the slice to 0.
11
+ *
12
+ * Problem: minimize x1 + x2
13
+ * subject to x1 + x2 = 3
14
+ * x1 - x2 = 1
15
+ * Solution: x1 = 2, x2 = 1, obj = 3.
16
+ *
17
+ * Variables [x1, x2] (n=2), m=2, k->z=2 (only zero cone).
18
+ *
19
+ * A cols (CSC):
20
+ * col 0 (x1): row 0 -> +1, row 1 -> +1
21
+ * col 1 (x2): row 0 -> +1, row 1 -> -1
22
+ */
23
+ static const char *test_zero_cone(void) {
24
+ ScsCone *k = (ScsCone *)scs_calloc(1, sizeof(ScsCone));
25
+ ScsData *d = (ScsData *)scs_calloc(1, sizeof(ScsData));
26
+ ScsSettings *stgs = (ScsSettings *)scs_calloc(1, sizeof(ScsSettings));
27
+ ScsSolution *sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution));
28
+ ScsInfo info = {0};
29
+ scs_int exitflag;
30
+ scs_float perr, derr;
31
+ scs_int success;
32
+ const char *fail;
33
+
34
+ scs_float opt = 3.0;
35
+
36
+ scs_float Ax[] = {1.0, 1.0, 1.0, -1.0};
37
+ scs_int Ai[] = {0, 1, 0, 1};
38
+ scs_int Ap[] = {0, 2, 4};
39
+
40
+ scs_float b[] = {3.0, 1.0};
41
+ scs_float c[] = {1.0, 1.0};
42
+
43
+ scs_int m = 2, n = 2;
44
+
45
+ d->m = m;
46
+ d->n = n;
47
+ d->b = b;
48
+ d->c = c;
49
+
50
+ d->A = (ScsMatrix *)scs_calloc(1, sizeof(ScsMatrix));
51
+ d->A->m = m;
52
+ d->A->n = n;
53
+ d->A->x = Ax;
54
+ d->A->i = Ai;
55
+ d->A->p = Ap;
56
+
57
+ k->z = 2; /* only zero cone — no l, q, s, ep, ed, p */
58
+
59
+ scs_set_default_settings(stgs);
60
+ stgs->eps_abs = 1e-6;
61
+ stgs->eps_rel = 1e-6;
62
+
63
+ exitflag = scs(d, k, stgs, sol, &info);
64
+
65
+ perr = info.pobj - opt;
66
+ derr = info.dobj - opt;
67
+
68
+ scs_printf("primal obj error %4e\n", perr);
69
+ scs_printf("dual obj error %4e\n", derr);
70
+
71
+ success = ABS(perr) < 1e-4 && ABS(derr) < 1e-4 && exitflag == SCS_SOLVED;
72
+ mu_assert("test_zero_cone: SCS failed to produce SCS_SOLVED", success);
73
+ fail = verify_solution_correct(d, k, stgs, &info, sol, exitflag);
74
+
75
+ SCS(free_sol)(sol);
76
+ scs_free(d->A);
77
+ scs_free(k);
78
+ scs_free(stgs);
79
+ scs_free(d);
80
+ return fail;
81
+ }
@@ -0,0 +1,66 @@
1
+ #include "glbopts.h"
2
+ #include "linalg.h"
3
+ #include "minunit.h"
4
+ #include "problem_utils.h"
5
+ #include "scs.h"
6
+ #include "util.h"
7
+
8
+ /*
9
+ * Unbounded LP: min -x s.t. x >= 0.
10
+ * x is unbounded above, so the objective -> -inf.
11
+ *
12
+ * SCS form: Ax + s = b, s in K_nn (l=1)
13
+ * row 0: -x + s = 0, s >= 0 => s = x >= 0
14
+ *
15
+ * A = [[-1]], b = [0], c = [-1], k->l = 1.
16
+ */
17
+ static const char *unbounded_lp(void) {
18
+ ScsCone *k = (ScsCone *)scs_calloc(1, sizeof(ScsCone));
19
+ ScsData *d = (ScsData *)scs_calloc(1, sizeof(ScsData));
20
+ ScsSettings *stgs = (ScsSettings *)scs_calloc(1, sizeof(ScsSettings));
21
+ ScsSolution *sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution));
22
+ ScsInfo info = {0};
23
+ scs_int exitflag;
24
+ const char *fail;
25
+
26
+ scs_float Ax[] = {-1.0};
27
+ scs_int Ai[] = {0};
28
+ scs_int Ap[] = {0, 1};
29
+
30
+ scs_float b[] = {0.0};
31
+ scs_float c[] = {-1.0};
32
+
33
+ scs_int m = 1, n = 1;
34
+
35
+ d->m = m;
36
+ d->n = n;
37
+ d->b = b;
38
+ d->c = c;
39
+
40
+ d->A = (ScsMatrix *)scs_calloc(1, sizeof(ScsMatrix));
41
+ d->A->m = m;
42
+ d->A->n = n;
43
+ d->A->x = Ax;
44
+ d->A->i = Ai;
45
+ d->A->p = Ap;
46
+
47
+ k->l = m;
48
+
49
+ scs_set_default_settings(stgs);
50
+ stgs->eps_abs = 1e-6;
51
+ stgs->eps_rel = 1e-6;
52
+ stgs->eps_infeas = 1e-9;
53
+
54
+ exitflag = scs(d, k, stgs, sol, &info);
55
+
56
+ mu_assert("unbounded_lp: expected SCS_UNBOUNDED",
57
+ exitflag == SCS_UNBOUNDED);
58
+ fail = verify_solution_correct(d, k, stgs, &info, sol, exitflag);
59
+
60
+ SCS(free_sol)(sol);
61
+ scs_free(d->A);
62
+ scs_free(k);
63
+ scs_free(stgs);
64
+ scs_free(d);
65
+ return fail;
66
+ }
@@ -0,0 +1,71 @@
1
+ #include "glbopts.h"
2
+ #include "linalg.h"
3
+ #include "minunit.h"
4
+ #include "problem_utils.h"
5
+ #include "scs.h"
6
+ #include "util.h"
7
+
8
+ /*
9
+ * Unbounded SOCP: min -(t + x) s.t. (t, x) in SOC_2.
10
+ * On the boundary t = x >= 0, objective = -2t -> -inf.
11
+ *
12
+ * Variables [t, x] (n=2), m=2 (SOC_2):
13
+ * row 0: -t + s0 = 0 => s0 = t
14
+ * row 1: -x + s1 = 0 => s1 = x
15
+ *
16
+ * A cols (CSC):
17
+ * col 0 (t): row 0 -> -1
18
+ * col 1 (x): row 1 -> -1
19
+ */
20
+ static const char *unbounded_socp(void) {
21
+ ScsCone *k = (ScsCone *)scs_calloc(1, sizeof(ScsCone));
22
+ ScsData *d = (ScsData *)scs_calloc(1, sizeof(ScsData));
23
+ ScsSettings *stgs = (ScsSettings *)scs_calloc(1, sizeof(ScsSettings));
24
+ ScsSolution *sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution));
25
+ ScsInfo info = {0};
26
+ scs_int exitflag;
27
+ const char *fail;
28
+
29
+ scs_float Ax[] = {-1.0, -1.0};
30
+ scs_int Ai[] = {0, 1};
31
+ scs_int Ap[] = {0, 1, 2};
32
+
33
+ scs_float b[] = {0.0, 0.0};
34
+ scs_float c[] = {-1.0, -1.0};
35
+
36
+ scs_int q[] = {2};
37
+ scs_int m = 2, n = 2;
38
+
39
+ d->m = m;
40
+ d->n = n;
41
+ d->b = b;
42
+ d->c = c;
43
+
44
+ d->A = (ScsMatrix *)scs_calloc(1, sizeof(ScsMatrix));
45
+ d->A->m = m;
46
+ d->A->n = n;
47
+ d->A->x = Ax;
48
+ d->A->i = Ai;
49
+ d->A->p = Ap;
50
+
51
+ k->qsize = 1;
52
+ k->q = q;
53
+
54
+ scs_set_default_settings(stgs);
55
+ stgs->eps_abs = 1e-6;
56
+ stgs->eps_rel = 1e-6;
57
+ stgs->eps_infeas = 1e-9;
58
+
59
+ exitflag = scs(d, k, stgs, sol, &info);
60
+
61
+ mu_assert("unbounded_socp: expected SCS_UNBOUNDED",
62
+ exitflag == SCS_UNBOUNDED);
63
+ fail = verify_solution_correct(d, k, stgs, &info, sol, exitflag);
64
+
65
+ SCS(free_sol)(sol);
66
+ scs_free(d->A);
67
+ scs_free(k);
68
+ scs_free(stgs);
69
+ scs_free(d);
70
+ return fail;
71
+ }
@@ -1,7 +1,11 @@
1
1
  #include "rw.h"
2
+ #include "cones.h"
2
3
  #include "scs.h"
3
4
  #include "util.h"
4
5
 
6
+ #include <stdlib.h>
7
+ #include <string.h>
8
+
5
9
  scs_int override_setting(ScsSettings *s, char *param, char *val) {
6
10
  scs_printf("Attempting to override %s with value %s.\n", param, val);
7
11
  if (strcmp(param, "normalize") == 0) {
@@ -28,6 +32,8 @@ scs_int override_setting(ScsSettings *s, char *param, char *val) {
28
32
  s->acceleration_interval = atoi(val);
29
33
  } else if (strcmp(param, "adaptive_scale") == 0) {
30
34
  s->adaptive_scale = atoi(val);
35
+ } else if (strcmp(param, "adaptive_diag_scale") == 0) {
36
+ s->adaptive_diag_scale = atoi(val);
31
37
  } else if (strcmp(param, "log_csv_filename") == 0) {
32
38
  s->log_csv_filename = val;
33
39
  } else {
@@ -7,12 +7,29 @@
7
7
 
8
8
  /* Include Tests */
9
9
  #include "problems/degenerate.h"
10
+ #include "problems/dense_qp.h"
10
11
  #include "problems/hs21_tiny_qp.h"
12
+ #include "problems/infeasible_lp.h"
13
+ #include "problems/infeasible_socp.h"
11
14
  #include "problems/infeasible_tiny_qp.h"
15
+ #include "problems/lp_update.h"
12
16
  #include "problems/qafiro_tiny_qp.h"
13
17
  #include "problems/small_lp.h"
14
18
  #include "problems/small_qp.h"
19
+ #include "problems/test_dual_exp_cone.h"
15
20
  #include "problems/test_exp_cone.h"
21
+ #include "problems/test_inaccurate.h"
22
+ #include "problems/test_mixed_cones.h"
23
+ #include "problems/test_normalize_roundtrip.h"
24
+ #include "problems/test_power_cone.h"
25
+ #include "problems/test_root_plus.h"
26
+ #include "problems/test_soc_sizes.h"
27
+ #include "problems/test_box_cone.h"
28
+ #include "problems/test_psd_n1.h"
29
+ #include "problems/test_solver_options.h"
30
+ #include "problems/test_zero_cone.h"
31
+ #include "problems/unbounded_lp.h"
32
+ #include "problems/unbounded_socp.h"
16
33
  #include "problems/unbounded_tiny_qp.h"
17
34
 
18
35
  int tests_run = 0;
@@ -35,9 +52,11 @@ _SKIP(test_validation)
35
52
  #if defined(USE_LAPACK)
36
53
  #include "problems/complex_PSD.h"
37
54
  #include "problems/sd_and_complex_sd.h"
55
+ #include "problems/test_psd_metric.h"
38
56
  #else
39
57
  _SKIP(complex_PSD)
40
58
  _SKIP(sd_and_complex_sd)
59
+ _SKIP(test_psd_metric)
41
60
  #endif
42
61
 
43
62
  /* solve SDPs from data files, requires blas / lapack */
@@ -57,6 +76,8 @@ _SKIP(rob_gauss_cov_est)
57
76
  #include "spectral_cones_problems/several_logdet_cones.h"
58
77
  #include "spectral_cones_problems/several_nuc_cone.h"
59
78
  #include "spectral_cones_problems/several_sum_largest.h"
79
+ #include "spectral_cones_problems/test_ell1_cone.h"
80
+ #include "spectral_cones_problems/test_ell1_and_nuc.h"
60
81
  #else
61
82
  _SKIP(exp_design)
62
83
  _SKIP(robust_pca)
@@ -64,15 +85,19 @@ _SKIP(graph_partitioning)
64
85
  _SKIP(several_sum_largest)
65
86
  _SKIP(several_nuc_cone)
66
87
  _SKIP(several_logdet_cones)
88
+ _SKIP(test_ell1_cone)
89
+ _SKIP(test_ell1_and_nuc)
67
90
  #endif
68
91
 
69
92
  /* solves problems from data files */
70
93
  #if NO_READ_WRITE == 0
71
94
  #include "problems/hs21_tiny_qp_rw.h"
95
+ #include "problems/test_rw_settings.h"
72
96
  #include "problems/max_ent.h"
73
97
  #include "problems/mpc_bug.h"
74
98
  #else
75
99
  _SKIP(hs21_tiny_qp_rw)
100
+ _SKIP(test_rw_settings)
76
101
  _SKIP(max_ent)
77
102
  _SKIP(mpc_bug)
78
103
  #endif
@@ -80,26 +105,72 @@ _SKIP(mpc_bug)
80
105
  static const char *all_tests(void) {
81
106
  mu_run_test(test_validation);
82
107
  mu_run_test(degenerate);
108
+ mu_run_test(dense_qp);
83
109
  mu_run_test(small_lp);
84
110
  mu_run_test(small_qp);
111
+ mu_run_test(lp_update);
85
112
  mu_run_test(rob_gauss_cov_est);
86
113
  mu_run_test(complex_PSD);
87
114
  mu_run_test(sd_and_complex_sd);
115
+ mu_run_test(test_psd_metric);
88
116
  mu_run_test(hs21_tiny_qp);
89
117
  mu_run_test(hs21_tiny_qp_rw);
118
+ mu_run_test(test_rw_settings);
90
119
  mu_run_test(qafiro_tiny_qp);
91
120
  mu_run_test(infeasible_tiny_qp);
121
+ mu_run_test(infeasible_lp);
122
+ mu_run_test(infeasible_socp);
92
123
  mu_run_test(unbounded_tiny_qp);
124
+ mu_run_test(unbounded_lp);
125
+ mu_run_test(unbounded_socp);
93
126
  mu_run_test(random_prob);
94
127
  mu_run_test(max_ent);
95
128
  mu_run_test(mpc_bug);
96
129
  mu_run_test(test_exp_cone);
130
+ mu_run_test(test_dual_exp_cone);
131
+ mu_run_test(test_power_cone);
132
+ mu_run_test(test_power_cone_p09);
133
+ mu_run_test(test_dual_power_cone);
134
+ mu_run_test(test_multi_power);
135
+ mu_run_test(test_power_cone_infeasible);
136
+ mu_run_test(test_soc_size1);
137
+ mu_run_test(test_soc_size2);
138
+ mu_run_test(test_soc_size3);
139
+ mu_run_test(test_soc_size5);
140
+ mu_run_test(test_multi_soc);
141
+ mu_run_test(test_zero_cone);
142
+ mu_run_test(test_box_cone_lp);
143
+ mu_run_test(test_psd_n1);
144
+ mu_run_test(test_solved_inaccurate);
145
+ mu_run_test(test_infeasible_inaccurate);
146
+ mu_run_test(test_unbounded_inaccurate);
147
+ mu_run_test(test_max_iters_1);
148
+ mu_run_test(test_adaptive_scale);
149
+ mu_run_test(test_no_acceleration);
150
+ mu_run_test(test_type2_acceleration);
151
+ mu_run_test(test_aa_relaxation_sweep);
152
+ mu_run_test(test_aa_regularization_sweep);
153
+ mu_run_test(test_negative_lookback_rejected);
154
+ mu_run_test(test_invalid_aa_relaxation_rejected);
155
+ mu_run_test(test_pinned_negative_regularization_solves);
156
+ mu_run_test(test_invalid_aa_regularization_rejected);
157
+ mu_run_test(test_normalize_off);
158
+ mu_run_test(test_normalize_roundtrip);
159
+ mu_run_test(test_scs_version);
160
+ mu_run_test(test_time_limit_secs);
161
+ mu_run_test(test_warm_start);
162
+ mu_run_test(test_mixed_cones);
163
+ mu_run_test(test_root_plus_equivalence);
164
+ mu_run_test(test_normalize_roundtrip_lp);
165
+ mu_run_test(test_normalize_roundtrip_qp);
97
166
  mu_run_test(exp_design);
98
167
  mu_run_test(robust_pca);
99
168
  mu_run_test(graph_partitioning);
100
169
  mu_run_test(several_sum_largest);
101
170
  mu_run_test(several_nuc_cone);
102
171
  mu_run_test(several_logdet_cones);
172
+ mu_run_test(test_ell1_cone);
173
+ mu_run_test(test_ell1_and_nuc);
103
174
  return 0;
104
175
  }
105
176
  int main(void) {
@@ -0,0 +1,7 @@
1
+ #include "problems/test_rw_settings.h"
2
+
3
+ int main(void) {
4
+ const char *result = test_rw_settings();
5
+ puts(result ? result : "rw_settings passed");
6
+ return result != SCS_NULL;
7
+ }