/* * Bounds + value of x */ static void print_avar_bounds_and_value(FILE *f, simplex_solver_t *solver, thvar_t x) { int32_t lb, ub; lb = arith_var_lower_index(&solver->vtbl, x); ub = arith_var_upper_index(&solver->vtbl, x); fputs(" ", f); print_avar(f, &solver->vtbl, x); fputs(" = ", f); xq_print(f, arith_var_value(&solver->vtbl, x)); if (lb >= 0 || ub >= 0) { fputc('\t', f); if (lb >= 0) { xq_print(f, solver->bstack.bound + lb); fputs(" <= ", f); } print_avar(f, &solver->vtbl, x); if (ub >= 0) { fputs(" <= ", f); xq_print(f, solver->bstack.bound + ub); } } fputc('\n', f); }
/* * Variant of print_simplex_bounds */ void print_simplex_bounds2(FILE *f, simplex_solver_t *solver) { uint32_t i, n; int32_t lb, ub; n = num_arith_vars(&solver->vtbl); for (i=0; i<n; i++) { lb = arith_var_lower_index(&solver->vtbl, i); ub = arith_var_upper_index(&solver->vtbl, i); if (lb >= 0 && ub >= 0) { if (xq_neq(solver->bstack.bound + lb, solver->bstack.bound + ub)) { fputs(" ", f); xq_print(f, solver->bstack.bound + lb); fprintf(f, " <= x_%"PRIu32" <= ", i); xq_print(f, solver->bstack.bound + ub); fputc('\n', f); } } else if (lb >= 0) { fputs(" ", f); xq_print(f, solver->bstack.bound + lb); fprintf(f, " <= x_%"PRIu32"\n", i); } else if (ub >= 0) { fprintf(f, " x_%"PRIu32" <= ", i); xq_print(f, solver->bstack.bound + ub); fputc('\n', f); } } }
/* * Bounds + value of x + row where x is basic */ static void print_avar_full(FILE *f, simplex_solver_t *solver, thvar_t x) { int32_t lb, ub, r; lb = arith_var_lower_index(&solver->vtbl, x); ub = arith_var_upper_index(&solver->vtbl, x); r = matrix_basic_row(&solver->matrix, x); fputs(" ", f); print_avar(f, &solver->vtbl, x); fputs(" = ", f); xq_print(f, arith_var_value(&solver->vtbl, x)); fputc('\t', f); if (lb >= 0 || ub >= 0) { if (lb >= 0) { xq_print(f, solver->bstack.bound + lb); fputs(" <= ", f); } print_avar(f, &solver->vtbl, x); if (ub >= 0) { fputs(" <= ", f); xq_print(f, solver->bstack.bound + ub); } } else { fputs("no bounds", f); } if (r >= 0) { fprintf(f, "\t\tbasic in row[%"PRIu32"]\n", r); } else { fprintf(f, "\t\tnon basic\n"); } }
void print_simplex_vars_summary(FILE *f, simplex_solver_t *solver) { arith_vartable_t *table; uint32_t i, n; int32_t lb, ub; table = &solver->vtbl; n = num_arith_vars(table); for (i=0; i<n; i++) { lb = arith_var_lower_index(&solver->vtbl, i); ub = arith_var_upper_index(&solver->vtbl, i); if (matrix_is_basic_var(&solver->matrix, i)) { fputs(" b ", f); } else { fputs(" ", f); } print_avar(f, table, i); fputs(" = ", f); xq_print(f, arith_var_value(&solver->vtbl, i)); if (lb >= 0 || ub >= 0) { fputs("\t", f); if (lb >= 0) { xq_print(f, solver->bstack.bound + lb); fputs(" <= ", f); } print_avar(f, &solver->vtbl, i); if (ub >= 0) { fputs(" <= ", f); xq_print(f, solver->bstack.bound + ub); } } if (arith_var_has_eterm(table, i)) { fputs("\t\teterm: ", f); print_eterm_id(f, arith_var_eterm(table, i)); } if (arith_var_def_is_poly(table, i)) { fputs("\t\tdef: ", f); print_avar_poly(f, table, arith_var_poly_def(table, i)); } else if (arith_var_def_is_product(table, i)) { fputs("\t\tdef: ", f); print_avar_product(f, table, arith_var_product_def(table, i)); } fputc('\n', f); } fputc('\n', f); }
/* * Remove q from map: q must be present in the table */ static void test_remove(xq_hmap_t *map, xrational_t *q) { uint32_t a, na, ea; uint32_t b, nb, eb; printf("test remove "); xq_print(stdout, q); fflush(stdout); a = xq_hmap_multiplicity(map, q); ea = xq_hmap_num_entries(map); na = xq_hmap_num_classes(map); assert(a > 0 && na > 0 && ea > 0); xq_hmap_remove_entry(map, q); b = xq_hmap_multiplicity(map, q); eb = xq_hmap_num_entries(map); nb = xq_hmap_num_classes(map); if (b != a-1 || eb != ea - 1) { printf(" failed: incorrect counters\n"); fflush(stdout); exit(1); } if ((a == 1 && nb != na - 1) || (a > 1 && nb != na)) { printf(" failed: incorrect number of classes\n"); fflush(stdout); exit(1); } printf(" ok\n"); }
void print_simplex_bound(FILE *f, simplex_solver_t *solver, uint32_t i) { fprintf(f, "bound[%"PRIu32"]: ", i); if (i < solver->bstack.top) { print_avar(f, &solver->vtbl, solver->bstack.var[i]); if (arith_tag_get_type(solver->bstack.tag[i]) == ATYPE_UB) { fputs(" <= ", f); } else { fputs(" >= ", f); } xq_print(f, solver->bstack.bound + i); } else { fprintf(f, "<INVALID BOUND INDEX>"); } }
static void print_hmap(xq_hmap_t *map) { xq_hmap_rec_t *r; uint32_t i, n; printf("map %p\n", map); printf(" size = %"PRIu32"\n", map->size); printf(" nelems = %"PRIu32"\n", map->nelems); printf(" nentries = %"PRIu32"\n", map->nentries); printf(" ndeleted = %"PRIu32"\n", map->ndeleted); printf(" content:\n"); r = map->data; n = map->size; for (i=0; i<n; i++) { if (r->value != 0 && r->value != UINT32_MAX) { printf(" [key = "); xq_print(stdout, &r->key); printf(", value = %"PRIu32"]\n", r->value); } r ++; } printf("\n"); }
void print_simplex_var_value(FILE *f, simplex_solver_t *solver, thvar_t v) { xq_print(f, arith_var_value(&solver->vtbl, v)); }
/* * Value of variable x */ static void print_avar_value(FILE *f, arith_vartable_t *vtbl, thvar_t x) { fputs(" val[", f); print_avar(f, vtbl, x); fputs("] = ", f); xq_print(f, arith_var_value(vtbl, x)); }