scs 0.6.0 → 0.6.1
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 +4 -0
- data/ext/scs/extconf.rb +3 -9
- data/lib/scs/version.rb +1 -1
- data/vendor/scs/CITATION.cff +2 -2
- data/vendor/scs/CMakeLists.txt +138 -10
- data/vendor/scs/CONTRIBUTING.md +21 -2
- data/vendor/scs/Makefile +4 -3
- data/vendor/scs/README.md +25 -14
- data/vendor/scs/include/cones.h +27 -9
- data/vendor/scs/include/glbopts.h +25 -5
- data/vendor/scs/include/scs.h +10 -8
- data/vendor/scs/include/scs_work.h +2 -1
- data/vendor/scs/linsys/cudss/direct/private.c +50 -2
- data/vendor/scs/linsys/gpu/indirect/private.c +17 -4
- data/vendor/scs/linsys/mkl/direct/private.c +1 -1
- data/vendor/scs/scs.mk +43 -2
- data/vendor/scs/src/aa.c +27 -7
- data/vendor/scs/src/cones.c +851 -163
- data/vendor/scs/src/linalg.c +16 -3
- data/vendor/scs/src/scs.c +91 -46
- data/vendor/scs/src/spectral_cones/logdeterminant/logdet_cone.c +15 -14
- data/vendor/scs/src/spectral_cones/nuclear/ell1_cone.c +1 -4
- data/vendor/scs/src/spectral_cones/sum-largest/sum_largest_eval_cone.c +11 -9
- data/vendor/scs/test/minunit.h +27 -3
- data/vendor/scs/test/mkl_psd_guard.c +282 -0
- data/vendor/scs/test/problem_utils.h +123 -22
- data/vendor/scs/test/problems/complex_PSD.h +2 -1
- data/vendor/scs/test/problems/degenerate.h +10 -3
- data/vendor/scs/test/problems/dense_qp.h +2 -1
- data/vendor/scs/test/problems/hs21_tiny_qp.h +7 -3
- data/vendor/scs/test/problems/hs21_tiny_qp_rw.h +5 -2
- data/vendor/scs/test/problems/issue_140 +0 -0
- data/vendor/scs/test/problems/issue_140.h +19 -0
- data/vendor/scs/test/problems/issue_220 +0 -0
- data/vendor/scs/test/problems/issue_220.h +37 -0
- data/vendor/scs/test/problems/issue_499.h +79 -0
- data/vendor/scs/test/problems/lp_update.h +5 -5
- data/vendor/scs/test/problems/qafiro_tiny_qp.h +25 -5
- data/vendor/scs/test/problems/rob_gauss_cov_est.h +24 -4
- data/vendor/scs/test/problems/sd_and_complex_sd.h +2 -1
- data/vendor/scs/test/problems/small_lp.h +2 -1
- data/vendor/scs/test/problems/small_qp.h +7 -0
- data/vendor/scs/test/problems/test_box_cone.h +2 -1
- data/vendor/scs/test/problems/test_dual_exp_cone.h +2 -1
- data/vendor/scs/test/problems/test_mixed_cones.h +2 -1
- data/vendor/scs/test/problems/test_non_psd_p.h +76 -0
- data/vendor/scs/test/problems/test_normalize_roundtrip.h +14 -12
- data/vendor/scs/test/problems/test_power_cone.h +139 -5
- data/vendor/scs/test/problems/test_prob_from_data_file.h +14 -4
- data/vendor/scs/test/problems/test_psd_metric.h +11 -7
- data/vendor/scs/test/problems/test_psd_n1.h +2 -1
- data/vendor/scs/test/problems/test_psd_parallel.h +383 -0
- data/vendor/scs/test/problems/test_psd_scale_updates.h +186 -0
- data/vendor/scs/test/problems/test_soc_sizes.h +10 -5
- data/vendor/scs/test/problems/test_solver_options.h +10 -3
- data/vendor/scs/test/problems/test_zero_cone.h +2 -1
- data/vendor/scs/test/run_from_file.c +8 -0
- data/vendor/scs/test/run_tests.c +84 -19
- data/vendor/scs/test/spectral_cones_problems/exp_design.h +1 -0
- data/vendor/scs/test/spectral_cones_problems/several_logdet_cones.h +1 -0
- data/vendor/scs/test/spectral_cones_problems/test_spectral_metric_updates.h +163 -0
- metadata +12 -3
- data/vendor/scs/CLAUDE.md +0 -115
data/vendor/scs/src/linalg.c
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Dense linear algebra operations: norms, dot products, scaling, axpy.
|
|
3
3
|
* Has two implementations: a plain C fallback and an optimized BLAS version
|
|
4
|
-
* (selected at compile time via USE_LAPACK).
|
|
4
|
+
* (selected at compile time via USE_LAPACK, double precision only).
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
#include "linalg.h"
|
|
@@ -33,7 +33,13 @@ scs_float SCS(norm_inf_diff)(const scs_float *a, const scs_float *b,
|
|
|
33
33
|
return max;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
/* Single precision uses these loops for every routine, BLAS or not. The ones
|
|
37
|
+
* that matter are dot and nrm2, which return a REAL: the legacy Accelerate
|
|
38
|
+
* interface macOS links for -lblas returns a REAL as a C double (the f2c
|
|
39
|
+
* convention), while OpenBLAS, MKL, etc. return a float, so no prototype is
|
|
40
|
+
* right for both and a wrong one silently reads garbage. The rest follow so
|
|
41
|
+
* that one switch covers the file. */
|
|
42
|
+
#if !defined(USE_LAPACK) || defined(SFLOAT)
|
|
37
43
|
/* Self-rolled basic linear algebra routines */
|
|
38
44
|
|
|
39
45
|
/* a *= b */
|
|
@@ -65,7 +71,14 @@ scs_float SCS(norm_sq)(const scs_float *v, scs_int len) {
|
|
|
65
71
|
|
|
66
72
|
/* ||v||_2 */
|
|
67
73
|
scs_float SCS(norm_2)(const scs_float *v, scs_int len) {
|
|
68
|
-
|
|
74
|
+
/* accumulate in double so that single-precision builds keep nrm2's
|
|
75
|
+
* protection against overflow and underflow in the squares */
|
|
76
|
+
double nmsq = 0.;
|
|
77
|
+
scs_int i;
|
|
78
|
+
for (i = 0; i < len; ++i) {
|
|
79
|
+
nmsq += (double)v[i] * (double)v[i];
|
|
80
|
+
}
|
|
81
|
+
return (scs_float)sqrt(nmsq);
|
|
69
82
|
}
|
|
70
83
|
|
|
71
84
|
scs_float SCS(norm_inf)(const scs_float *a, scs_int len) {
|
data/vendor/scs/src/scs.c
CHANGED
|
@@ -1040,8 +1040,8 @@ static void set_diag_r(ScsWork *w) {
|
|
|
1040
1040
|
SCS(set_r_y)(w->cone_work, w->stgs->scale, &(w->diag_r[w->d->n]));
|
|
1041
1041
|
if (w->scale_mults) {
|
|
1042
1042
|
/* per-row multipliers act like a per-row scale: R_y_i = base_i / f_i.
|
|
1043
|
-
* Multipliers are kept
|
|
1044
|
-
* time) so no SCS(enforce_cone_boundaries) needed here. */
|
|
1043
|
+
* Multipliers are kept in the form their cone block needs (enforced
|
|
1044
|
+
* at update time) so no SCS(enforce_cone_boundaries) needed here. */
|
|
1045
1045
|
for (i = 0; i < w->d->m; ++i) {
|
|
1046
1046
|
w->diag_r[w->d->n + i] /= w->scale_mults[i];
|
|
1047
1047
|
}
|
|
@@ -1114,17 +1114,6 @@ static ScsWork *init_work(const ScsData *d, const ScsCone *k,
|
|
|
1114
1114
|
w->r_orig = init_residuals(w->d);
|
|
1115
1115
|
w->b_orig = (scs_float *)scs_calloc(w->d->m, sizeof(scs_float));
|
|
1116
1116
|
w->c_orig = (scs_float *)scs_calloc(w->d->n, sizeof(scs_float));
|
|
1117
|
-
#ifdef USE_SPECTRAL_CONES
|
|
1118
|
-
if (w->stgs->adaptive_diag_scale &&
|
|
1119
|
-
(w->k->dsize || w->k->nucsize || w->k->ell1_size || w->k->sl_size)) {
|
|
1120
|
-
/* The spectral-cone projections are iterative inner solvers with
|
|
1121
|
-
* warm-start state that does not currently tolerate mid-solve metric
|
|
1122
|
-
* changes (observed as dual iterates leaving the cone). Disable
|
|
1123
|
-
* dynamic diagonal rescaling on such problems until the inner
|
|
1124
|
-
* solvers are made metric-change aware. */
|
|
1125
|
-
w->stgs->adaptive_diag_scale = 0;
|
|
1126
|
-
}
|
|
1127
|
-
#endif
|
|
1128
1117
|
if (w->stgs->adaptive_diag_scale) {
|
|
1129
1118
|
if (!w->stgs->adaptive_scale) {
|
|
1130
1119
|
/* silently disable: diag scaling rides the adaptive-scale update
|
|
@@ -1134,7 +1123,9 @@ static ScsWork *init_work(const ScsData *d, const ScsCone *k,
|
|
|
1134
1123
|
} else {
|
|
1135
1124
|
scs_int j;
|
|
1136
1125
|
w->scale_mults = (scs_float *)scs_calloc(w->d->m, sizeof(scs_float));
|
|
1137
|
-
|
|
1126
|
+
w->scale_mults_next =
|
|
1127
|
+
(scs_float *)scs_calloc(w->d->m, sizeof(scs_float));
|
|
1128
|
+
if (!w->scale_mults || !w->scale_mults_next) {
|
|
1138
1129
|
scs_printf("ERROR: work memory allocation failure\n");
|
|
1139
1130
|
scs_finish(w);
|
|
1140
1131
|
return SCS_NULL;
|
|
@@ -1159,6 +1150,10 @@ static ScsWork *init_work(const ScsData *d, const ScsCone *k,
|
|
|
1159
1150
|
scs_finish(w);
|
|
1160
1151
|
return SCS_NULL;
|
|
1161
1152
|
}
|
|
1153
|
+
if (w->stgs->verbose && w->cone_work->psd_nthreads > 1) {
|
|
1154
|
+
scs_printf("\t psd cones projected in parallel by %li threads\n",
|
|
1155
|
+
(long)w->cone_work->psd_nthreads);
|
|
1156
|
+
}
|
|
1162
1157
|
set_diag_r(w);
|
|
1163
1158
|
|
|
1164
1159
|
if (w->stgs->normalize) {
|
|
@@ -1260,6 +1255,10 @@ static scs_int update_work(ScsWork *w, ScsSolution *sol) {
|
|
|
1260
1255
|
cold_start_vars(w);
|
|
1261
1256
|
}
|
|
1262
1257
|
|
|
1258
|
+
/* the cached spectral warm starts describe the iterates of the previous
|
|
1259
|
+
* solve, which the (re)start above has just discarded */
|
|
1260
|
+
SCS(reset_cone_cache)(w->cone_work);
|
|
1261
|
+
|
|
1263
1262
|
update_work_cache(w);
|
|
1264
1263
|
return 0;
|
|
1265
1264
|
}
|
|
@@ -1304,8 +1303,10 @@ static void set_den_floor(ScsWork *w) {
|
|
|
1304
1303
|
|
|
1305
1304
|
static scs_int update_scale(ScsWork *w, const ScsCone *k, scs_int iter) {
|
|
1306
1305
|
scs_int i;
|
|
1307
|
-
scs_float factor, new_scale,
|
|
1308
|
-
scs_float
|
|
1306
|
+
scs_float factor, new_scale, dist_pri, dist_dual;
|
|
1307
|
+
scs_float terms_pri, terms_dual, abs_pri, abs_dual, sat_pri, sat_dual, wt;
|
|
1308
|
+
const scs_float eps_abs = w->stgs->eps_abs;
|
|
1309
|
+
const scs_float eps_rel = w->stgs->eps_rel;
|
|
1309
1310
|
|
|
1310
1311
|
ScsResiduals *r = w->r_orig;
|
|
1311
1312
|
|
|
@@ -1320,20 +1321,44 @@ static scs_int update_scale(ScsWork *w, const ScsCone *k, scs_int iter) {
|
|
|
1320
1321
|
if (w->scale_mults) {
|
|
1321
1322
|
set_den_floor(w);
|
|
1322
1323
|
}
|
|
1324
|
+
/* The scale is moved toward whichever residual is further behind, so each
|
|
1325
|
+
* sample is the log of a primal-to-dual ratio. Two ratios are blended.
|
|
1326
|
+
*
|
|
1327
|
+
* (1) Distance to stopping: each residual over its own threshold in
|
|
1328
|
+
* has_converged, with tau multiplied through. At or below one, that side
|
|
1329
|
+
* would pass. Balancing these evens out how far each side has to go. */
|
|
1323
1330
|
/* ||Ax + s - b * tau|| */
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
relative_res_pri = SAFEDIV_POS(nm_ax_s_btau, denom_pri);
|
|
1331
|
+
terms_pri = MAX(MAX(nm_ax, nm_s), w->nm_b_orig * r->tau);
|
|
1332
|
+
dist_pri = SAFEDIV_POS(nm_ax_s_btau, eps_abs * r->tau + eps_rel * terms_pri);
|
|
1327
1333
|
/* ||Px + A'y + c * tau|| */
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1334
|
+
terms_dual = MAX(MAX(nm_px, nm_aty), w->nm_c_orig * r->tau);
|
|
1335
|
+
dist_dual =
|
|
1336
|
+
SAFEDIV_POS(nm_px_aty_ctau, eps_abs * r->tau + eps_rel * terms_dual);
|
|
1337
|
+
/* clamp to avoid log(0) which would NaN-poison sum_log_scale_factor */
|
|
1338
|
+
dist_pri = MAX(dist_pri, _DIV_EPS_TOL);
|
|
1339
|
+
dist_dual = MAX(dist_dual, _DIV_EPS_TOL);
|
|
1340
|
+
|
|
1341
|
+
/* (2) The residuals themselves, in the space the iteration runs in
|
|
1342
|
+
* (equilibrated when normalize is on), with nothing divided out. */
|
|
1343
|
+
abs_pri = MAX(SCALE_NORM(w->r_normalized->ax_s_btau, w->d->m), _DIV_EPS_TOL);
|
|
1344
|
+
abs_dual =
|
|
1345
|
+
MAX(SCALE_NORM(w->r_normalized->px_aty_ctau, w->d->n), _DIV_EPS_TOL);
|
|
1346
|
+
|
|
1347
|
+
/* A residual as large as the terms it is measured against has no correct
|
|
1348
|
+
* digits, and its distance then sits at a ceiling of about 1 / eps_rel
|
|
1349
|
+
* whatever the iterate does. With c = 0 and P = 0 the dual is there on
|
|
1350
|
+
* every iteration, because the residual A'y is the only term: (1) alone
|
|
1351
|
+
* then reads the dual as permanently behind and walks the scale to its
|
|
1352
|
+
* floor. sat is 1 at that ceiling and 0 when the residual is negligible
|
|
1353
|
+
* against its terms; (1) gets weight wt, the trust in both sides, and (2)
|
|
1354
|
+
* gets the rest. */
|
|
1355
|
+
sat_pri = MIN(1., eps_rel * dist_pri);
|
|
1356
|
+
sat_dual = MIN(1., eps_rel * dist_dual);
|
|
1357
|
+
wt = (1. - sat_pri) * (1. - sat_dual);
|
|
1331
1358
|
|
|
1332
1359
|
/* higher scale makes res_pri go down faster, so increase if res_pri larger */
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
relative_res_dual = MAX(relative_res_dual, _DIV_EPS_TOL);
|
|
1336
|
-
w->sum_log_scale_factor += log(relative_res_pri) - log(relative_res_dual);
|
|
1360
|
+
w->sum_log_scale_factor += wt * (log(dist_pri) - log(dist_dual)) +
|
|
1361
|
+
(1. - wt) * (log(abs_pri) - log(abs_dual));
|
|
1337
1362
|
w->n_log_scale_factor++;
|
|
1338
1363
|
|
|
1339
1364
|
/* geometric mean */
|
|
@@ -1349,13 +1374,28 @@ static scs_int update_scale(ScsWork *w, const ScsCone *k, scs_int iter) {
|
|
|
1349
1374
|
scs_int apply_scalar =
|
|
1350
1375
|
(new_scale != w->stgs->scale) && should_update_r(factor);
|
|
1351
1376
|
scs_int apply_diag = 0;
|
|
1352
|
-
scs_float log_g = 0., g, step,
|
|
1377
|
+
scs_float log_g = 0., g, step, change;
|
|
1353
1378
|
if (w->stgs->adaptive_diag_scale) {
|
|
1354
|
-
/*
|
|
1355
|
-
*
|
|
1356
|
-
*
|
|
1357
|
-
*
|
|
1358
|
-
|
|
1379
|
+
/* Residual profiles. The multipliers the update would install are
|
|
1380
|
+
* built in full first: a damped step along the row profile, the clamp,
|
|
1381
|
+
* and then the form each cone block must take (one value for most
|
|
1382
|
+
* non-polyhedral cones, a rank-one fit for PSD blocks). The diagonal
|
|
1383
|
+
* adapts when the scalar updates, or when some multiplier would move
|
|
1384
|
+
* by more than the update threshold, so that a railed scalar does not
|
|
1385
|
+
* freeze the diagonal and a railed multiplier does not keep asking for
|
|
1386
|
+
* an update it cannot take.
|
|
1387
|
+
*
|
|
1388
|
+
* The change is measured on what would be installed, after the cone
|
|
1389
|
+
* blocks have been given their form. Measured before that, a single
|
|
1390
|
+
* row of a block that wants a large step refactorizes the matrix even
|
|
1391
|
+
* though its block then moves by almost nothing: the factorization,
|
|
1392
|
+
* the acceleration memory and the cone cache are thrown away as often
|
|
1393
|
+
* as every RESCALING_MIN_ITERS iterations for a metric that has not
|
|
1394
|
+
* changed. (The fit of a PSD block can also move an entry further than
|
|
1395
|
+
* any one row asked for; that change is real and is counted too.)
|
|
1396
|
+
* Rows of the zero, nonnegative and box cones are not shared, so for
|
|
1397
|
+
* them the two measures are the same. */
|
|
1398
|
+
scs_float change_max = 1.0;
|
|
1359
1399
|
for (i = 0; i < w->d->m; ++i) {
|
|
1360
1400
|
log_g += log(row_rel_res(w, i));
|
|
1361
1401
|
}
|
|
@@ -1363,12 +1403,17 @@ static scs_int update_scale(ScsWork *w, const ScsCone *k, scs_int iter) {
|
|
|
1363
1403
|
g = exp(log_g);
|
|
1364
1404
|
for (i = 0; i < w->d->m; ++i) {
|
|
1365
1405
|
step = POWF(row_rel_res(w, i) / g, DIAG_SCALE_DAMP);
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
drift = MAX(drift, MAX(change, 1. / change));
|
|
1406
|
+
w->scale_mults_next[i] =
|
|
1407
|
+
MIN(MAX(w->scale_mults[i] * step, DIAG_SCALE_MULT_MIN),
|
|
1408
|
+
DIAG_SCALE_MULT_MAX);
|
|
1370
1409
|
}
|
|
1371
|
-
|
|
1410
|
+
SCS(enforce_cone_boundaries)(w->cone_work, w->scale_mults_next,
|
|
1411
|
+
&SCS(mean), 1);
|
|
1412
|
+
for (i = 0; i < w->d->m; ++i) {
|
|
1413
|
+
change = w->scale_mults_next[i] / w->scale_mults[i];
|
|
1414
|
+
change_max = MAX(change_max, MAX(change, 1. / change));
|
|
1415
|
+
}
|
|
1416
|
+
apply_diag = apply_scalar || should_update_r(change_max);
|
|
1372
1417
|
}
|
|
1373
1418
|
if (!apply_scalar && !apply_diag) {
|
|
1374
1419
|
return 0;
|
|
@@ -1383,15 +1428,9 @@ static scs_int update_scale(ScsWork *w, const ScsCone *k, scs_int iter) {
|
|
|
1383
1428
|
w->stgs->scale = new_scale;
|
|
1384
1429
|
}
|
|
1385
1430
|
if (apply_diag) {
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
w->scale_mults[i] = MIN(
|
|
1390
|
-
MAX(w->scale_mults[i] * step, DIAG_SCALE_MULT_MIN),
|
|
1391
|
-
DIAG_SCALE_MULT_MAX);
|
|
1392
|
-
}
|
|
1393
|
-
/* non-polyhedral cone blocks must share a single metric entry */
|
|
1394
|
-
SCS(enforce_cone_boundaries)(w->cone_work, w->scale_mults, &SCS(mean), 1);
|
|
1431
|
+
/* already clamped and in the form the cone blocks need */
|
|
1432
|
+
memcpy(w->scale_mults, w->scale_mults_next,
|
|
1433
|
+
w->d->m * sizeof(scs_float));
|
|
1395
1434
|
}
|
|
1396
1435
|
|
|
1397
1436
|
/* update diag r vector */
|
|
@@ -1410,6 +1449,11 @@ static scs_int update_scale(ScsWork *w, const ScsCone *k, scs_int iter) {
|
|
|
1410
1449
|
if (w->accel) {
|
|
1411
1450
|
aa_reset(w->accel);
|
|
1412
1451
|
}
|
|
1452
|
+
/* Same reasoning for the cone projections: the spectral cones' inner
|
|
1453
|
+
* solvers warm-start from state computed under the metric we just
|
|
1454
|
+
* replaced, so drop it rather than let it seed the next iteration's
|
|
1455
|
+
* projection (see SCS(reset_cone_cache)). */
|
|
1456
|
+
SCS(reset_cone_cache)(w->cone_work);
|
|
1413
1457
|
/* update v, using fact that rsk, u, u_t vectors should be the same */
|
|
1414
1458
|
/* solve: R^+ (v^+ + u - 2u_t) = rsk = R(v + u - 2u_t)
|
|
1415
1459
|
* => v^+ = R+^-1 rsk + 2u_t - u
|
|
@@ -1688,6 +1732,7 @@ void scs_finish(ScsWork *w) {
|
|
|
1688
1732
|
scs_free(w->lin_sys_warm_start);
|
|
1689
1733
|
scs_free(w->diag_r);
|
|
1690
1734
|
scs_free(w->scale_mults);
|
|
1735
|
+
scs_free(w->scale_mults_next);
|
|
1691
1736
|
SCS(free_sol)(w->xys_orig);
|
|
1692
1737
|
if (w->scal) {
|
|
1693
1738
|
scs_free(w->scal->D);
|
|
@@ -27,10 +27,10 @@ extern "C" {
|
|
|
27
27
|
void BLAS(syev)(const char *jobz, const char *uplo, blas_int *n, scs_float *a,
|
|
28
28
|
blas_int *lda, scs_float *w, scs_float *work, blas_int *lwork,
|
|
29
29
|
blas_int *info);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
void BLAS(syrk)(const char *uplo, const char *trans, const blas_int *n,
|
|
31
|
+
const blas_int *k, const scs_float *alpha, const scs_float *a,
|
|
32
|
+
const blas_int *lda, const scs_float *beta, scs_float *c,
|
|
33
|
+
const blas_int *ldc);
|
|
34
34
|
void BLAS(scal)(const blas_int *n, const scs_float *sa, scs_float *sx,
|
|
35
35
|
const blas_int *incx);
|
|
36
36
|
|
|
@@ -70,11 +70,11 @@ scs_int SCS(proj_logdet_cone)(scs_float *tvX, scs_int n, ScsConeWork *c,
|
|
|
70
70
|
scs_float zero = 0., one = 1.;
|
|
71
71
|
scs_float sqrt2 = SQRTF(2.0);
|
|
72
72
|
scs_float sqrt2_inv = 1.0 / sqrt2;
|
|
73
|
-
scs_float *Xs = c->Xs;
|
|
74
|
-
scs_float *Z = c->Z;
|
|
75
|
-
scs_float *e = c->e;
|
|
76
|
-
scs_float *work = c->work;
|
|
77
|
-
blas_int lwork = c->lwork;
|
|
73
|
+
scs_float *Xs = c->psd_tw->Xs;
|
|
74
|
+
scs_float *Z = c->psd_tw->Z;
|
|
75
|
+
scs_float *e = c->psd_tw->e;
|
|
76
|
+
scs_float *work = c->psd_tw->work;
|
|
77
|
+
blas_int lwork = c->psd_tw->lwork;
|
|
78
78
|
blas_int info = 0;
|
|
79
79
|
scs_float sq_eig_pos;
|
|
80
80
|
scs_float *current_log_proj;
|
|
@@ -96,12 +96,13 @@ scs_int SCS(proj_logdet_cone)(scs_float *tvX, scs_int n, ScsConeWork *c,
|
|
|
96
96
|
* order (smallest eigenvalue first)
|
|
97
97
|
*/
|
|
98
98
|
BLAS(syev)("Vectors", "Lower", &nb, Xs, &nb, e, work, &lwork, &info);
|
|
99
|
+
/* info < 0: bad argument. info > 0: no convergence, so 'e' and 'Xs' hold
|
|
100
|
+
* partial results. Either way the eigendecomposition below it is built on
|
|
101
|
+
* is meaningless, so fail rather than return a bogus projection. */
|
|
99
102
|
if (info != 0) {
|
|
100
|
-
scs_printf("
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return info;
|
|
104
|
-
}
|
|
103
|
+
scs_printf("FATAL: LAPACK syev error in logdet cone, info = %li\n",
|
|
104
|
+
(long)info);
|
|
105
|
+
return -1;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
/*
|
|
@@ -27,9 +27,6 @@ extern "C" {
|
|
|
27
27
|
void BLAS(axpy)(blas_int *n, const scs_float *a, const scs_float *x,
|
|
28
28
|
blas_int *incx, scs_float *y, blas_int *incy);
|
|
29
29
|
|
|
30
|
-
scs_float BLAS(dot)(const blas_int *n, const scs_float *x, const blas_int *incx,
|
|
31
|
-
const scs_float *y, const blas_int *incy);
|
|
32
|
-
|
|
33
30
|
#ifdef __cplusplus
|
|
34
31
|
}
|
|
35
32
|
#endif
|
|
@@ -62,7 +59,7 @@ static void compute_cone_residuals_ell1(const scs_float *tx, scs_float t0,
|
|
|
62
59
|
* Compute complementarity measure
|
|
63
60
|
* --------------------------------------- */
|
|
64
61
|
complementarity =
|
|
65
|
-
tx[0] * dualt +
|
|
62
|
+
tx[0] * dualt + SCS(dot)(dualx, tx + 1, n);
|
|
66
63
|
|
|
67
64
|
/* -----------------------------------------------
|
|
68
65
|
* Compute primal feasibility measure
|
|
@@ -69,11 +69,11 @@ scs_int SCS(proj_sum_largest_evals)(scs_float *tX, scs_int n, scs_int k,
|
|
|
69
69
|
blas_int one_int = 1;
|
|
70
70
|
scs_float sqrt2 = SQRTF(2.0);
|
|
71
71
|
scs_float sqrt2_inv = 1.0 / sqrt2;
|
|
72
|
-
scs_float *Xs = c->Xs;
|
|
73
|
-
scs_float *e = c->e;
|
|
74
|
-
scs_float *Z = c->Z;
|
|
75
|
-
scs_float *work = c->work;
|
|
76
|
-
blas_int lwork = c->lwork;
|
|
72
|
+
scs_float *Xs = c->psd_tw->Xs;
|
|
73
|
+
scs_float *e = c->psd_tw->e;
|
|
74
|
+
scs_float *Z = c->psd_tw->Z;
|
|
75
|
+
scs_float *work = c->psd_tw->work;
|
|
76
|
+
blas_int lwork = c->psd_tw->lwork;
|
|
77
77
|
blas_int info = 0;
|
|
78
78
|
scs_int status;
|
|
79
79
|
char transN;
|
|
@@ -96,11 +96,13 @@ scs_int SCS(proj_sum_largest_evals)(scs_float *tX, scs_int n, scs_int k,
|
|
|
96
96
|
* order (smallest eigenvalue first)
|
|
97
97
|
*/
|
|
98
98
|
BLAS(syev)("Vectors", "Lower", &nb, Xs, &nb, e, work, &lwork, &info);
|
|
99
|
+
/* info < 0: bad argument. info > 0: no convergence, so 'e' and 'Xs' hold
|
|
100
|
+
* partial results. Either way the eigendecomposition below it is built on
|
|
101
|
+
* is meaningless, so fail rather than return a bogus projection. */
|
|
99
102
|
if (info != 0) {
|
|
100
|
-
scs_printf("
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
103
|
+
scs_printf("FATAL: LAPACK syev error in sum-of-largest cone, info = %li\n",
|
|
104
|
+
(long)info);
|
|
105
|
+
return -1;
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
/*
|
data/vendor/scs/test/minunit.h
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
/* Taken from http://www.jera.com/techinfo/jtns/jtn002.html */
|
|
2
2
|
|
|
3
3
|
/* Simple Macros for testing */
|
|
4
|
+
|
|
5
|
+
/* Failures are recorded rather than aborting the run, so that a single run
|
|
6
|
+
* reports every failing test. The runner defines these. */
|
|
7
|
+
#define MU_MAX_FAILED_TESTS 256
|
|
8
|
+
extern int tests_run;
|
|
9
|
+
extern int tests_failed;
|
|
10
|
+
extern int tests_skipped;
|
|
11
|
+
extern const char *failed_tests[MU_MAX_FAILED_TESTS];
|
|
12
|
+
extern const char *skipped_tests[MU_MAX_FAILED_TESTS];
|
|
13
|
+
/* Sentinel returned by a test that is compiled out of the current build (see
|
|
14
|
+
* _SKIP in run_tests.c). Compared by address, so it can never collide with a
|
|
15
|
+
* real failure message. */
|
|
16
|
+
extern const char *const mu_skipped;
|
|
4
17
|
#define mu_assert_less(message, a, b) \
|
|
5
18
|
do { \
|
|
6
19
|
if (a > b) { \
|
|
@@ -22,7 +35,18 @@
|
|
|
22
35
|
scs_printf("*********************************************************\n"); \
|
|
23
36
|
scs_printf("Running test: %s\n", name); \
|
|
24
37
|
const char *message = test(); \
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
if (message == mu_skipped) { \
|
|
39
|
+
scs_printf("skipped\n"); \
|
|
40
|
+
if (tests_skipped < MU_MAX_FAILED_TESTS) \
|
|
41
|
+
skipped_tests[tests_skipped] = name; \
|
|
42
|
+
tests_skipped++; \
|
|
43
|
+
} else { \
|
|
44
|
+
tests_run++; \
|
|
45
|
+
if (message) { \
|
|
46
|
+
scs_printf("FAILED: %s: %s\n", name, message); \
|
|
47
|
+
if (tests_failed < MU_MAX_FAILED_TESTS) \
|
|
48
|
+
failed_tests[tests_failed] = name; \
|
|
49
|
+
tests_failed++; \
|
|
50
|
+
} \
|
|
51
|
+
} \
|
|
28
52
|
} while (0)
|