Skip to content

Commit

Permalink
Merge branch 'master' into remove_matrix_dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianSchwendinger authored Aug 12, 2022
2 parents 6cb6cac + 1b6dec8 commit e5f6279
Show file tree
Hide file tree
Showing 21 changed files with 52 additions and 40 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Package: scs
Version: 3.0-1
Title: Splitting Conic Solver
Authors@R: c( person("Florian", "Schwendinger", role = c("ctb", "cre"), email = "[email protected]"),
Authors@R: c( person("Florian", "Schwendinger", role = c("aut", "cre"), email = "[email protected]"),
person("Brendan", "O'Donoghue", role = c("aut", "cph")),
person("Balasubramanian", "Narasimhan", role = c("ctb")),
person("Balasubramanian", "Narasimhan", role = c("aut")),
person("Timothy A.", "Davis", role = "cph"),
person("Patrick R.", "Amestory", role = "cph"),
person("Iain S.", "Duff", role = "cph"))
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# scs 1.3-2
# scs 3.0-0

- Set `acceleration_lookback` parameter to (current default) `10L`
from previous value of `20L`.
Expand Down
4 changes: 2 additions & 2 deletions src/scs_mods/rw.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "scs_matrix.h"
#include "util.h"

#define FREAD(a, b, c, d) if ( fread((a), (b), (c), (d)) != (b) ) scs_printf("error reading data\n")
#define FWRITE(a, b, c, d) if ( fwrite((a), (b), (c), (d)) != (b) ) scs_printf("error writing data\n")
#define FREAD(a, b, c, d) if ( fread((a), (b), (c), (d)) != (c) ) scs_printf("error reading data\n")
#define FWRITE(a, b, c, d) if ( fwrite((a), (b), (c), (d)) != (c) ) scs_printf("error writing data\n")

/* writes/reads problem data to/from filename */
/* This is a VERY naive implementation, doesn't care about portability etc */
Expand Down
50 changes: 31 additions & 19 deletions src/scsr.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ SEXP floatVec2R(scs_int n, scs_float *in) {
return ret;
}

const char *getStrFromListWithDefault(SEXP list, const char *str,
const char *def) {
SEXP val = getListElement(list, str);
if (val == R_NilValue) {
return def;
}
val = coerceVector(val, STRSXP);
return CHAR(STRING_ELT(val, 0));
}

scs_float getFloatFromListWithDefault(SEXP list, const char *str,
scs_float def) {
SEXP val = getListElement(list, str);
Expand Down Expand Up @@ -93,13 +103,13 @@ SEXP populateInfoR(ScsInfo *info) {

PROTECT(statusVal_r = allocVector(INTSXP, 1));
INTEGER(statusVal_r)[0] = info->status_val;
SET_STRING_ELT(info_names, 2, mkChar("statusVal"));
SET_STRING_ELT(info_names, 2, mkChar("status_val"));
SET_VECTOR_ELT(infor, 2, statusVal_r);
UNPROTECT(1);

PROTECT(scaleUpdates_r = allocVector(INTSXP, 1));
INTEGER(scaleUpdates_r)[0] = info->scale_updates;
SET_STRING_ELT(info_names, 3, mkChar("scaleUpdates"));
SET_STRING_ELT(info_names, 3, mkChar("scale_updates"));
SET_VECTOR_ELT(infor, 3, scaleUpdates_r);
UNPROTECT(1);

Expand All @@ -117,13 +127,13 @@ SEXP populateInfoR(ScsInfo *info) {

PROTECT(resPri_r = allocVector(REALSXP, 1));
REAL(resPri_r)[0] = info->res_pri;
SET_STRING_ELT(info_names, 6, mkChar("resPri"));
SET_STRING_ELT(info_names, 6, mkChar("res_pri"));
SET_VECTOR_ELT(infor, 6, resPri_r);
UNPROTECT(1);

PROTECT(resDual_r = allocVector(REALSXP, 1));
REAL(resDual_r)[0] = info->res_dual;
SET_STRING_ELT(info_names, 7, mkChar("resDual"));
SET_STRING_ELT(info_names, 7, mkChar("res_dual"));
SET_VECTOR_ELT(infor, 7, resDual_r);
UNPROTECT(1);

Expand All @@ -135,31 +145,31 @@ SEXP populateInfoR(ScsInfo *info) {

PROTECT(resInfeas_r = allocVector(REALSXP, 1));
REAL(resInfeas_r)[0] = info->res_infeas;
SET_STRING_ELT(info_names, 9, mkChar("resInfeas"));
SET_STRING_ELT(info_names, 9, mkChar("res_infeas"));
SET_VECTOR_ELT(infor, 9, resInfeas_r);
UNPROTECT(1);

PROTECT(resUnbddA_r = allocVector(REALSXP, 1));
REAL(resUnbddA_r)[0] = info->res_unbdd_a;
SET_STRING_ELT(info_names, 10, mkChar("resUnbddA"));
SET_STRING_ELT(info_names, 10, mkChar("res_unbdd_a"));
SET_VECTOR_ELT(infor, 10, resUnbddA_r);
UNPROTECT(1);

PROTECT(resUnbddP_r = allocVector(REALSXP, 1));
REAL(resUnbddP_r)[0] = info->res_unbdd_p;
SET_STRING_ELT(info_names, 11, mkChar("resUnbddP"));
SET_STRING_ELT(info_names, 11, mkChar("res_unbdd_p"));
SET_VECTOR_ELT(infor, 11, resUnbddP_r);
UNPROTECT(1);

PROTECT(setupTime_r = allocVector(REALSXP, 1));
REAL(setupTime_r)[0] = info->setup_time;
SET_STRING_ELT(info_names, 12, mkChar("setupTime"));
SET_STRING_ELT(info_names, 12, mkChar("setup_time"));
SET_VECTOR_ELT(infor, 12, setupTime_r);
UNPROTECT(1);

PROTECT(solveTime_r = allocVector(REALSXP, 1));
REAL(solveTime_r)[0] = info->solve_time;
SET_STRING_ELT(info_names, 13, mkChar("solveTime"));
SET_STRING_ELT(info_names, 13, mkChar("solve_time"));
SET_VECTOR_ELT(infor, 13, solveTime_r);
UNPROTECT(1);

Expand All @@ -171,37 +181,37 @@ SEXP populateInfoR(ScsInfo *info) {

PROTECT(compSlack_r = allocVector(REALSXP, 1));
REAL(compSlack_r)[0] = info->comp_slack;
SET_STRING_ELT(info_names, 15, mkChar("compSlack"));
SET_STRING_ELT(info_names, 15, mkChar("comp_slack"));
SET_VECTOR_ELT(infor, 15, compSlack_r);
UNPROTECT(1);

PROTECT(rejectedAccelSteps_r = allocVector(INTSXP, 1));
INTEGER(rejectedAccelSteps_r)[0] = info->rejected_accel_steps;
SET_STRING_ELT(info_names, 16, mkChar("rejectedAccelSteps"));
SET_STRING_ELT(info_names, 16, mkChar("rejected_accel_steps"));
SET_VECTOR_ELT(infor, 16, rejectedAccelSteps_r);
UNPROTECT(1);

PROTECT(acceptedAccelSteps_r = allocVector(INTSXP, 1));
INTEGER(acceptedAccelSteps_r)[0] = info->accepted_accel_steps;
SET_STRING_ELT(info_names, 17, mkChar("acceptedAccelSteps"));
SET_STRING_ELT(info_names, 17, mkChar("accepted_accel_steps"));
SET_VECTOR_ELT(infor, 17, acceptedAccelSteps_r);
UNPROTECT(1);

PROTECT(linsysTime_r = allocVector(REALSXP, 1));
REAL(linsysTime_r)[0] = info->lin_sys_time;
SET_STRING_ELT(info_names, 18, mkChar("linsysTime"));
SET_STRING_ELT(info_names, 18, mkChar("lin_sys_time"));
SET_VECTOR_ELT(infor, 18, linsysTime_r);
UNPROTECT(1);

PROTECT(coneTime_r = allocVector(REALSXP, 1));
REAL(coneTime_r)[0] = info->cone_time;
SET_STRING_ELT(info_names, 19, mkChar("coneTime"));
SET_STRING_ELT(info_names, 19, mkChar("cone_time"));
SET_VECTOR_ELT(infor, 19, coneTime_r);
UNPROTECT(1);

PROTECT(accelTime_r = allocVector(REALSXP, 1));
REAL(accelTime_r)[0] = info->accel_time;
SET_STRING_ELT(info_names, 20, mkChar("accelTime"));
SET_STRING_ELT(info_names, 20, mkChar("accel_time"));
SET_VECTOR_ELT(infor, 20, accelTime_r);
UNPROTECT(1);

Expand All @@ -210,7 +220,7 @@ SEXP populateInfoR(ScsInfo *info) {
}

SEXP scsr(SEXP data, SEXP cone, SEXP params) {
scs_int len, exit_flag;
scs_int len;
SEXP ret, retnames, infor, xr, yr, sr;

/* allocate memory */
Expand Down Expand Up @@ -263,8 +273,10 @@ SEXP scsr(SEXP data, SEXP cone, SEXP params) {
ACCELERATION_INTERVAL);
stgs->adaptive_scale = getIntFromListWithDefault(params, "adaptive_scale", ADAPTIVE_SCALE);
/* Without this nulling out, things bomb! */
stgs->write_data_filename = NULL;
stgs->log_csv_filename = NULL;
/* stgs->write_data_filename = NULL; */
/* stgs->log_csv_filename = NULL; */
stgs->write_data_filename = getStrFromListWithDefault(params, "write_data_filename", (char *) NULL);
stgs->log_csv_filename = getStrFromListWithDefault(params, "log_csv_filename", (char *) NULL);
stgs->time_limit_secs = getFloatFromListWithDefault(params, "time_limit_secs", TIME_LIMIT_SECS);

/* Warm start data consists of x, y, s from previous solution and need to be stuffed into */
Expand Down Expand Up @@ -302,7 +314,7 @@ SEXP scsr(SEXP data, SEXP cone, SEXP params) {
/* solve! */
/* scs(d, k, sol, info); */
/* exit_flag is stuffed in info anyway, so ignore... */
exit_flag = scs(d, k, stgs, sol, info);
scs(d, k, stgs, sol, info);

PROTECT(infor = populateInfoR(info)); /* count = 1 */

Expand Down
Binary file modified tests/testthat/problem_results/degenerate1.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/degenerate2.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/degenerate3.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/degenerate4.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/hs21_tiny_qp1.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/hs21_tiny_qp2.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/infeasible_tiny_qp.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/qafiro_tiny_qp1.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/qafiro_tiny_qp2.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/qafiro_tiny_qp3.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/random_prob.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/rob_gauss_cov_est1.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/rob_gauss_cov_est2.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/small_lp.RDS
Binary file not shown.
Binary file modified tests/testthat/problem_results/unbounded_tiny_qp.RDS
Binary file not shown.
30 changes: 15 additions & 15 deletions tests/testthat/test_problems.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ rds_files <- c(
info_vars_to_check <- c(
"iter",
"status",
"statusVal",
"scaleUpdates",
"status_val",
"scale_updates",
"pobj",
"dobj",
## "resPri",
## "resDual",
## "res_pri",
## "res_dual",
## "gap",
"resInfeas",
"resUnbddA",
"resUnbddP",
## "setupTime",
## "solveTime",
"res_infeas",
"res_unbdd_a",
"res_unbdd_p",
## "setup_time",
## "solve_time",
"scale",
## "compSlack",
"rejectedAccelSteps",
"acceptedAccelSteps"
## "linsysTime",
## "coneTime",
## "accelTime"
## "comp_slack",
"rejected_accel_steps",
"accepted_accel_steps"
## "lin_sys_time",
## "cone_time",
## "accel_time"
)

sol_vars_to_check <- c("x", "y", "s")
Expand Down

0 comments on commit e5f6279

Please sign in to comment.