7 /* The input of this program is the same as that of the "polytope_minimize"
8 * program from the barvinok distribution.
10 * Constraints of set is PolyLib format.
11 * Linear or affine objective function in PolyLib format.
14 static struct isl_vec *isl_vec_lin_to_aff(struct isl_vec *vec)
20 aff = isl_vec_alloc(vec->ctx, 1 + vec->size);
23 isl_int_set_si(aff->el[0], 0);
24 isl_seq_cpy(aff->el + 1, vec->el, vec->size);
32 /* Rotate elements of vector right.
33 * In particular, move the constant term from the end of the
34 * vector to the start of the vector.
36 static struct isl_vec *vec_ror(struct isl_vec *vec)
42 for (i = vec->size - 2; i >= 0; --i)
43 isl_int_swap(vec->el[i], vec->el[i + 1]);
47 int main(int argc, char **argv)
49 struct isl_ctx *ctx = isl_ctx_alloc();
50 struct isl_basic_set *bset;
55 enum isl_lp_result res;
58 bset = isl_basic_set_read_from_file(ctx, stdin, 0, ISL_FORMAT_POLYLIB);
60 obj = isl_vec_read_from_file(ctx, stdin, ISL_FORMAT_POLYLIB);
62 dim = isl_basic_set_total_dim(bset);
63 assert(obj->size >= dim && obj->size <= dim + 1);
64 if (obj->size != dim + 1)
65 obj = isl_vec_lin_to_aff(obj);
68 res = isl_basic_set_solve_ilp(bset, 0, obj->el, &opt, &sol);
69 assert(res != isl_lp_error);
72 fprintf(stdout, "empty\n");
74 case isl_lp_unbounded:
75 fprintf(stdout, "unbounded\n");
78 isl_vec_dump(sol, stdout, 0);
79 isl_int_print(stdout, opt, 0);
80 fprintf(stdout, "\n");
82 isl_basic_set_free(bset);