isl_pw_qpolynomial_sum: handle existentials in wrapped domains
[barvinok.git] / polysign.c
blob04fe5f0c30fa1626578ade071df76f95aaea66b0
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 #ifndef HAVE_PIPLIB
69 enum lp_result pip_constraints_opt(Matrix *C, Value *obj, Value denom,
70 enum lp_dir dir, Value *opt)
72 assert(0);
75 enum lp_result pip_polyhedron_range(Polyhedron *D, Value *obj, Value denom,
76 Value *min, Value *max,
77 struct barvinok_options *options)
79 assert(0);
81 #endif
83 enum order_sign polyhedron_affine_sign(Polyhedron *D, Matrix *T,
84 struct barvinok_options *options)
86 if (options->lp_solver == BV_LP_POLYLIB)
87 return PL_polyhedron_affine_sign(D, T, options);
88 else if (options->lp_solver == BV_LP_GLPK)
89 return glpk_polyhedron_affine_sign(D, T, options);
90 else if (options->lp_solver == BV_LP_CDD)
91 return cdd_polyhedron_affine_sign(D, T, options);
92 else if (options->lp_solver == BV_LP_CDDF)
93 return cddf_polyhedron_affine_sign(D, T, options);
94 else
95 assert(0);
99 * Optimize (minimize or maximize depending on dir) the affine
100 * objective function obj (of length dimension+1), with denominator
101 * denom over the polyhedron specified by the constraints C.
102 * The result is returned in opt.
104 enum lp_result constraints_opt(Matrix *C, Value *obj, Value denom,
105 enum lp_dir dir, Value *opt,
106 struct barvinok_options *options)
108 if (options->lp_solver == BV_LP_POLYLIB)
109 return PL_constraints_opt(C, obj, denom, dir, opt, options->MaxRays);
110 else if (options->lp_solver == BV_LP_GLPK)
111 return glpk_constraints_opt(C, obj, denom, dir, opt);
112 else if (options->lp_solver == BV_LP_CDD)
113 return cdd_constraints_opt(C, obj, denom, dir, opt);
114 else if (options->lp_solver == BV_LP_CDDF)
115 return cddf_constraints_opt(C, obj, denom, dir, opt);
116 else if (options->lp_solver == BV_LP_PIP)
117 return pip_constraints_opt(C, obj, denom, dir, opt);
118 else
119 assert(0);
123 * Optimize (minimize or maximize depending on dir) the affine
124 * objective function obj (of length dimension+1), with denominator
125 * denom over the polyhedron specified by P.
126 * The result is returned in opt.
128 enum lp_result polyhedron_opt(Polyhedron *P, Value *obj, Value denom,
129 enum lp_dir dir, Value *opt,
130 struct barvinok_options *options)
132 if (options->lp_solver == BV_LP_POLYLIB)
133 return PL_polyhedron_opt(P, obj, denom, dir, opt);
134 else {
135 Matrix M;
136 Polyhedron_Matrix_View(P, &M, P->NbConstraints);
137 return constraints_opt(&M, obj, denom, dir, opt, options);
141 enum lp_result polyhedron_range(Polyhedron *D, Value *obj, Value denom,
142 Value *min, Value *max,
143 struct barvinok_options *options)
145 if (options->lp_solver == BV_LP_POLYLIB)
146 return PL_polyhedron_range(D, obj, denom, min, max, options);
147 else if (options->lp_solver == BV_LP_GLPK)
148 return glpk_polyhedron_range(D, obj, denom, min, max, options);
149 else if (options->lp_solver == BV_LP_CDD)
150 return cdd_polyhedron_range(D, obj, denom, min, max, options);
151 else if (options->lp_solver == BV_LP_CDDF)
152 return cddf_polyhedron_range(D, obj, denom, min, max, options);
153 else if (options->lp_solver == BV_LP_PIP)
154 return pip_polyhedron_range(D, obj, denom, min, max, options);
155 else
156 assert(0);