Skip to content

Commit

Permalink
isl_tab_compute_reduced_basis: only print error message on actual non…
Browse files Browse the repository at this point in the history
…-solution

The original assert hints that the error is caused by an unexpected
unboundedness, but the called function may also fail due to a failed
memory allocation or because the computation has exceeded the maximal
number of operations.  In these latter cases, no (additional) error
message should be printed.

Signed-off-by: Sven Verdoolaege <[email protected]>
  • Loading branch information
Sven Verdoolaege committed May 1, 2015
1 parent 10fa52f commit 8e21cf3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
5 changes: 4 additions & 1 deletion basis_reduction_tab.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,11 @@ static int solve_lp(struct tab_lp *lp)
isl_vec_free(sample);
}
isl_int_divexact_ui(lp->opt_denom, lp->opt_denom, 2);
if (res != isl_lp_ok)
if (res < 0)
return -1;
if (res != isl_lp_ok)
isl_die(lp->ctx, isl_error_internal,
"unexpected missing (bounded) solution", return -1);
return 0;
}

Expand Down
17 changes: 8 additions & 9 deletions basis_reduction_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ struct isl_tab *isl_tab_compute_reduced_basis(struct isl_tab *tab)
unsigned dim;
struct isl_ctx *ctx;
struct isl_mat *B;
int unbounded;
int i;
GBR_LP *lp = NULL;
GBR_type F_old, alpha, F_new;
Expand Down Expand Up @@ -133,8 +132,8 @@ struct isl_tab *isl_tab_compute_reduced_basis(struct isl_tab *tab)

GBR_lp_set_obj(lp, B->row[1+i]+1, dim);
ctx->stats->gbr_solved_lps++;
unbounded = GBR_lp_solve(lp);
isl_assert(ctx, !unbounded, goto error);
if (GBR_lp_solve(lp) < 0)
goto error;
GBR_lp_get_obj_val(lp, &F[i]);

if (GBR_lt(F[i], one)) {
Expand All @@ -151,8 +150,8 @@ struct isl_tab *isl_tab_compute_reduced_basis(struct isl_tab *tab)
if (i+1 == tab->n_zero) {
GBR_lp_set_obj(lp, B->row[1+i+1]+1, dim);
ctx->stats->gbr_solved_lps++;
unbounded = GBR_lp_solve(lp);
isl_assert(ctx, !unbounded, goto error);
if (GBR_lp_solve(lp) < 0)
goto error;
GBR_lp_get_obj_val(lp, &F_new);
fixed = GBR_lp_is_fixed(lp);
GBR_set_ui(alpha, 0);
Expand All @@ -166,8 +165,8 @@ struct isl_tab *isl_tab_compute_reduced_basis(struct isl_tab *tab)
row = GBR_lp_add_row(lp, B->row[1+i]+1, dim);
GBR_lp_set_obj(lp, B->row[1+i+1]+1, dim);
ctx->stats->gbr_solved_lps++;
unbounded = GBR_lp_solve(lp);
isl_assert(ctx, !unbounded, goto error);
if (GBR_lp_solve(lp) < 0)
goto error;
GBR_lp_get_obj_val(lp, &F_new);
fixed = GBR_lp_is_fixed(lp);

Expand Down Expand Up @@ -196,8 +195,8 @@ struct isl_tab *isl_tab_compute_reduced_basis(struct isl_tab *tab)
tmp, B->row[1+i]+1, dim);
GBR_lp_set_obj(lp, b_tmp->el, dim);
ctx->stats->gbr_solved_lps++;
unbounded = GBR_lp_solve(lp);
isl_assert(ctx, !unbounded, goto error);
if (GBR_lp_solve(lp) < 0)
goto error;
GBR_lp_get_obj_val(lp, &mu_F[j]);
mu_fixed[j] = GBR_lp_is_fixed(lp);
if (i > 0)
Expand Down

0 comments on commit 8e21cf3

Please sign in to comment.