iscc: add affine hull operation
[barvinok/uuh.git] / polysign.c
blobc4e97b5f49287deeb87d787a3c74118b4da3424a
1 #include <assert.h>
2 #include <barvinok/options.h>
3 #include <barvinok/util.h>
4 #include "polysign.h"
5 #include "config.h"
7 #ifndef HAVE_LIBGLPK
8 enum order_sign glpk_polyhedron_affine_sign(Polyhedron *D, Matrix *T,
9 struct barvinok_options *options)
11 assert(0);
14 enum lp_result glpk_constraints_opt(Matrix *C, Value *obj, Value denom,
15 enum lp_dir dir, Value *opt)
17 assert(0);
20 enum lp_result glpk_polyhedron_range(Polyhedron *D, Value *obj, Value denom,
21 Value *min, Value *max,
22 struct barvinok_options *options)
24 assert(0);
26 #endif
28 #ifndef HAVE_LIBCDDGMP
29 enum order_sign cdd_polyhedron_affine_sign(Polyhedron *D, Matrix *T,
30 struct barvinok_options *options)
32 assert(0);
35 enum order_sign cddf_polyhedron_affine_sign(Polyhedron *D, Matrix *T,
36 struct barvinok_options *options)
38 assert(0);
41 enum lp_result cdd_constraints_opt(Matrix *C, Value *obj, Value denom,
42 enum lp_dir dir, Value *opt)
44 assert(0);
47 enum lp_result cddf_constraints_opt(Matrix *C, Value *obj, Value denom,
48 enum lp_dir dir, Value *opt)
50 assert(0);
53 enum lp_result cdd_polyhedron_range(Polyhedron *D, Value *obj, Value denom,
54 Value *min, Value *max,
55 struct barvinok_options *options)
57 assert(0);
60 enum lp_result cddf_polyhedron_range(Polyhedron *D, Value *obj, Value denom,
61 Value *min, Value *max,
62 struct barvinok_options *options)
64 assert(0);
66 #endif
68 enum order_sign polyhedron_affine_sign(Polyhedron *D, Matrix *T,
69 struct barvinok_options *options)
71 if (options->lp_solver == BV_LP_POLYLIB)
72 return PL_polyhedron_affine_sign(D, T, options);
73 else if (options->lp_solver == BV_LP_GLPK)
74 return glpk_polyhedron_affine_sign(D, T, options);
75 else if (options->lp_solver == BV_LP_CDD)
76 return cdd_polyhedron_affine_sign(D, T, options);
77 else if (options->lp_solver == BV_LP_CDDF)
78 return cddf_polyhedron_affine_sign(D, T, options);
79 else
80 assert(0);
84 * Optimize (minimize or maximize depending on dir) the affine
85 * objective function obj (of length dimension+1), with denominator
86 * denom over the polyhedron specified by the constraints C.
87 * The result is returned in opt.
89 enum lp_result constraints_opt(Matrix *C, Value *obj, Value denom,
90 enum lp_dir dir, Value *opt,
91 struct barvinok_options *options)
93 if (options->lp_solver == BV_LP_POLYLIB)
94 return PL_constraints_opt(C, obj, denom, dir, opt, options->MaxRays);
95 else if (options->lp_solver == BV_LP_GLPK)
96 return glpk_constraints_opt(C, obj, denom, dir, opt);
97 else if (options->lp_solver == BV_LP_CDD)
98 return cdd_constraints_opt(C, obj, denom, dir, opt);
99 else if (options->lp_solver == BV_LP_CDDF)
100 return cddf_constraints_opt(C, obj, denom, dir, opt);
101 else if (options->lp_solver == BV_LP_PIP)
102 return pip_constraints_opt(C, obj, denom, dir, opt);
103 else
104 assert(0);
108 * Optimize (minimize or maximize depending on dir) the affine
109 * objective function obj (of length dimension+1), with denominator
110 * denom over the polyhedron specified by P.
111 * The result is returned in opt.
113 enum lp_result polyhedron_opt(Polyhedron *P, Value *obj, Value denom,
114 enum lp_dir dir, Value *opt,
115 struct barvinok_options *options)
117 if (options->lp_solver == BV_LP_POLYLIB)
118 return PL_polyhedron_opt(P, obj, denom, dir, opt);
119 else {
120 Matrix M;
121 Polyhedron_Matrix_View(P, &M, P->NbConstraints);
122 return constraints_opt(&M, obj, denom, dir, opt, options);
126 enum lp_result polyhedron_range(Polyhedron *D, Value *obj, Value denom,
127 Value *min, Value *max,
128 struct barvinok_options *options)
130 if (options->lp_solver == BV_LP_POLYLIB)
131 return PL_polyhedron_range(D, obj, denom, min, max, options);
132 else if (options->lp_solver == BV_LP_GLPK)
133 return glpk_polyhedron_range(D, obj, denom, min, max, options);
134 else if (options->lp_solver == BV_LP_CDD)
135 return cdd_polyhedron_range(D, obj, denom, min, max, options);
136 else if (options->lp_solver == BV_LP_CDDF)
137 return cddf_polyhedron_range(D, obj, denom, min, max, options);
138 else if (options->lp_solver == BV_LP_PIP)
139 return pip_polyhedron_range(D, obj, denom, min, max, options);
140 else
141 assert(0);