11 unsigned is_nonneg : 1;
13 unsigned is_redundant : 1;
18 enum isl_tab_undo_type {
22 isl_tab_undo_redundant,
24 isl_tab_undo_allocate,
26 isl_tab_undo_saved_basis,
29 union isl_tab_undo_val {
35 enum isl_tab_undo_type type;
36 union isl_tab_undo_val u;
37 struct isl_tab_undo *next;
40 /* The tableau maintains equality relations.
41 * Each column and each row is associated to a variable or a constraint.
42 * The "value" of an inequality constraint is the value of the corresponding
44 * The "row_var" and "col_var" arrays map column and row indices
45 * to indices in the "var" and "con" arrays. The elements of these
46 * arrays maintain extra information about the variables and the constraints.
47 * Each row expresses the corresponding row variable as an affine expression
48 * of the column variables.
49 * The first two columns in the matrix contain the common denominator of
50 * the row and the numerator of the constant term. The third column
51 * in the matrix is called column 0 with respect to the col_var array.
52 * The sample value of the tableau is the value that assigns zero
53 * to all the column variables and the constant term of each affine
54 * expression to the corresponding row variable.
55 * The operations on the tableau maintain the property that the sample
56 * value satisfies the non-negativity constraints (usually on the slack
59 * The first n_dead column variables have their values fixed to zero.
60 * The corresponding tab_vars are flagged "is_zero".
61 * Some of the rows that have have zero coefficients in all but
62 * the dead columns are also flagged "is_zero".
64 * The first n_redundant rows correspond to inequality constraints
65 * that are always satisfied for any value satisfying the non-redundant
66 * rows. The corresponding tab_vars are flagged "is_redundant".
67 * A row variable that is flagged "is_zero" is also flagged "is_redundant"
68 * since the constraint has been reduced to 0 = 0 and is therefore always
71 * Dead columns and redundant rows are detected on the fly.
72 * However, the basic operations do not ensure that all dead columns
73 * or all redundant rows are detected.
74 * isl_tab_detect_equalities and isl_tab_detect_redundant can be used
75 * to peform and exhaustive search for dead columns and redundant rows.
89 struct isl_tab_var *var;
90 struct isl_tab_var *con;
91 int *row_var; /* v >= 0 -> var v; v < 0 -> con ~v */
92 int *col_var; /* v >= 0 -> var v; v < 0 -> con ~v */
94 struct isl_tab_undo bottom;
95 struct isl_tab_undo *top;
99 unsigned need_undo : 1;
100 unsigned rational : 1;
102 unsigned in_undo : 1;
105 struct isl_tab *isl_tab_alloc(struct isl_ctx *ctx,
106 unsigned n_row, unsigned n_var);
107 void isl_tab_free(struct isl_tab *tab);
109 struct isl_tab *isl_tab_from_basic_map(struct isl_basic_map *bmap);
110 struct isl_tab *isl_tab_from_basic_set(struct isl_basic_set *bset);
111 struct isl_tab *isl_tab_from_recession_cone(struct isl_basic_map *bmap);
112 int isl_tab_cone_is_bounded(struct isl_tab *tab);
113 struct isl_basic_map *isl_basic_map_update_from_tab(struct isl_basic_map *bmap,
114 struct isl_tab *tab);
115 struct isl_basic_set *isl_basic_set_update_from_tab(struct isl_basic_set *bset,
116 struct isl_tab *tab);
117 struct isl_tab *isl_tab_detect_equalities(struct isl_tab *tab);
118 struct isl_tab *isl_tab_detect_redundant(struct isl_tab *tab);
119 #define ISL_TAB_SAVE_DUAL (1 << 0)
120 enum isl_lp_result isl_tab_min(struct isl_tab *tab,
121 isl_int *f, isl_int denom, isl_int *opt, isl_int *opt_denom,
124 struct isl_tab *isl_tab_extend(struct isl_tab *tab, unsigned n_new);
125 struct isl_tab *isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq);
126 struct isl_tab *isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq);
128 int isl_tab_is_equality(struct isl_tab *tab, int con);
129 int isl_tab_is_redundant(struct isl_tab *tab, int con);
131 int isl_tab_sample_is_integer(struct isl_tab *tab);
132 struct isl_vec *isl_tab_get_sample_value(struct isl_tab *tab);
143 enum isl_ineq_type isl_tab_ineq_type(struct isl_tab *tab, isl_int *ineq);
145 struct isl_tab_undo *isl_tab_snap(struct isl_tab *tab);
146 int isl_tab_rollback(struct isl_tab *tab, struct isl_tab_undo *snap);
148 struct isl_tab *isl_tab_relax(struct isl_tab *tab, int con);
149 struct isl_tab *isl_tab_select_facet(struct isl_tab *tab, int con);
151 void isl_tab_dump(struct isl_tab *tab, FILE *out, int indent);
155 struct isl_tab_var *isl_tab_var_from_row(struct isl_tab *tab, int i);
156 int isl_tab_mark_redundant(struct isl_tab *tab, int row);
157 struct isl_tab *isl_tab_mark_empty(struct isl_tab *tab);
158 struct isl_tab *isl_tab_dup(struct isl_tab *tab);
159 int isl_tab_extend_cons(struct isl_tab *tab, unsigned n_new);
160 int isl_tab_allocate_con(struct isl_tab *tab);
161 void isl_tab_pivot(struct isl_tab *tab, int row, int col);
162 int isl_tab_add_row(struct isl_tab *tab, isl_int *line);
163 int isl_tab_row_is_redundant(struct isl_tab *tab, int row);
164 int isl_tab_min_at_most_neg_one(struct isl_tab *tab, struct isl_tab_var *var);
166 void isl_tab_push(struct isl_tab *tab, enum isl_tab_undo_type type);
167 void isl_tab_push_var(struct isl_tab *tab,
168 enum isl_tab_undo_type type, struct isl_tab_var *var);
169 void isl_tab_push_basis(struct isl_tab *tab);