diff --git a/DESCRIPTION b/DESCRIPTION index 1b8fec2..417c32a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "FlorianSchwendinger@gmx.at"), +Authors@R: c( person("Florian", "Schwendinger", role = c("aut", "cre"), email = "FlorianSchwendinger@gmx.at"), 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")) diff --git a/NEWS.md b/NEWS.md index 5aef3d5..a4d807c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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`. diff --git a/src/scs b/src/scs index 3aaa93c..d48ce1b 160000 --- a/src/scs +++ b/src/scs @@ -1 +1 @@ -Subproject commit 3aaa93c7aa04c7001df5e51b81f21b126dfa99b3 +Subproject commit d48ce1b457d5b49ff91f9778849d1f8d9db3cdd4 diff --git a/src/scs_mods/rw.c b/src/scs_mods/rw.c index 7775765..02826f9 100644 --- a/src/scs_mods/rw.c +++ b/src/scs_mods/rw.c @@ -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 */ diff --git a/src/scsr.c b/src/scsr.c index a6df8ac..1d2a2ba 100644 --- a/src/scsr.c +++ b/src/scsr.c @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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 */ @@ -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 */ @@ -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 */ diff --git a/tests/testthat/problem_results/degenerate1.RDS b/tests/testthat/problem_results/degenerate1.RDS index 9743f2e..1407ce4 100644 Binary files a/tests/testthat/problem_results/degenerate1.RDS and b/tests/testthat/problem_results/degenerate1.RDS differ diff --git a/tests/testthat/problem_results/degenerate2.RDS b/tests/testthat/problem_results/degenerate2.RDS index 1d9ace3..f021b03 100644 Binary files a/tests/testthat/problem_results/degenerate2.RDS and b/tests/testthat/problem_results/degenerate2.RDS differ diff --git a/tests/testthat/problem_results/degenerate3.RDS b/tests/testthat/problem_results/degenerate3.RDS index d071407..3591816 100644 Binary files a/tests/testthat/problem_results/degenerate3.RDS and b/tests/testthat/problem_results/degenerate3.RDS differ diff --git a/tests/testthat/problem_results/degenerate4.RDS b/tests/testthat/problem_results/degenerate4.RDS index 5c96119..3208461 100644 Binary files a/tests/testthat/problem_results/degenerate4.RDS and b/tests/testthat/problem_results/degenerate4.RDS differ diff --git a/tests/testthat/problem_results/hs21_tiny_qp1.RDS b/tests/testthat/problem_results/hs21_tiny_qp1.RDS index 53b0c7c..54d54db 100644 Binary files a/tests/testthat/problem_results/hs21_tiny_qp1.RDS and b/tests/testthat/problem_results/hs21_tiny_qp1.RDS differ diff --git a/tests/testthat/problem_results/hs21_tiny_qp2.RDS b/tests/testthat/problem_results/hs21_tiny_qp2.RDS index dee2136..6275c4a 100644 Binary files a/tests/testthat/problem_results/hs21_tiny_qp2.RDS and b/tests/testthat/problem_results/hs21_tiny_qp2.RDS differ diff --git a/tests/testthat/problem_results/infeasible_tiny_qp.RDS b/tests/testthat/problem_results/infeasible_tiny_qp.RDS index 399850a..e876094 100644 Binary files a/tests/testthat/problem_results/infeasible_tiny_qp.RDS and b/tests/testthat/problem_results/infeasible_tiny_qp.RDS differ diff --git a/tests/testthat/problem_results/qafiro_tiny_qp1.RDS b/tests/testthat/problem_results/qafiro_tiny_qp1.RDS index c47f957..a051e90 100644 Binary files a/tests/testthat/problem_results/qafiro_tiny_qp1.RDS and b/tests/testthat/problem_results/qafiro_tiny_qp1.RDS differ diff --git a/tests/testthat/problem_results/qafiro_tiny_qp2.RDS b/tests/testthat/problem_results/qafiro_tiny_qp2.RDS index d302f68..e630894 100644 Binary files a/tests/testthat/problem_results/qafiro_tiny_qp2.RDS and b/tests/testthat/problem_results/qafiro_tiny_qp2.RDS differ diff --git a/tests/testthat/problem_results/qafiro_tiny_qp3.RDS b/tests/testthat/problem_results/qafiro_tiny_qp3.RDS index 79296d3..8ee9df4 100644 Binary files a/tests/testthat/problem_results/qafiro_tiny_qp3.RDS and b/tests/testthat/problem_results/qafiro_tiny_qp3.RDS differ diff --git a/tests/testthat/problem_results/random_prob.RDS b/tests/testthat/problem_results/random_prob.RDS index 3ce2eb4..16d23b8 100644 Binary files a/tests/testthat/problem_results/random_prob.RDS and b/tests/testthat/problem_results/random_prob.RDS differ diff --git a/tests/testthat/problem_results/rob_gauss_cov_est1.RDS b/tests/testthat/problem_results/rob_gauss_cov_est1.RDS index 5b57fea..47cbf84 100644 Binary files a/tests/testthat/problem_results/rob_gauss_cov_est1.RDS and b/tests/testthat/problem_results/rob_gauss_cov_est1.RDS differ diff --git a/tests/testthat/problem_results/rob_gauss_cov_est2.RDS b/tests/testthat/problem_results/rob_gauss_cov_est2.RDS index c9bbe58..fa1cba0 100644 Binary files a/tests/testthat/problem_results/rob_gauss_cov_est2.RDS and b/tests/testthat/problem_results/rob_gauss_cov_est2.RDS differ diff --git a/tests/testthat/problem_results/small_lp.RDS b/tests/testthat/problem_results/small_lp.RDS index 57788df..b33677a 100644 Binary files a/tests/testthat/problem_results/small_lp.RDS and b/tests/testthat/problem_results/small_lp.RDS differ diff --git a/tests/testthat/problem_results/unbounded_tiny_qp.RDS b/tests/testthat/problem_results/unbounded_tiny_qp.RDS index 2dd296a..38d4609 100644 Binary files a/tests/testthat/problem_results/unbounded_tiny_qp.RDS and b/tests/testthat/problem_results/unbounded_tiny_qp.RDS differ diff --git a/tests/testthat/test_problems.R b/tests/testthat/test_problems.R index 95b3ce2..c8b60e8 100644 --- a/tests/testthat/test_problems.R +++ b/tests/testthat/test_problems.R @@ -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")