scs 0.4.1 → 0.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9005db60b3ebc21bfe74e18fbd90db752801cce6232c5dcbbf9746ed6a3772b9
4
- data.tar.gz: 8d1eade7f1501cbf46e820a2e7b20133f008e14d2bcc098629643a9b750b55b3
3
+ metadata.gz: 82ca3e4eb97e0a3d55e0755babc5ba5cca8d0eb0c171a0733c38916726697bd5
4
+ data.tar.gz: f91bdb81c22052f788c615dd9bc598941741f1fdba59d741bcaa4b6633c1eae5
5
5
  SHA512:
6
- metadata.gz: 98ecf4f8beb7215e0ca44a57e3345b257054948c311e8e749f31d698e27c7f6c66ccbaaa71bbb091a92d4a23809b9b98a5d65767ee8d58e78cc7a8f08a32e042
7
- data.tar.gz: 4701d88bad2ae68509fba757a922019400a78f8d8c2bdf0e33f35f7e409c49b0e8306d0cc3281a542508e3a73176042bf16a6039aee5101430ff378689791686
6
+ metadata.gz: 835cbd3b7a6fcd085663ef49c54d10c2bfecee3c2435b2b873cfeab01efa90dba7f7a0f59f4487dad15135570399c75c002864dadc4031dda83af1de0abb509a
7
+ data.tar.gz: a9401bac5dd33e24e140061d66cc52fe02c2982bc63b96ebf44f5c13affc8e6f8477bf4907043902278b90e673aca848e77bcad8fc90f2f94550729b25a5de81
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.2 (2024-07-10)
2
+
3
+ - Updated SCS to 3.2.6
4
+
1
5
  ## 0.4.1 (2023-04-09)
2
6
 
3
7
  - Updated SCS to 3.2.3
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-2023 Andrew Kane
4
+ Copyright (c) 2019-2024 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
@@ -36,7 +36,7 @@ module SCS
36
36
  "ScsMatrix *a",
37
37
  "ScsMatrix *p",
38
38
  "scs_float *b",
39
- "scs_float *c",
39
+ "scs_float *c"
40
40
  ]
41
41
 
42
42
  m::Cone = struct [
@@ -52,7 +52,7 @@ module SCS
52
52
  "scs_int ep",
53
53
  "scs_int ed",
54
54
  "scs_float *p",
55
- "scs_int psize",
55
+ "scs_int psize"
56
56
  ]
57
57
 
58
58
  m::Solution = struct [
data/lib/scs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SCS
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/scs.rb CHANGED
@@ -2,9 +2,9 @@
2
2
  require "fiddle/import"
3
3
 
4
4
  # modules
5
- require "scs/matrix"
6
- require "scs/solver"
7
- require "scs/version"
5
+ require_relative "scs/matrix"
6
+ require_relative "scs/solver"
7
+ require_relative "scs/version"
8
8
 
9
9
  module SCS
10
10
  class Error < StandardError; end
@@ -10,7 +10,7 @@ authors:
10
10
  - family-names: "Boyd"
11
11
  given-names: "Stephen"
12
12
  title: "SCS: Spltting Conic Solver"
13
- version: 3.2.3
13
+ version: 3.2.6
14
14
  date-released: 2023
15
15
  url: "https://github.com/cvxgrp/scs"
16
16
 
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.5)
6
6
  project(
7
7
  scs
8
8
  LANGUAGES C
9
- VERSION 3.2.3)
9
+ VERSION 3.2.6)
10
10
 
11
11
  # Defines the CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR and many other useful
12
12
  # macros. See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
@@ -121,7 +121,15 @@ message(STATUS "Printing is NOT ${NO_PRINTING}")
121
121
  option(NO_READ_WRITE "Disables all read/write functionality" OFF)
122
122
  message(STATUS "Read/write functionality is NOT ${NO_READ_WRITE}")
123
123
 
124
- set(COMPILER_OPTS "-DUSE_LAPACK -DCTRLC")
124
+ option(USE_LAPACK "Whether to use BLAS/LAPACK" ON)
125
+ message(STATUS "BLAS/LAPACK usage is ${USE_LAPACK}")
126
+
127
+ # Enable OpenMP support
128
+ option(USE_OPENMP "Compile with OpenMP support" OFF)
129
+ message(STATUS "OpenMP parallelization is ${USE_OPENMP}")
130
+
131
+ set(COMPILER_OPTS "-DCTRLC")
132
+ set(LAPACK_LINK_LIBRARIES "")
125
133
 
126
134
  # Primitive types
127
135
  if(SFLOAT)
@@ -146,7 +154,17 @@ if(NO_READ_WRITE)
146
154
  set(COMPILER_OPTS "-DNO_READ_WRITE=1 ${COMPILER_OPTS}")
147
155
  endif()
148
156
 
157
+ if (USE_LAPACK)
158
+ set(COMPILER_OPTS "-DUSE_LAPACK ${COMPILER_OPTS}")
159
+ list(APPEND LAPACK_LINK_LIBRARIES "blas" "lapack")
160
+ endif()
161
+
162
+ if(USE_OPENMP)
163
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
164
+ endif()
165
+
149
166
  message(STATUS "COMPILER_OPTS = ${COMPILER_OPTS}")
167
+ message(STATUS "CMAKE_C_FLAGS = ${CMAKE_C_FLAGS}")
150
168
 
151
169
  # TODO this is a hack that overwrites the scs_types.h file, we should find a way
152
170
  # to do this that doesn't pollute the master directory.
@@ -226,8 +244,8 @@ target_include_directories(
226
244
  # Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
227
245
  target_compile_definitions(${${PROJECT_NAME}_DIRECT} PRIVATE ${COMPILER_OPTS})
228
246
 
229
- # The library depends on math (m) blas and lapack
230
- target_link_libraries(${${PROJECT_NAME}_DIRECT} PRIVATE m blas lapack)
247
+ # The library depends on math (m) and (optionally) blas and lapack
248
+ target_link_libraries(${${PROJECT_NAME}_DIRECT} PRIVATE m ${LAPACK_LINK_LIBRARIES})
231
249
 
232
250
  # Set some properties
233
251
  set_target_properties(
@@ -274,8 +292,8 @@ target_include_directories(
274
292
  target_compile_definitions(${${PROJECT_NAME}_INDIRECT} PRIVATE ${COMPILER_OPTS}
275
293
  -DINDIRECT)
276
294
 
277
- # The library depends on math (m) blas and lapack
278
- target_link_libraries(${${PROJECT_NAME}_INDIRECT} PUBLIC m blas lapack)
295
+ # The library depends on math (m) and (optionally) blas and lapack
296
+ target_link_libraries(${${PROJECT_NAME}_INDIRECT} PUBLIC m ${LAPACK_LINK_LIBRARIES})
279
297
 
280
298
  # Set some properties
281
299
  set_target_properties(
data/vendor/scs/Makefile CHANGED
@@ -151,7 +151,7 @@ $(GPUINDIR)/private.o: $(GPUINDIR)/private.c
151
151
  # $(ARCHIVE) $@ $^
152
152
  # - $(RANLIB) $@
153
153
 
154
- $(OUT)/libscsgpuindir.$(SHARED): $(SCS_O) $(SCS_OBJECTS) $(GPUINDIR)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o $(LINSYS)/gpu/gpu.o
154
+ $(OUT)/libscsgpuindir.$(SHARED): $(SCS_INDIR_O) $(SCS_OBJECTS) $(GPUINDIR)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o $(LINSYS)/gpu/gpu.o
155
155
  mkdir -p $(OUT)
156
156
  $(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS) $(CULDFLAGS)
157
157
 
data/vendor/scs/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  SCS (`splitting conic solver`) is a numerical optimization package for solving
11
- large-scale convex cone problems. The current version is `3.2.3`.
11
+ large-scale convex cone problems. The current version is `3.2.6`.
12
12
 
13
13
  The full documentation is available [here](https://www.cvxgrp.org/scs/).
14
14
 
@@ -14,7 +14,7 @@ extern "C" {
14
14
 
15
15
  /* SCS VERSION NUMBER ---------------------------------------------- */
16
16
  /* string literals automatically null-terminated */
17
- #define SCS_VERSION ("3.2.3")
17
+ #define SCS_VERSION ("3.2.6")
18
18
 
19
19
  /* verbosity level */
20
20
  #ifndef VERBOSITY
@@ -39,7 +39,8 @@ extern "C" {
39
39
  #define WRITE_DATA_FILENAME (0)
40
40
  #define LOG_CSV_FILENAME (0)
41
41
  #define TIME_LIMIT_SECS (0.)
42
-
42
+ /* Tolerance to check negativity condition for infeasibility */
43
+ #define INFEAS_NEGATIVITY_TOL (1e-9)
43
44
  /* redefine printfs as needed */
44
45
  #if NO_PRINTING > 0 /* Disable all printing */
45
46
  #define scs_printf(...) /* No-op */
@@ -17,8 +17,10 @@ extern "C" {
17
17
  /* single or double precision */
18
18
  #ifndef SFLOAT
19
19
  #define BLAS(x) d##x
20
+ #define BLASI(x) id##x
20
21
  #else
21
22
  #define BLAS(x) s##x
23
+ #define BLASI(x) is##x
22
24
  #endif
23
25
  #else
24
26
  /* this extra indirection is needed for BLASSUFFIX to work correctly as a
@@ -28,8 +30,10 @@ extern "C" {
28
30
  /* single or double precision */
29
31
  #ifndef SFLOAT
30
32
  #define BLAS(x) stitch__(d, x, BLASSUFFIX)
33
+ #define BLASI(x) stitch__(id, x, BLASSUFFIX)
31
34
  #else
32
35
  #define BLAS(x) stitch__(s, x, BLASSUFFIX)
36
+ #define BLASI(x) stitch__(is, x, BLASSUFFIX)
33
37
  #endif
34
38
  #endif
35
39
 
@@ -1,6 +1,6 @@
1
1
  #include "private.h"
2
2
 
3
- const char *scs_get_lin_sys_method() {
3
+ const char *scs_get_lin_sys_method(void) {
4
4
  return "sparse-direct-amd-qdldl";
5
5
  }
6
6
 
@@ -1,6 +1,6 @@
1
1
  #include "private.h"
2
2
 
3
- const char *scs_get_lin_sys_method() {
3
+ const char *scs_get_lin_sys_method(void) {
4
4
  return "sparse-indirect-scs";
5
5
  }
6
6
 
data/vendor/scs/scs.mk CHANGED
@@ -143,7 +143,7 @@ MKLFLAGS = -L$(MKLROOT) -L$(MKLROOT)/lib -Wl,--no-as-needed -lmkl_rt -lmkl_gnu_t
143
143
  USE_OPENMP = 0
144
144
  ifneq ($(USE_OPENMP), 0)
145
145
  override CFLAGS += -fopenmp
146
- LDFLAGS += -lgomp
146
+ LDFLAGS += -fopenmp
147
147
  endif
148
148
 
149
149
  ############ SDPS: BLAS + LAPACK ############
@@ -331,7 +331,7 @@ char *SCS(get_cone_header)(const ScsCone *k) {
331
331
  static scs_int set_up_sd_cone_work_space(ScsConeWork *c, const ScsCone *k) {
332
332
  scs_int i;
333
333
  #ifdef USE_LAPACK
334
- blas_int n_max = 0;
334
+ blas_int n_max = 1;
335
335
  blas_int neg_one = -1;
336
336
  blas_int info = 0;
337
337
  scs_float wkopt = 0.0;
@@ -356,7 +356,7 @@ static scs_int set_up_sd_cone_work_space(ScsConeWork *c, const ScsCone *k) {
356
356
  &info);
357
357
 
358
358
  if (info != 0) {
359
- scs_printf("FATAL: syev failure, info = %li\n", (long)info);
359
+ scs_printf("FATAL: syev workspace query failure, info = %li\n", (long)info);
360
360
  return -1;
361
361
  }
362
362
  c->lwork = (blas_int)(wkopt + 1); /* +1 for int casting safety */
@@ -102,12 +102,16 @@ extern "C" {
102
102
  scs_float BLAS(nrm2)(blas_int *n, const scs_float *x, blas_int *incx);
103
103
  scs_float BLAS(dot)(const blas_int *n, const scs_float *x, const blas_int *incx,
104
104
  const scs_float *y, const blas_int *incy);
105
- scs_float BLAS(lange)(const char *norm, const blas_int *m, const blas_int *n,
106
- const scs_float *a, blas_int *lda, scs_float *work);
107
105
  void BLAS(axpy)(blas_int *n, const scs_float *a, const scs_float *x,
108
106
  blas_int *incx, scs_float *y, blas_int *incy);
109
107
  void BLAS(scal)(const blas_int *n, const scs_float *sa, scs_float *sx,
110
108
  const blas_int *incx);
109
+ blas_int BLASI(amax)(blas_int *n, const scs_float *x, blas_int *incx);
110
+
111
+ /* Possibly not working correctly on all platforms.
112
+ scs_float BLAS(lange)(const char *norm, const blas_int *m, const blas_int *n,
113
+ const scs_float *a, blas_int *lda, scs_float *work);
114
+ */
111
115
 
112
116
  #ifdef __cplusplus
113
117
  }
@@ -140,10 +144,20 @@ scs_float SCS(norm_2)(const scs_float *v, scs_int len) {
140
144
  return BLAS(nrm2)(&blen, v, &bone);
141
145
  }
142
146
 
147
+ /* Possibly not working correctly on all platforms.
148
+ scs_float SCS(norm_inf)(const scs_float *a, scs_int len) {
149
+ blas_int bone = 1;
150
+ blas_int blen = (blas_int)len;
151
+ return BLAS(lange)("Max", &blen, &bone, a, &blen, SCS_NULL);
152
+ }
153
+ */
154
+
143
155
  scs_float SCS(norm_inf)(const scs_float *a, scs_int len) {
144
156
  blas_int bone = 1;
145
157
  blas_int blen = (blas_int)len;
146
- return BLAS(lange)("Max", &blen, &bone, a, &bone, SCS_NULL);
158
+ scs_int idx = (scs_int)BLASI(amax)(&blen, a, &bone);
159
+ /* Returned idx is 1-based. */
160
+ return ABS(a[idx - 1]);
147
161
  }
148
162
 
149
163
  /* axpy a += sc*b */
data/vendor/scs/src/rw.c CHANGED
@@ -60,7 +60,7 @@ static size_t read_int(scs_int *dest, size_t file_int_sz, size_t nitems,
60
60
  }
61
61
  void *ptr = scs_calloc(nitems, file_int_sz);
62
62
  size_t val = fread(ptr, file_int_sz, nitems, fin);
63
- scs_int i;
63
+ size_t i;
64
64
  switch (file_int_sz) {
65
65
  case 4:
66
66
  for (i = 0; i < nitems; ++i) {
@@ -328,8 +328,15 @@ void SCS(log_data_to_csv)(const ScsCone *k, const ScsSettings *stgs,
328
328
  "tau_normalized,"
329
329
  "kap_normalized,"
330
330
  "ax_nrm_inf,"
331
+ "ax_s_nrm_inf"
331
332
  "px_nrm_inf,"
332
333
  "aty_nrm_inf,"
334
+ "xt_p_x,"
335
+ "xt_p_x_tau,"
336
+ "ctx,"
337
+ "ctx_tau,"
338
+ "bty,"
339
+ "bty_tau,"
333
340
  "b_nrm_inf,"
334
341
  "c_nrm_inf,"
335
342
  "scale,"
@@ -385,8 +392,15 @@ void SCS(log_data_to_csv)(const ScsCone *k, const ScsSettings *stgs,
385
392
  fprintf(fout, "%.16e,", r_n->tau);
386
393
  fprintf(fout, "%.16e,", r_n->kap);
387
394
  fprintf(fout, "%.16e,", SCS(norm_inf)(r->ax, w->d->m));
395
+ fprintf(fout, "%.16e,", SCS(norm_inf)(r->ax_s, w->d->m));
388
396
  fprintf(fout, "%.16e,", SCS(norm_inf)(r->px, w->d->n));
389
397
  fprintf(fout, "%.16e,", SCS(norm_inf)(r->aty, w->d->n));
398
+ fprintf(fout, "%.16e,", r->xt_p_x);
399
+ fprintf(fout, "%.16e,", r->xt_p_x_tau);
400
+ fprintf(fout, "%.16e,", r->ctx);
401
+ fprintf(fout, "%.16e,", r->ctx_tau);
402
+ fprintf(fout, "%.16e,", r->bty);
403
+ fprintf(fout, "%.16e,", r->bty_tau);
390
404
  fprintf(fout, "%.16e,", SCS(norm_inf)(w->b_orig, w->d->m));
391
405
  fprintf(fout, "%.16e,", SCS(norm_inf)(w->c_orig, w->d->n));
392
406
  fprintf(fout, "%.16e,", w->stgs->scale);
data/vendor/scs/src/scs.c CHANGED
@@ -112,6 +112,9 @@ static void print_init_header(const ScsData *d, const ScsCone *k,
112
112
  if (stgs->time_limit_secs) {
113
113
  scs_printf("\t time_limit_secs: %.2e\n", stgs->time_limit_secs);
114
114
  }
115
+ #ifdef _OPENMP
116
+ scs_printf("\t compiled with openmp parallelization enabled\n");
117
+ #endif
115
118
  if (lin_sys_method) {
116
119
  scs_printf("lin-sys: %s\n\t nnz(A): %li, nnz(P): %li\n", lin_sys_method,
117
120
  (long)d->A->p[d->A->n], d->P ? (long)d->P->p[d->P->n] : 0l);
@@ -204,13 +207,13 @@ static void compute_residuals(ScsResiduals *r, scs_int m, scs_int n) {
204
207
  r->res_unbdd_a = NAN;
205
208
  r->res_unbdd_p = NAN;
206
209
  r->res_infeas = NAN;
207
- if (r->ctx_tau < 0) {
210
+ if (r->ctx_tau < -INFEAS_NEGATIVITY_TOL) {
208
211
  nm_ax_s = NORM(r->ax_s, m);
209
212
  nm_px = NORM(r->px, n);
210
213
  r->res_unbdd_a = SAFEDIV_POS(nm_ax_s, -r->ctx_tau);
211
214
  r->res_unbdd_p = SAFEDIV_POS(nm_px, -r->ctx_tau);
212
215
  }
213
- if (r->bty_tau < 0) {
216
+ if (r->bty_tau < -INFEAS_NEGATIVITY_TOL) {
214
217
  nm_aty = NORM(r->aty, n);
215
218
  r->res_infeas = SAFEDIV_POS(nm_aty, -r->bty_tau);
216
219
  }
@@ -584,22 +587,22 @@ static void print_summary(ScsWork *w, scs_int i, SCS(timer) * solve_timer) {
584
587
  scs_printf("\n");
585
588
 
586
589
  #if VERBOSITY > 0
587
- scs_printf("Norm u = %4f, ", SCS(norm_2)(w->u, w->d->n + w->d->m + 1));
588
- scs_printf("Norm u_t = %4f, ", SCS(norm_2)(w->u_t, w->d->n + w->d->m + 1));
589
- scs_printf("Norm v = %4f, ", SCS(norm_2)(w->v, w->d->n + w->d->m + 1));
590
- scs_printf("Norm rsk = %4f, ", SCS(norm_2)(w->rsk, w->d->n + w->d->m + 1));
591
- scs_printf("Norm x = %4f, ", SCS(norm_2)(w->xys_orig->x, w->d->n));
592
- scs_printf("Norm y = %4f, ", SCS(norm_2)(w->xys_orig->y, w->d->m));
593
- scs_printf("Norm s = %4f, ", SCS(norm_2)(w->xys_orig->s, w->d->m));
594
- scs_printf("Norm |Ax + s| = %1.2e, ", SCS(norm_2)(r->ax_s, w->d->m));
595
- scs_printf("tau = %4f, ", w->u[w->d->n + w->d->m]);
596
- scs_printf("kappa = %4f, ", w->rsk[w->d->n + w->d->m]);
597
- scs_printf("|u - u_t| = %1.2e, ",
590
+ scs_printf("Norm u = %1.6e, ", SCS(norm_2)(w->u, w->d->n + w->d->m + 1));
591
+ scs_printf("Norm u_t = %1.6e, ", SCS(norm_2)(w->u_t, w->d->n + w->d->m + 1));
592
+ scs_printf("Norm v = %1.6e, ", SCS(norm_2)(w->v, w->d->n + w->d->m + 1));
593
+ scs_printf("Norm rsk = %1.6e, ", SCS(norm_2)(w->rsk, w->d->n + w->d->m + 1));
594
+ scs_printf("Norm x = %1.6e, ", SCS(norm_2)(w->xys_orig->x, w->d->n));
595
+ scs_printf("Norm y = %1.6e, ", SCS(norm_2)(w->xys_orig->y, w->d->m));
596
+ scs_printf("Norm s = %1.6e, ", SCS(norm_2)(w->xys_orig->s, w->d->m));
597
+ scs_printf("Norm |Ax + s| = %1.6e, ", SCS(norm_2)(r->ax_s, w->d->m));
598
+ scs_printf("tau = %1.6e, ", w->u[w->d->n + w->d->m]);
599
+ scs_printf("kappa = %1.6e, ", w->rsk[w->d->n + w->d->m]);
600
+ scs_printf("|u - u_t| = %1.6e, ",
598
601
  SCS(norm_diff)(w->u, w->u_t, w->d->n + w->d->m + 1));
599
- scs_printf("res_infeas = %1.2e, ", r->res_infeas);
600
- scs_printf("res_unbdd_a = %1.2e, ", r->res_unbdd_a);
601
- scs_printf("res_unbdd_p = %1.2e, ", r->res_unbdd_p);
602
- scs_printf("ctx_tau = %1.2e, ", r->ctx_tau);
602
+ scs_printf("res_infeas = %1.6e, ", r->res_infeas);
603
+ scs_printf("res_unbdd_a = %1.6e, ", r->res_unbdd_a);
604
+ scs_printf("res_unbdd_p = %1.6e, ", r->res_unbdd_p);
605
+ scs_printf("ctx_tau = %1.6e, ", r->ctx_tau);
603
606
  scs_printf("bty_tau = %1.2e\n", r->bty_tau);
604
607
  #endif
605
608
 
@@ -0,0 +1,19 @@
1
+ #include "glbopts.h"
2
+ #include "problems/test_prob_from_data_file.h"
3
+ #include "scs.h"
4
+
5
+ static const char *mpc_bug(void) {
6
+ const char *fail;
7
+ scs_float OPT1 = -0.473957794500; /* from scs */
8
+ scs_float OPT2 = -0.029336830816; /* from scs */
9
+ scs_float OPT3 = -0.002215217478; /* from scs */
10
+ fail = _test_prob_from_data("test/problems/mpc_bug1", OPT1);
11
+ if (fail) {
12
+ return fail;
13
+ }
14
+ fail = _test_prob_from_data("test/problems/mpc_bug2", OPT2);
15
+ if (fail) {
16
+ return fail;
17
+ }
18
+ return _test_prob_from_data("test/problems/mpc_bug3", OPT3);
19
+ }
Binary file
Binary file
Binary file
@@ -19,6 +19,8 @@ static const char *_test_prob_from_data(const char *file, scs_float OPT) {
19
19
  scs_float perr, derr;
20
20
  scs_int success;
21
21
  const char *fail;
22
+ scs_float xt_p_x;
23
+ scs_float *px = SCS_NULL;
22
24
 
23
25
  read_status = SCS(read_data)(file, &d, &k, &stgs);
24
26
 
@@ -28,12 +30,24 @@ static const char *_test_prob_from_data(const char *file, scs_float OPT) {
28
30
 
29
31
  stgs->eps_abs = 1e-6;
30
32
  stgs->eps_rel = 1e-6;
33
+ /* Force verbosity for the test */
34
+ stgs->verbose = 1;
31
35
 
32
36
  sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution));
33
37
  exitflag = scs(d, k, stgs, sol, &info);
34
38
 
35
- perr = SCS(dot)(d->c, sol->x, d->n) - OPT;
36
- derr = -SCS(dot)(d->b, sol->y, d->m) - OPT;
39
+ if (d->P) {
40
+ /* px = Px */
41
+ px = (scs_float *)scs_calloc(d->n, sizeof(scs_float));
42
+ memset(px, 0, d->n * sizeof(scs_float));
43
+ SCS(accum_by_p)(d->P, sol->x, px);
44
+ xt_p_x = SCS(dot)(px, sol->x, d->n);
45
+ } else {
46
+ xt_p_x = 0.;
47
+ }
48
+
49
+ perr = 0.5 * xt_p_x + SCS(dot)(d->c, sol->x, d->n) - OPT;
50
+ derr = -0.5 * xt_p_x - SCS(dot)(d->b, sol->y, d->m) - OPT;
37
51
  scs_printf("primal obj error %4e\n", perr);
38
52
  scs_printf("dual obj error %4e\n", derr);
39
53
 
@@ -47,7 +61,9 @@ static const char *_test_prob_from_data(const char *file, scs_float OPT) {
47
61
  SCS(free_cone)(k);
48
62
  SCS(free_sol)(sol);
49
63
  scs_free(stgs);
50
-
64
+ if (px) {
65
+ scs_free(px);
66
+ }
51
67
  if (fail) {
52
68
  scs_printf("%s: FAILED\n", file);
53
69
  }
@@ -43,9 +43,11 @@ _SKIP(random_prob)
43
43
  #if NO_READ_WRITE == 0 /* reads / writes */
44
44
  #include "problems/hs21_tiny_qp_rw.h"
45
45
  #include "problems/max_ent.h"
46
+ #include "problems/mpc_bug.h"
46
47
  #else
47
48
  _SKIP(hs21_tiny_qp_rw)
48
49
  _SKIP(max_ent)
50
+ _SKIP(mpc_bug)
49
51
  #endif
50
52
 
51
53
  static const char *all_tests(void) {
@@ -61,6 +63,7 @@ static const char *all_tests(void) {
61
63
  mu_run_test(unbounded_tiny_qp);
62
64
  mu_run_test(random_prob);
63
65
  mu_run_test(max_ent);
66
+ mu_run_test(mpc_bug);
64
67
  mu_run_test(test_exp_cone);
65
68
  return 0;
66
69
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-09 00:00:00.000000000 Z
11
+ date: 2024-07-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: andrew@ankane.org
@@ -102,6 +102,10 @@ files:
102
102
  - vendor/scs/test/problems/infeasible_tiny_qp.h
103
103
  - vendor/scs/test/problems/max_ent
104
104
  - vendor/scs/test/problems/max_ent.h
105
+ - vendor/scs/test/problems/mpc_bug.h
106
+ - vendor/scs/test/problems/mpc_bug1
107
+ - vendor/scs/test/problems/mpc_bug2
108
+ - vendor/scs/test/problems/mpc_bug3
105
109
  - vendor/scs/test/problems/qafiro_tiny_qp.h
106
110
  - vendor/scs/test/problems/random_prob
107
111
  - vendor/scs/test/problems/random_prob.h
@@ -135,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
139
  - !ruby/object:Gem::Version
136
140
  version: '0'
137
141
  requirements: []
138
- rubygems_version: 3.4.10
142
+ rubygems_version: 3.5.11
139
143
  signing_key:
140
144
  specification_version: 4
141
145
  summary: SCS - the splitting conic solver - for Ruby