From bd991fa3b2dde6e0107ae126b4b934e9437e3066 Mon Sep 17 00:00:00 2001 From: Brendan O'Donoghue Date: Fri, 5 Jul 2024 11:47:23 +0100 Subject: [PATCH] mpc bug test (#280) * mpc bug test * explicit memset to 0 * not sure what is failing * fix n * add some prints * better print * test disable res infeas * disable other tests * Revert "disable other tests" This reverts commit b1a41ba75e657d593d4a5ea2605892748f2559c8. * cleanup * add more tests * rename var --------- Co-authored-by: Brendan O'Donoghue --- include/glbopts.h | 3 +- src/scs.c | 34 +++++++++++------------ test/problems/mpc_bug.h | 19 +++++++++++++ test/problems/mpc_bug1 | Bin 0 -> 23753 bytes test/problems/mpc_bug2 | Bin 0 -> 23753 bytes test/problems/mpc_bug3 | Bin 0 -> 23753 bytes test/problems/test_prob_from_data_file.h | 22 +++++++++++++-- test/run_tests.c | 3 ++ 8 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 test/problems/mpc_bug.h create mode 100644 test/problems/mpc_bug1 create mode 100644 test/problems/mpc_bug2 create mode 100644 test/problems/mpc_bug3 diff --git a/include/glbopts.h b/include/glbopts.h index 4d7b7fdf..ed2a15b5 100644 --- a/include/glbopts.h +++ b/include/glbopts.h @@ -39,7 +39,8 @@ extern "C" { #define WRITE_DATA_FILENAME (0) #define LOG_CSV_FILENAME (0) #define TIME_LIMIT_SECS (0.) - +/* Tolerance to check negativity condition for infeasibility */ +#define INFEAS_NEGATIVITY_TOL (1e-9) /* redefine printfs as needed */ #if NO_PRINTING > 0 /* Disable all printing */ #define scs_printf(...) /* No-op */ diff --git a/src/scs.c b/src/scs.c index 9cb1ee58..7dfd092a 100644 --- a/src/scs.c +++ b/src/scs.c @@ -207,13 +207,13 @@ static void compute_residuals(ScsResiduals *r, scs_int m, scs_int n) { r->res_unbdd_a = NAN; r->res_unbdd_p = NAN; r->res_infeas = NAN; - if (r->ctx_tau < 0) { + if (r->ctx_tau < -INFEAS_NEGATIVITY_TOL) { nm_ax_s = NORM(r->ax_s, m); nm_px = NORM(r->px, n); r->res_unbdd_a = SAFEDIV_POS(nm_ax_s, -r->ctx_tau); r->res_unbdd_p = SAFEDIV_POS(nm_px, -r->ctx_tau); } - if (r->bty_tau < 0) { + if (r->bty_tau < -INFEAS_NEGATIVITY_TOL) { nm_aty = NORM(r->aty, n); r->res_infeas = SAFEDIV_POS(nm_aty, -r->bty_tau); } @@ -587,22 +587,22 @@ static void print_summary(ScsWork *w, scs_int i, SCS(timer) * solve_timer) { scs_printf("\n"); #if VERBOSITY > 0 - scs_printf("Norm u = %4f, ", SCS(norm_2)(w->u, w->d->n + w->d->m + 1)); - scs_printf("Norm u_t = %4f, ", SCS(norm_2)(w->u_t, w->d->n + w->d->m + 1)); - scs_printf("Norm v = %4f, ", SCS(norm_2)(w->v, w->d->n + w->d->m + 1)); - scs_printf("Norm rsk = %4f, ", SCS(norm_2)(w->rsk, w->d->n + w->d->m + 1)); - scs_printf("Norm x = %4f, ", SCS(norm_2)(w->xys_orig->x, w->d->n)); - scs_printf("Norm y = %4f, ", SCS(norm_2)(w->xys_orig->y, w->d->m)); - scs_printf("Norm s = %4f, ", SCS(norm_2)(w->xys_orig->s, w->d->m)); - scs_printf("Norm |Ax + s| = %1.2e, ", SCS(norm_2)(r->ax_s, w->d->m)); - scs_printf("tau = %4f, ", w->u[w->d->n + w->d->m]); - scs_printf("kappa = %4f, ", w->rsk[w->d->n + w->d->m]); - scs_printf("|u - u_t| = %1.2e, ", + scs_printf("Norm u = %1.6e, ", SCS(norm_2)(w->u, w->d->n + w->d->m + 1)); + scs_printf("Norm u_t = %1.6e, ", SCS(norm_2)(w->u_t, w->d->n + w->d->m + 1)); + scs_printf("Norm v = %1.6e, ", SCS(norm_2)(w->v, w->d->n + w->d->m + 1)); + scs_printf("Norm rsk = %1.6e, ", SCS(norm_2)(w->rsk, w->d->n + w->d->m + 1)); + scs_printf("Norm x = %1.6e, ", SCS(norm_2)(w->xys_orig->x, w->d->n)); + scs_printf("Norm y = %1.6e, ", SCS(norm_2)(w->xys_orig->y, w->d->m)); + scs_printf("Norm s = %1.6e, ", SCS(norm_2)(w->xys_orig->s, w->d->m)); + scs_printf("Norm |Ax + s| = %1.6e, ", SCS(norm_2)(r->ax_s, w->d->m)); + scs_printf("tau = %1.6e, ", w->u[w->d->n + w->d->m]); + scs_printf("kappa = %1.6e, ", w->rsk[w->d->n + w->d->m]); + scs_printf("|u - u_t| = %1.6e, ", SCS(norm_diff)(w->u, w->u_t, w->d->n + w->d->m + 1)); - scs_printf("res_infeas = %1.2e, ", r->res_infeas); - scs_printf("res_unbdd_a = %1.2e, ", r->res_unbdd_a); - scs_printf("res_unbdd_p = %1.2e, ", r->res_unbdd_p); - scs_printf("ctx_tau = %1.2e, ", r->ctx_tau); + scs_printf("res_infeas = %1.6e, ", r->res_infeas); + scs_printf("res_unbdd_a = %1.6e, ", r->res_unbdd_a); + scs_printf("res_unbdd_p = %1.6e, ", r->res_unbdd_p); + scs_printf("ctx_tau = %1.6e, ", r->ctx_tau); scs_printf("bty_tau = %1.2e\n", r->bty_tau); #endif diff --git a/test/problems/mpc_bug.h b/test/problems/mpc_bug.h new file mode 100644 index 00000000..e8fc2e03 --- /dev/null +++ b/test/problems/mpc_bug.h @@ -0,0 +1,19 @@ +#include "glbopts.h" +#include "problems/test_prob_from_data_file.h" +#include "scs.h" + +static const char *mpc_bug(void) { + const char *fail; + scs_float OPT1 = -0.473957794500; /* from scs */ + scs_float OPT2 = -0.029336830816; /* from scs */ + scs_float OPT3 = -0.002215217478; /* from scs */ + fail = _test_prob_from_data("test/problems/mpc_bug1", OPT1); + if (fail) { + return fail; + } + fail = _test_prob_from_data("test/problems/mpc_bug2", OPT2); + if (fail) { + return fail; + } + return _test_prob_from_data("test/problems/mpc_bug3", OPT3); +} diff --git a/test/problems/mpc_bug1 b/test/problems/mpc_bug1 new file mode 100644 index 0000000000000000000000000000000000000000..989fbb3e4bb5863af6620ae8317575a1eed2a4c3 GIT binary patch literal 23753 zcmeI32~^J68^_aFD@|#kX^|E}HOMx@)Wb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ii#%BkL&w2 zC2czG{JJ2P9_$@p`_bfhnteBNt=9ELwDj)s(7Fi=sQtvTL+lPLqReUCjV%mUQh1NU zehXf&qgJG*HotDmW(p_DDLEa`g9IheH|jv{Z(piJ)-)bz@~SXra+5S=djBG zWIWtFG3P=M%^z(PzSV6Z#oK0`megNO-O@A;JlEYs#?pQUd*XM}osHi-nL2hc3CX7t zhyT5VhV1-x$U^^R)Jc2m&WCQxsnd1$Q@xXy(cecS#*E8eLOXna%R2w*B64;=5z#Ym zHZ6;K9T;vCNSX$5p&hS%N)NULTG)j2C-)|i{R8GNBaM`seWZra}` zAwxU&`iBDMl7r(U3#a%w^zAq1hWYxTBxGK5J0Z0t{nWwj!dDNWS+}D1KlX_x<*KqH z-?yI^yd6oz*UEB|V(*vsd0ESqw|qtGRaX7VZbwz^sk&WtwXg1es;a-L?zg)1U)}7e zuJ%-SyK0JkHO+y3fE&!HPu5LNYa~_bZm$o0S$M2mhTA$ySR#rRpxgoH;<6^tGJY5`|^s8i|yj}%vEG3x6AKURb@A~&+jeO)epa)QFnj*ezB_h<^Ok5)%`bD zlWtj8Jm2hp_5<5tT}|z2QO)hLsUh~+)-XHyy>WF}r`GTv>yhW3{mS;Xtf78pyIa)~ z`}yzkYN~#C9(WuMwQOE^JgsZ_xE$Y;@wIu+#_5Fd^7r?s&5F-)&+x}bqW`*hz$1Ez i@=5po-$&)%3iaUoe66gWSNL}cXs+=8QFESv+y6hi9d^F} literal 0 HcmV?d00001 diff --git a/test/problems/mpc_bug3 b/test/problems/mpc_bug3 new file mode 100644 index 0000000000000000000000000000000000000000..bfed77f2de6a189d078b6ccdf7350ad672ffa20b GIT binary patch literal 23753 zcmeI33s{fm8^?cg=$uk%QPBahGD&QIBYDV+x}r?q!rfsmy&Y~{onk)cdqO0>gxFWb+F%c< zsfj-=#UK0bJ-hc3`SP=ff2k( z@7(bwtwhefFlbYtiVGdi-5%*E@~G*OK58Q8Ur5S4+02C;?)i8e5xLdDIXqcp($#w^ z*F-M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Y%rVUP#NYhd)eS6-Y^E*KJ5PUP3xnz18>oEG6r1b4_d#me3F1 z8|ysL3M3&X)&8iHC23uq*fV^s2Ys3zy|2JMn&h*}ipIVCJmlp_CcT!IlT~=Xs?V!i zuBPQ{`(9nWU)S|0sy;>6tE~E!-A;YASKsY6l=d5%9Szl~=R5 z`|ea^pe0qJ}Eyag8kD=XKshUGaA z$gfwm9e$6`ooo9(pO@BEJ?dN$Skr#7U0fgMOS$^Gu2+*QR*>CXzm}5Q(MEeZAm^Kz zx{~{RtyjtYHdTDCU(Ip`H7w8hb7{Z0A8aq%!|m{UZEM*szi(8>_3(LlZTrP`aec-L zvXkrOb5%vz&GqxSrLx-L^BHBg$LEXn)h_?PllpGIgOYU1y5jL>|Fa+1j*bn~9`gon zmqjD7&$5x($>+umWuA6~|5%Sa?(A2#w^JkaGuz#{iP+D7m)BVJ!{fmHux?`G!u{#m z#QW9lHR<1*uUS8B&|m)kzGZXi=g5HYf`ieI&m=iUhsvJ}-S^{`d+C9We4nr7uNRm7 QT>`2r`+wA&C*b=34eps_abs = 1e-6; stgs->eps_rel = 1e-6; + /* Force verbosity for the test */ + stgs->verbose = 1; sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution)); exitflag = scs(d, k, stgs, sol, &info); - perr = SCS(dot)(d->c, sol->x, d->n) - OPT; - derr = -SCS(dot)(d->b, sol->y, d->m) - OPT; + if (d->P) { + /* px = Px */ + px = (scs_float *)scs_calloc(d->n, sizeof(scs_float)); + memset(px, 0, d->n * sizeof(scs_float)); + SCS(accum_by_p)(d->P, sol->x, px); + xt_p_x = SCS(dot)(px, sol->x, d->n); + } else { + xt_p_x = 0.; + } + + perr = 0.5 * xt_p_x + SCS(dot)(d->c, sol->x, d->n) - OPT; + derr = -0.5 * xt_p_x - SCS(dot)(d->b, sol->y, d->m) - OPT; scs_printf("primal obj error %4e\n", perr); scs_printf("dual obj error %4e\n", derr); @@ -47,7 +61,9 @@ static const char *_test_prob_from_data(const char *file, scs_float OPT) { SCS(free_cone)(k); SCS(free_sol)(sol); scs_free(stgs); - + if (px) { + scs_free(px); + } if (fail) { scs_printf("%s: FAILED\n", file); } diff --git a/test/run_tests.c b/test/run_tests.c index 337b5d7a..15094ce7 100644 --- a/test/run_tests.c +++ b/test/run_tests.c @@ -43,9 +43,11 @@ _SKIP(random_prob) #if NO_READ_WRITE == 0 /* reads / writes */ #include "problems/hs21_tiny_qp_rw.h" #include "problems/max_ent.h" +#include "problems/mpc_bug.h" #else _SKIP(hs21_tiny_qp_rw) _SKIP(max_ent) +_SKIP(mpc_bug) #endif static const char *all_tests(void) { @@ -61,6 +63,7 @@ static const char *all_tests(void) { mu_run_test(unbounded_tiny_qp); mu_run_test(random_prob); mu_run_test(max_ent); + mu_run_test(mpc_bug); mu_run_test(test_exp_cone); return 0; }