vendor/scs/test/problems/small_lp.h in scs-0.2.3 vs vendor/scs/test/problems/small_lp.h in scs-0.3.0

- old
+ new

@@ -5,10 +5,11 @@ #include "util.h" static const char *small_lp(void) { ScsCone *k = (ScsCone *)scs_calloc(1, sizeof(ScsCone)); ScsData *d = (ScsData *)scs_calloc(1, sizeof(ScsData)); + ScsSettings *stgs = (ScsSettings *)scs_calloc(1, sizeof(ScsSettings)); ScsSolution *sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution)); ScsSolution *opt_sol = (ScsSolution *)scs_calloc(1, sizeof(ScsSolution)); ScsInfo info = {0}; scs_float p_f = 0.1; int seed = 1234; @@ -17,34 +18,32 @@ scs_int col_nnz = (scs_int)ceil(sqrt(n)); scs_int nnz = n * col_nnz; scs_int exitflag; scs_float perr, derr; scs_int success; + const char *fail; - d->stgs = (ScsSettings *)scs_calloc(1, sizeof(ScsSettings)); - k->f = (scs_int)floor(m * p_f); - k->l = m - k->f; + k->z = (scs_int)floor(m * p_f); + k->l = m - k->z; - srand(seed); - d->m = m; d->n = n; - gen_random_prob_data(nnz, col_nnz, d, k, opt_sol); - SCS(set_default_settings)(d); + gen_random_prob_data(nnz, col_nnz, d, k, opt_sol, seed); + SCS(set_default_settings)(stgs); + stgs->eps_abs = 1e-5; + stgs->eps_rel = 1e-5; - /* this test fails with the default choice of 10 */ - d->stgs->acceleration_lookback = 20; - - exitflag = scs(d, k, sol, &info); + exitflag = scs(d, k, stgs, sol, &info); perr = SCS(dot)(d->c, sol->x, d->n) - SCS(dot)(d->c, opt_sol->x, d->n); derr = -SCS(dot)(d->b, sol->y, d->m) + SCS(dot)(d->b, opt_sol->y, d->m); scs_printf("primal obj error %4e\n", perr); scs_printf("dual obj error %4e\n", derr); success = ABS(perr) < 1e-4 && ABS(derr) < 1e-4 && exitflag == SCS_SOLVED; - SCS(free_data)(d, k); + mu_assert("small_lp: SCS failed to produce outputflag SCS_SOLVED", success); + fail = verify_solution_correct(d, k, stgs, &info, sol, exitflag); + SCS(free_data)(d, k, stgs); SCS(free_sol)(sol); SCS(free_sol)(opt_sol); - mu_assert("small_lp: SCS failed to produce outputflag SCS_SOLVED", success); - return 0; + return fail; }