vendor/scs/src/rw.c in scs-0.3.1 vs vendor/scs/src/rw.c in scs-0.3.2
- old
+ new
@@ -31,24 +31,24 @@
static ScsCone *read_scs_cone(FILE *fin) {
ScsCone *k = (ScsCone *)scs_calloc(1, sizeof(ScsCone));
fread(&(k->z), sizeof(scs_int), 1, fin);
fread(&(k->l), sizeof(scs_int), 1, fin);
fread(&(k->bsize), sizeof(scs_int), 1, fin);
- k->bl = scs_calloc(MAX(k->bsize - 1, 0), sizeof(scs_float));
- k->bu = scs_calloc(MAX(k->bsize - 1, 0), sizeof(scs_float));
+ k->bl = (scs_float *)scs_calloc(MAX(k->bsize - 1, 0), sizeof(scs_float));
+ k->bu = (scs_float *)scs_calloc(MAX(k->bsize - 1, 0), sizeof(scs_float));
fread(k->bl, sizeof(scs_float), MAX(k->bsize - 1, 0), fin);
fread(k->bu, sizeof(scs_float), MAX(k->bsize - 1, 0), fin);
fread(&(k->qsize), sizeof(scs_int), 1, fin);
- k->q = scs_calloc(k->qsize, sizeof(scs_int));
+ k->q = (scs_int *)scs_calloc(k->qsize, sizeof(scs_int));
fread(k->q, sizeof(scs_int), k->qsize, fin);
fread(&(k->ssize), sizeof(scs_int), 1, fin);
- k->s = scs_calloc(k->ssize, sizeof(scs_int));
+ k->s = (scs_int *)scs_calloc(k->ssize, sizeof(scs_int));
fread(k->s, sizeof(scs_int), k->ssize, fin);
fread(&(k->ep), sizeof(scs_int), 1, fin);
fread(&(k->ed), sizeof(scs_int), 1, fin);
fread(&(k->psize), sizeof(scs_int), 1, fin);
- k->p = scs_calloc(k->psize, sizeof(scs_float));
+ k->p = (scs_float *)scs_calloc(k->psize, sizeof(scs_float));
fread(k->p, sizeof(scs_float), k->psize, fin);
return k;
}
static void write_scs_stgs(const ScsSettings *s, FILE *fout) {
@@ -101,15 +101,15 @@
static ScsMatrix *read_amatrix(FILE *fin) {
scs_int Anz;
ScsMatrix *A = (ScsMatrix *)scs_calloc(1, sizeof(ScsMatrix));
fread(&(A->m), sizeof(scs_int), 1, fin);
fread(&(A->n), sizeof(scs_int), 1, fin);
- A->p = scs_calloc(A->n + 1, sizeof(scs_int));
+ A->p = (scs_int *)scs_calloc(A->n + 1, sizeof(scs_int));
fread(A->p, sizeof(scs_int), A->n + 1, fin);
Anz = A->p[A->n];
- A->x = scs_calloc(Anz, sizeof(scs_float));
- A->i = scs_calloc(Anz, sizeof(scs_int));
+ A->x = (scs_float *)scs_calloc(Anz, sizeof(scs_float));
+ A->i = (scs_int *)scs_calloc(Anz, sizeof(scs_int));
fread(A->x, sizeof(scs_float), Anz, fin);
fread(A->i, sizeof(scs_int), Anz, fin);
return A;
}
@@ -130,12 +130,12 @@
static ScsData *read_scs_data(FILE *fin) {
scs_int has_p = 0;
ScsData *d = (ScsData *)scs_calloc(1, sizeof(ScsData));
fread(&(d->m), sizeof(scs_int), 1, fin);
fread(&(d->n), sizeof(scs_int), 1, fin);
- d->b = scs_calloc(d->m, sizeof(scs_float));
- d->c = scs_calloc(d->n, sizeof(scs_float));
+ d->b = (scs_float *)scs_calloc(d->m, sizeof(scs_float));
+ d->c = (scs_float *)scs_calloc(d->n, sizeof(scs_float));
fread(d->b, sizeof(scs_float), d->m, fin);
fread(d->c, sizeof(scs_float), d->n, fin);
d->A = read_amatrix(fin);
/* If has_p bit is not set or this hits end of file then has_p = 0 */
has_p &= fread(&has_p, sizeof(scs_int), 1, fin);
@@ -144,12 +144,12 @@
}
void SCS(write_data)(const ScsData *d, const ScsCone *k,
const ScsSettings *stgs) {
FILE *fout = fopen(stgs->write_data_filename, "wb");
- uint32_t scs_int_sz = (uint32_t)SCS(sizeof_int)();
- uint32_t scs_float_sz = (uint32_t)SCS(sizeof_float)();
+ uint32_t scs_int_sz = (uint32_t)sizeof(scs_int);
+ uint32_t scs_float_sz = (uint32_t)sizeof(scs_float);
const char *scs_version = SCS_VERSION;
uint32_t scs_version_sz = (uint32_t)strlen(scs_version);
scs_printf("writing data to %s\n", stgs->write_data_filename);
fwrite(&(scs_int_sz), sizeof(uint32_t), 1, fout);
fwrite(&(scs_float_sz), sizeof(uint32_t), 1, fout);
@@ -211,10 +211,12 @@
void SCS(log_data_to_csv)(const ScsData *d, const ScsCone *k,
const ScsSettings *stgs, const ScsWork *w,
scs_int iter, SCS(timer) * solve_timer) {
ScsResiduals *r = w->r_orig;
ScsResiduals *r_n = w->r_normalized;
+ ScsSolution *sol = w->xys_orig;
+ ScsSolution *sol_n = w->xys_normalized;
/* if iter 0 open to write, else open to append */
FILE *fout = fopen(stgs->log_csv_filename, iter == 0 ? "w" : "a");
if (!fout) {
scs_printf("Error: Could not open %s for writing\n",
stgs->log_csv_filename);
@@ -225,10 +227,22 @@
/* need to end in comma so that csv parsing is correct */
fprintf(fout, "iter,"
"res_pri,"
"res_dual,"
"gap,"
+ "x_nrm_inf,"
+ "y_nrm_inf,"
+ "s_nrm_inf,"
+ "x_nrm_2,"
+ "y_nrm_2,"
+ "s_nrm_2,"
+ "x_nrm_inf_normalized,"
+ "y_nrm_inf_normalized,"
+ "s_nrm_inf_normalized,"
+ "x_nrm_2_normalized,"
+ "y_nrm_2_normalized,"
+ "s_nrm_2_normalized,"
"ax_s_btau_nrm_inf,"
"px_aty_ctau_nrm_inf,"
"ax_s_btau_nrm_2,"
"px_aty_ctau_nrm_2,"
"res_infeas,"
@@ -250,10 +264,15 @@
"res_unbdd_p_normalized,"
"pobj_normalized,"
"dobj_normalized,"
"tau_normalized,"
"kap_normalized,"
+ "ax_nrm_inf,"
+ "px_nrm_inf,"
+ "aty_nrm_inf,"
+ "b_nrm_inf,"
+ "c_nrm_inf,"
"scale,"
"diff_u_ut_nrm_2,"
"diff_v_v_prev_nrm_2,"
"diff_u_ut_nrm_inf,"
"diff_v_v_prev_nrm_inf,"
@@ -265,10 +284,22 @@
}
fprintf(fout, "%li,", (long)iter);
fprintf(fout, "%.16e,", r->res_pri);
fprintf(fout, "%.16e,", r->res_dual);
fprintf(fout, "%.16e,", r->gap);
+ fprintf(fout, "%.16e,", SCS(norm_inf)(sol->x, w->n));
+ fprintf(fout, "%.16e,", SCS(norm_inf)(sol->y, w->m));
+ fprintf(fout, "%.16e,", SCS(norm_inf)(sol->s, w->m));
+ fprintf(fout, "%.16e,", SCS(norm_2)(sol->x, w->n));
+ fprintf(fout, "%.16e,", SCS(norm_2)(sol->y, w->m));
+ fprintf(fout, "%.16e,", SCS(norm_2)(sol->s, w->m));
+ fprintf(fout, "%.16e,", SCS(norm_inf)(sol_n->x, w->n));
+ fprintf(fout, "%.16e,", SCS(norm_inf)(sol_n->y, w->m));
+ fprintf(fout, "%.16e,", SCS(norm_inf)(sol_n->s, w->m));
+ fprintf(fout, "%.16e,", SCS(norm_2)(sol_n->x, w->n));
+ fprintf(fout, "%.16e,", SCS(norm_2)(sol_n->y, w->m));
+ fprintf(fout, "%.16e,", SCS(norm_2)(sol_n->s, w->m));
fprintf(fout, "%.16e,", SCS(norm_inf)(r->ax_s_btau, w->m));
fprintf(fout, "%.16e,", SCS(norm_inf)(r->px_aty_ctau, w->n));
fprintf(fout, "%.16e,", SCS(norm_2)(r->ax_s_btau, w->m));
fprintf(fout, "%.16e,", SCS(norm_2)(r->px_aty_ctau, w->n));
fprintf(fout, "%.16e,", r->res_infeas);
@@ -290,9 +321,14 @@
fprintf(fout, "%.16e,", r_n->res_unbdd_p);
fprintf(fout, "%.16e,", r_n->pobj);
fprintf(fout, "%.16e,", r_n->dobj);
fprintf(fout, "%.16e,", r_n->tau);
fprintf(fout, "%.16e,", r_n->kap);
+ fprintf(fout, "%.16e,", SCS(norm_inf)(r->ax, w->m));
+ fprintf(fout, "%.16e,", SCS(norm_inf)(r->px, w->n));
+ fprintf(fout, "%.16e,", SCS(norm_inf)(r->aty, w->n));
+ fprintf(fout, "%.16e,", SCS(norm_inf)(w->b_orig, w->m));
+ fprintf(fout, "%.16e,", SCS(norm_inf)(w->c_orig, w->n));
fprintf(fout, "%.16e,", w->scale);
fprintf(fout, "%.16e,", SCS(norm_diff)(w->u, w->u_t, l));
fprintf(fout, "%.16e,", SCS(norm_diff)(w->v, w->v_prev, l));
fprintf(fout, "%.16e,", SCS(norm_inf_diff)(w->u, w->u_t, l));
fprintf(fout, "%.16e,", SCS(norm_inf_diff)(w->v, w->v_prev, l));