enum isl_lp_result isl_basic_set_max(
__isl_keep isl_basic_set *bset,
__isl_keep isl_aff *obj, isl_int *opt)
+ __isl_give isl_val *isl_basic_set_max_val(
+ __isl_keep isl_basic_set *bset,
+ __isl_keep isl_aff *obj);
enum isl_lp_result isl_set_min(__isl_keep isl_set *set,
__isl_keep isl_aff *obj, isl_int *opt);
enum isl_lp_result isl_set_max(__isl_keep isl_set *set,
Compute the minimum or maximum of the integer affine expression C<obj>
over the points in C<set>, returning the result in C<opt>.
The return value may be one of C<isl_lp_error>,
-C<isl_lp_ok>, C<isl_lp_unbounded> or C<isl_lp_empty>.
+C<isl_lp_ok>, C<isl_lp_unbounded> or C<isl_lp_empty>, in case of
+an C<isl_lp_result>. If the result is an C<isl_val> then
+the result is C<NULL> in case of an error, the optimal value in case
+there is one, infinity if the problem is unbounded and
+NaN if the problem is empty.
=item * Parametric optimization
#include <isl/aff_type.h>
#include <isl/lp.h>
+#include <isl/val.h>
#if defined(__cplusplus)
extern "C" {
struct isl_vec **sol_p);
enum isl_lp_result isl_basic_set_max(__isl_keep isl_basic_set *bset,
__isl_keep isl_aff *obj, isl_int *opt);
+__isl_give isl_val *isl_basic_set_max_val(__isl_keep isl_basic_set *bset,
+ __isl_keep isl_aff *obj);
enum isl_lp_result isl_set_min(__isl_keep isl_set *set,
__isl_keep isl_aff *obj, isl_int *opt);
enum isl_lp_result isl_set_max(__isl_keep isl_set *set,
#include <isl_aff_private.h>
#include <isl_local_space_private.h>
#include <isl_mat_private.h>
+#include <isl_val_private.h>
/* Given a basic set "bset", construct a basic set U such that for
* each element x in U, the whole unit box positioned at x is inside
{
return isl_set_opt(set, 0, obj, opt);
}
+
+/* Convert the result of a function that returns an isl_lp_result
+ * to an isl_val. The numerator of "v" is set to the optimal value
+ * if lp_res is isl_lp_ok. "max" is set if a maximum was computed.
+ *
+ * Return "v" with denominator set to 1 if lp_res is isl_lp_ok.
+ * Return NULL on error.
+ * Return a NaN if lp_res is isl_lp_empty.
+ * Return infinity or negative infinity if lp_res is isl_lp_unbounded,
+ * depending on "max".
+ */
+static __isl_give isl_val *convert_lp_result(enum isl_lp_result lp_res,
+ __isl_take isl_val *v, int max)
+{
+ isl_ctx *ctx;
+
+ if (lp_res == isl_lp_ok) {
+ isl_int_set_si(v->d, 1);
+ return isl_val_normalize(v);
+ }
+ ctx = isl_val_get_ctx(v);
+ isl_val_free(v);
+ if (lp_res == isl_lp_error)
+ return NULL;
+ if (lp_res == isl_lp_empty)
+ return isl_val_nan(ctx);
+ if (max)
+ return isl_val_infty(ctx);
+ else
+ return isl_val_neginfty(ctx);
+}
+
+/* Return the minimum (maximum if max is set) of the integer affine
+ * expression "obj" over the points in "bset".
+ *
+ * Return infinity or negative infinity if the optimal value is unbounded and
+ * NaN if "bset" is empty.
+ *
+ * Call isl_basic_set_opt and translate the results.
+ */
+__isl_give isl_val *isl_basic_set_opt_val(__isl_keep isl_basic_set *bset,
+ int max, __isl_keep isl_aff *obj)
+{
+ isl_ctx *ctx;
+ isl_val *res;
+ enum isl_lp_result lp_res;
+
+ if (!bset || !obj)
+ return NULL;
+
+ ctx = isl_aff_get_ctx(obj);
+ res = isl_val_alloc(ctx);
+ if (!res)
+ return NULL;
+ lp_res = isl_basic_set_opt(bset, max, obj, &res->n);
+ return convert_lp_result(lp_res, res, max);
+}
+
+/* Return the maximum of the integer affine
+ * expression "obj" over the points in "bset".
+ *
+ * Return infinity or negative infinity if the optimal value is unbounded and
+ * NaN if "bset" is empty.
+ */
+__isl_give isl_val *isl_basic_set_max_val(__isl_keep isl_basic_set *bset,
+ __isl_keep isl_aff *obj)
+{
+ return isl_basic_set_opt_val(bset, 1, obj);
+}