move omega subdir to omega_interface
[barvinok/uuh.git] / polytope_minimize.c
blob93362859a95837741c4b2da8cf145cc677928f98
1 #include <assert.h>
2 #include <barvinok/options.h>
3 #include <barvinok/util.h>
4 #include "argp.h"
5 #include "progname.h"
6 #include "ilp.h"
7 #include "polysign.h"
9 int main(int argc, char **argv)
11 struct barvinok_options *options = barvinok_options_new_with_defaults();
12 Polyhedron *P;
13 Vector *obj, *affine;
14 Vector *minmax;
15 Vector *opt;
16 enum lp_result res;
17 Value one;
19 set_program_name(argv[0]);
20 argp_parse(&barvinok_argp, argc, argv, 0, 0, options);
22 P = Polyhedron_Read(options->MaxRays);
23 obj = Vector_Read();
24 minmax = Vector_Alloc(2);
26 if (obj->Size == P->Dimension) {
27 affine = Vector_Alloc(P->Dimension+1);
28 Vector_Copy(obj->p, affine->p, P->Dimension);
29 value_set_si(affine->p[P->Dimension], 1);
30 } else if (obj->Size == P->Dimension+1)
31 affine = obj;
32 else
33 assert(0);
35 value_init(one);
36 value_set_si(one, 1);
37 res = polyhedron_range(P, affine->p, one, &minmax->p[0], &minmax->p[1],
38 options);
39 assert(res == lp_ok);
40 value_clear(one);
42 opt = Polyhedron_Integer_Minimum(P, obj->p, minmax->p[0], minmax->p[1],
43 NULL, NULL, options);
44 Vector_Print(stdout, P_VALUE_FMT, opt);
45 Vector_Free(opt);
47 if (obj != affine)
48 Vector_Free(affine);
49 Vector_Free(obj);
50 Vector_Free(minmax);
51 Polyhedron_Free(P);
53 barvinok_options_free(options);