iscc: add operations on int objects
[barvinok.git] / polysign.c
blobee7783c031afad30ab498d8a6ec6c63b46667a11
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);
19 #endif
21 #ifndef HAVE_LIBCDDGMP
22 enum order_sign cdd_polyhedron_affine_sign(Polyhedron *D, Matrix *T,
23 struct barvinok_options *options)
25 assert(0);
28 enum order_sign cddf_polyhedron_affine_sign(Polyhedron *D, Matrix *T,
29 struct barvinok_options *options)
31 assert(0);
34 enum lp_result cdd_constraints_opt(Matrix *C, Value *obj, Value denom,
35 enum lp_dir dir, Value *opt)
37 assert(0);
40 enum lp_result cddf_constraints_opt(Matrix *C, Value *obj, Value denom,
41 enum lp_dir dir, Value *opt)
43 assert(0);
45 #endif
47 #ifndef HAVE_PIPLIB
48 enum lp_result pip_constraints_opt(Matrix *C, Value *obj, Value denom,
49 enum lp_dir dir, Value *opt)
51 assert(0);
53 #endif
55 enum order_sign polyhedron_affine_sign(Polyhedron *D, Matrix *T,
56 struct barvinok_options *options)
58 if (options->lp_solver == BV_LP_POLYLIB)
59 return PL_polyhedron_affine_sign(D, T, options);
60 else if (options->lp_solver == BV_LP_GLPK)
61 return glpk_polyhedron_affine_sign(D, T, options);
62 else if (options->lp_solver == BV_LP_CDD)
63 return cdd_polyhedron_affine_sign(D, T, options);
64 else if (options->lp_solver == BV_LP_CDDF)
65 return cddf_polyhedron_affine_sign(D, T, options);
66 else
67 assert(0);
71 * Optimize (minimize or maximize depending on dir) the affine
72 * objective function obj (of length dimension+1), with denominator
73 * denom over the polyhedron specified by the constraints C.
74 * The result is returned in opt.
76 enum lp_result constraints_opt(Matrix *C, Value *obj, Value denom,
77 enum lp_dir dir, Value *opt,
78 struct barvinok_options *options)
80 if (options->lp_solver == BV_LP_POLYLIB)
81 return PL_constraints_opt(C, obj, denom, dir, opt, options->MaxRays);
82 else if (options->lp_solver == BV_LP_GLPK)
83 return glpk_constraints_opt(C, obj, denom, dir, opt);
84 else if (options->lp_solver == BV_LP_CDD)
85 return cdd_constraints_opt(C, obj, denom, dir, opt);
86 else if (options->lp_solver == BV_LP_CDDF)
87 return cddf_constraints_opt(C, obj, denom, dir, opt);
88 else if (options->lp_solver == BV_LP_PIP)
89 return pip_constraints_opt(C, obj, denom, dir, opt);
90 else
91 assert(0);
95 * Optimize (minimize or maximize depending on dir) the affine
96 * objective function obj (of length dimension+1), with denominator
97 * denom over the polyhedron specified by P.
98 * The result is returned in opt.
100 enum lp_result polyhedron_opt(Polyhedron *P, Value *obj, Value denom,
101 enum lp_dir dir, Value *opt,
102 struct barvinok_options *options)
104 if (options->lp_solver == BV_LP_POLYLIB)
105 return PL_polyhedron_opt(P, obj, denom, dir, opt);
106 else {
107 Matrix M;
108 Polyhedron_Matrix_View(P, &M, P->NbConstraints);
109 return constraints_opt(&M, obj, denom, dir, opt, options);