iscc: parse lists
[barvinok.git] / polysign.c
blob6b3afc32c061b7de6021a1f0e266f8c77eae379a
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 if (options->lp_solver == BV_LP_ISL)
67 return isl_polyhedron_affine_sign(D, T, options);
68 else
69 assert(0);
73 * Optimize (minimize or maximize depending on dir) the affine
74 * objective function obj (of length dimension+1), with denominator
75 * denom over the polyhedron specified by the constraints C.
76 * The result is returned in opt.
78 enum lp_result constraints_opt(Matrix *C, Value *obj, Value denom,
79 enum lp_dir dir, Value *opt,
80 struct barvinok_options *options)
82 if (options->lp_solver == BV_LP_POLYLIB)
83 return PL_constraints_opt(C, obj, denom, dir, opt, options->MaxRays);
84 else if (options->lp_solver == BV_LP_GLPK)
85 return glpk_constraints_opt(C, obj, denom, dir, opt);
86 else if (options->lp_solver == BV_LP_CDD)
87 return cdd_constraints_opt(C, obj, denom, dir, opt);
88 else if (options->lp_solver == BV_LP_CDDF)
89 return cddf_constraints_opt(C, obj, denom, dir, opt);
90 else if (options->lp_solver == BV_LP_PIP)
91 return pip_constraints_opt(C, obj, denom, dir, opt);
92 else if (options->lp_solver == BV_LP_ISL)
93 return isl_constraints_opt(C, obj, denom, dir, opt);
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 P.
102 * The result is returned in opt.
104 enum lp_result polyhedron_opt(Polyhedron *P, 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_polyhedron_opt(P, obj, denom, dir, opt);
110 else {
111 Matrix M;
112 Polyhedron_Matrix_View(P, &M, P->NbConstraints);
113 return constraints_opt(&M, obj, denom, dir, opt, options);