scs 0.5.3 → 0.5.5

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.
@@ -0,0 +1,155 @@
1
+ #include "glbopts.h"
2
+ #include "linalg.h"
3
+ #include "minunit.h"
4
+ #include "problem_utils.h"
5
+ #include "rw.h"
6
+ #include "scs.h"
7
+ #include "scs_matrix.h"
8
+ #include "util.h"
9
+
10
+ /* Randomly generated problem that mixes psd and complex psd cones */
11
+ static const char *sd_and_complex_sd(void) {
12
+ ScsCone *k = (ScsCone *)scs_calloc(1, sizeof(ScsCone));
13
+ ScsData *d = (ScsData *)scs_calloc(1, sizeof(ScsData));
14
+ ScsSettings *stgs = (ScsSettings *)scs_calloc(1, sizeof(ScsSettings));
15
+ ScsSolution *sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution));
16
+ ScsInfo info = {0};
17
+ scs_int exitflag;
18
+ scs_float perr, derr;
19
+ scs_int success;
20
+ const char *fail;
21
+
22
+ /* data */
23
+ scs_float Px[] = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
24
+ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
25
+ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
26
+ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
27
+ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1};
28
+
29
+ scs_int Pi[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
30
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
31
+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
32
+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+ 0.2, 0.4, 0.6, 0.8, 0.4, 0.1, 0.6, 0.7, 0.4, 0.9, 0.3, 0.2, 0.4, 0.4,
52
+ 0.8, 1, 0.3, 0.7, 0.2, 0.5, 1, 0.3, 0.9, 0.4, 0.9, 0.8, 0.7, 0.4,
53
+ 0.5, 1, 0.4, 0.3, 0.6, 1, 0.8, 0.6, 0, 1, 0.6, 0.9};
54
+
55
+ scs_int Ai[] = {
56
+ 25, 44, 3, 19, 23, 27, 47, 51, 54, 58, 20, 29, 42, 45, 1, 21, 39, 17,
57
+ 20, 28, 46, 52, 1, 2, 13, 36, 21, 6, 16, 23, 34, 1, 11, 51, 59, 6,
58
+ 7, 8, 15, 30, 39, 47, 22, 7, 12, 30, 31, 38, 48, 29, 39, 56, 19, 24,
59
+ 50, 46, 22, 50, 3, 25, 33, 44, 54, 57, 0, 43, 3, 19, 37, 52, 58, 12,
60
+ 21, 26, 58, 3, 8, 30, 2, 54, 39, 40, 43, 44, 49, 17, 9, 15, 17, 53,
61
+ 59, 14, 0, 5, 5, 44, 48, 58, 14, 15, 48, 31, 29, 40, 41, 42, 6, 53,
62
+ 55, 10, 15, 9, 17, 19, 29, 57, 6, 17, 55, 11, 27, 42, 45, 56, 7, 18,
63
+ 24, 28, 46, 51, 5, 29, 40, 1, 6, 35, 36, 11, 18, 44, 36, 45, 49, 45,
64
+ 56, 57, 0, 7, 25, 42, 48, 0, 10, 25, 43, 47, 58, 3, 11, 30, 40, 43,
65
+ 47, 58, 2, 18, 27, 10, 21, 57, 11, 38, 43, 57, 18, 12, 19, 41, 44, 57};
66
+
67
+ scs_int Ap[] = {0, 2, 10, 14, 17, 22, 26, 27, 31, 35, 42,
68
+ 43, 48, 49, 52, 55, 56, 58, 64, 66, 71, 75,
69
+ 78, 80, 85, 86, 88, 91, 92, 94, 98, 101, 102,
70
+ 106, 109, 109, 111, 116, 119, 124, 130, 133, 135, 137,
71
+ 140, 142, 143, 146, 147, 148, 150, 151, 155, 157, 164,
72
+ 167, 170, 174, 175, 179, 180};
73
+
74
+ scs_float b[] = {-0.1, -0.2, -0.8, 0.7, 0.4, -0.7, -0.1, 1.2, -1, -0.6,
75
+ -0.5, 2.6, 0.3, 0.4, 0.6, 0.8, 0.5, 1.5, 0, 0.3,
76
+ -0.3, -0.7, 1.7, 0.7, -2.3, -2, 0.5, 1.7, 0.6, -0.9,
77
+ -1, 2.4, 0.7, -1.9, 0, -0.1, -1.4, 0, 0.6, 0.2,
78
+ 0.4, -2.6, 1.3, 0.5, -0.6, -0.9, -0.9, 0.9, -0.8, -0.1,
79
+ 0, -0.2, 0.1, -0.7, -0.2, -1.7, 0.8, -0.4, -0.9, -0.2};
80
+
81
+ scs_float c[] = {1.2, -0.2, -0.4, 1.2, -0.2, -1.2, -0.1, -0.5, 1.2, 0.2,
82
+ -0.8, 0.3, -1.6, 1.6, 0.8, -0.4, 0.1, 1.8, 0.4, 1.1,
83
+ 0.2, 1.2, -0.4, -0.6, 1.7, -0.6, -1, -0.5, 0.6, 1.2,
84
+ 2.1, 1.6, 0.6, 1.3, -1, -0.8, -0.8, -0.2, -0.9, 1,
85
+ 0.7, -2, -0.6, -0.5, 0.9, -0.3, -2.1, -0, -0.5, 0.1,
86
+ -0.3, 0.8, 2, 0.8, 0.5, 0.8, -0.3, -0, -1.1, 0.2};
87
+
88
+ scs_int m = 60;
89
+ scs_int n = 60;
90
+ scs_int s[] = {3, 4};
91
+ scs_int sssize = 2;
92
+ scs_int cs[] = {5, 4};
93
+ scs_int cssize = 2;
94
+ k->z = 1;
95
+ k->l = 2;
96
+ k->s = s;
97
+ k->ssize = sssize;
98
+ k->cs = cs;
99
+ k->cssize = cssize;
100
+
101
+ /* computed by SCS with high precision, not confirmed that this is optimal */
102
+ scs_float opt = -135.009872;
103
+ /* end data */
104
+
105
+ d->m = m;
106
+ d->n = n;
107
+ d->b = b;
108
+ d->c = c;
109
+
110
+ d->P = (ScsMatrix *)scs_calloc(1, sizeof(ScsMatrix));
111
+ d->P->m = n;
112
+ d->P->n = n;
113
+ d->P->x = Px;
114
+ d->P->i = Pi;
115
+ d->P->p = Pp;
116
+
117
+ d->A = (ScsMatrix *)scs_calloc(1, sizeof(ScsMatrix));
118
+ d->A->m = m;
119
+ d->A->n = n;
120
+ d->A->x = Ax;
121
+ d->A->i = Ai;
122
+ d->A->p = Ap;
123
+
124
+ scs_set_default_settings(stgs);
125
+ stgs->eps_abs = 1e-7;
126
+ stgs->eps_rel = 1e-7;
127
+ stgs->eps_infeas = 1e-9;
128
+
129
+ exitflag = scs(d, k, stgs, sol, &info);
130
+
131
+ perr = info.pobj - opt;
132
+ derr = info.dobj - opt;
133
+
134
+ scs_printf("primal obj error %4e\n", perr);
135
+ scs_printf("dual obj error %4e\n", derr);
136
+
137
+ success = ABS(perr) < 1e-4 && ABS(derr) < 1e-4 && exitflag == SCS_SOLVED;
138
+
139
+ mu_assert("sd_and_complex_sd: SCS failed to produce outputflag SCS_SOLVED",
140
+ success);
141
+
142
+ fail = verify_solution_correct(d, k, stgs, &info, sol, exitflag);
143
+ if (fail)
144
+ return fail;
145
+
146
+ /* kill data */
147
+ scs_free(d->A);
148
+ scs_free(d->P);
149
+ scs_free(k);
150
+ scs_free(stgs);
151
+ scs_free(d);
152
+ SCS(free_sol)(sol);
153
+
154
+ return fail;
155
+ }
@@ -32,17 +32,25 @@ _SKIP(test_validation)
32
32
  #endif
33
33
 
34
34
  /* solve SDPs, requires blas / lapack */
35
- #if defined(USE_LAPACK) && NO_READ_WRITE == 0
35
+ #if defined(USE_LAPACK)
36
36
  #include "problems/complex_PSD.h"
37
+ #include "problems/sd_and_complex_sd.h"
38
+ #else
39
+ _SKIP(complex_PSD)
40
+ _SKIP(sd_and_complex_sd)
41
+ #endif
42
+
43
+ /* solve SDPs from data files, requires blas / lapack */
44
+ #if defined(USE_LAPACK) && NO_READ_WRITE == 0
37
45
  #include "problems/random_prob.h"
38
- #include "problems/rob_gauss_cov_est.h"
46
+ #include "problems/rob_gauss_cov_est.h" /* tests writing to data file */
39
47
  #else
40
- _SKIP(rob_gauss_cov_est)
41
48
  _SKIP(random_prob)
42
- _SKIP(complex_PSD)
49
+ _SKIP(rob_gauss_cov_est)
43
50
  #endif
44
51
 
45
- #if defined(USE_SPECTRAL_CONES) && NO_READ_WRITE == 0
52
+ /* solve SDPs with spectral cones, requires blas / lapack */
53
+ #if defined(USE_SPECTRAL_CONES)
46
54
  #include "spectral_cones_problems/exp_design.h"
47
55
  #include "spectral_cones_problems/graph_partitioning.h"
48
56
  #include "spectral_cones_problems/robust_pca.h"
@@ -58,7 +66,8 @@ _SKIP(several_nuc_cone)
58
66
  _SKIP(several_logdet_cones)
59
67
  #endif
60
68
 
61
- #if NO_READ_WRITE == 0 /* reads / writes */
69
+ /* solves problems from data files */
70
+ #if NO_READ_WRITE == 0
62
71
  #include "problems/hs21_tiny_qp_rw.h"
63
72
  #include "problems/max_ent.h"
64
73
  #include "problems/mpc_bug.h"
@@ -75,6 +84,7 @@ static const char *all_tests(void) {
75
84
  mu_run_test(small_qp);
76
85
  mu_run_test(rob_gauss_cov_est);
77
86
  mu_run_test(complex_PSD);
87
+ mu_run_test(sd_and_complex_sd);
78
88
  mu_run_test(hs21_tiny_qp);
79
89
  mu_run_test(hs21_tiny_qp_rw);
80
90
  mu_run_test(qafiro_tiny_qp);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
@@ -135,6 +135,7 @@ files:
135
135
  - vendor/scs/test/problems/random_prob
136
136
  - vendor/scs/test/problems/random_prob.h
137
137
  - vendor/scs/test/problems/rob_gauss_cov_est.h
138
+ - vendor/scs/test/problems/sd_and_complex_sd.h
138
139
  - vendor/scs/test/problems/small_lp.h
139
140
  - vendor/scs/test/problems/small_qp.h
140
141
  - vendor/scs/test/problems/test_exp_cone.h
@@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  - !ruby/object:Gem::Version
170
171
  version: '0'
171
172
  requirements: []
172
- rubygems_version: 3.6.9
173
+ rubygems_version: 4.0.3
173
174
  specification_version: 4
174
175
  summary: SCS - the splitting conic solver - for Ruby
175
176
  test_files: []