declare flexarrays of size 1 to silence sun compiler
[isl.git] / pip.c
blob94e7af916ad8fe4c6d9e1b637be74e069fd6e53e
1 #include <assert.h>
2 #include <string.h>
3 #include "isl_set.h"
4 #include "isl_tab.h"
5 #include "isl_map_private.h"
7 /* The input of this program is the same as that of the "example" program
8 * from the PipLib distribution, except that the "big parameter column"
9 * should always be -1.
11 * Context constraints in PolyLib format
12 * -1
13 * Problem constraints in PolyLib format
14 * Optional list of options
16 * The options are
17 * Maximize compute maximum instead of minimum
18 * Rational compute rational optimum instead of integer optimum
19 * Urs_parms don't assume parameters are non-negative
20 * Urs_unknowns don't assume unknowns are non-negative
23 static struct isl_basic_set *to_parameter_domain(struct isl_basic_set *context)
25 struct isl_dim *param_dim;
26 struct isl_basic_set *model;
28 param_dim = isl_dim_set_alloc(context->ctx,
29 isl_basic_set_n_dim(context), 0);
30 model = isl_basic_set_empty(param_dim);
31 context = isl_basic_set_from_underlying_set(context, model);
33 return context;
36 int main(int argc, char **argv)
38 struct isl_ctx *ctx = isl_ctx_alloc();
39 struct isl_basic_set *context, *bset;
40 struct isl_set *set;
41 struct isl_set *empty;
42 int neg_one;
43 char s[1024];
44 int urs_parms = 0;
45 int urs_unknowns = 0;
46 int max = 0;
48 context = isl_basic_set_read_from_file(ctx, stdin, 0, ISL_FORMAT_POLYLIB);
49 assert(context);
50 fscanf(stdin, "%d", &neg_one);
51 assert(neg_one == -1);
52 bset = isl_basic_set_read_from_file(ctx, stdin,
53 isl_basic_set_dim(context, isl_dim_set), ISL_FORMAT_POLYLIB);
55 while (fgets(s, sizeof(s), stdin)) {
56 if (strncasecmp(s, "Maximize", 8) == 0)
57 max = 1;
58 if (strncasecmp(s, "Rational", 8) == 0)
59 bset = isl_basic_set_set_rational(bset);
60 if (strncasecmp(s, "Urs_parms", 9) == 0)
61 urs_parms = 1;
62 if (strncasecmp(s, "Urs_unknowns", 12) == 0)
63 urs_unknowns = 1;
65 if (!urs_parms)
66 context = isl_basic_set_intersect(context,
67 isl_basic_set_positive_orthant(isl_basic_set_get_dim(context)));
68 context = to_parameter_domain(context);
69 if (!urs_unknowns)
70 bset = isl_basic_set_intersect(bset,
71 isl_basic_set_positive_orthant(isl_basic_set_get_dim(bset)));
73 if (max)
74 set = isl_basic_set_partial_lexmax(bset, context, &empty);
75 else
76 set = isl_basic_set_partial_lexmin(bset, context, &empty);
78 isl_set_dump(set, stdout, 0);
79 fprintf(stdout, "no solution:\n");
80 isl_set_dump(empty, stdout, 4);
82 isl_set_free(set);
83 isl_set_free(empty);
84 isl_ctx_free(ctx);
86 return 0;