isl_tab.h

Go to the documentation of this file.
00001 #ifndef ISL_TAB_H
00002 #define ISL_TAB_H
00003 
00004 #include "isl_lp.h"
00005 #include "isl_map.h"
00006 #include "isl_mat.h"
00007 
00008 struct isl_tab_var {
00009         int index;
00010         unsigned is_row : 1;
00011         unsigned is_nonneg : 1;
00012         unsigned is_zero : 1;
00013         unsigned is_redundant : 1;
00014         unsigned marked : 1;
00015         unsigned frozen : 1;
00016 };
00017 
00018 enum isl_tab_undo_type {
00019         isl_tab_undo_bottom,
00020         isl_tab_undo_empty,
00021         isl_tab_undo_nonneg,
00022         isl_tab_undo_redundant,
00023         isl_tab_undo_zero,
00024         isl_tab_undo_allocate,
00025         isl_tab_undo_relax,
00026 };
00027 
00028 struct isl_tab_undo {
00029         enum isl_tab_undo_type  type;
00030         struct isl_tab_var      *var;
00031         struct isl_tab_undo     *next;
00032 };
00033 
00034 /* The tableau maintains equality relations.
00035  * Each column and each row is associated to a variable or a constraint.
00036  * The "value" of an inequality constraint is the value of the corresponding
00037  * slack variable.
00038  * The "row_var" and "col_var" arrays map column and row indices
00039  * to indices in the "var" and "con" arrays.  The elements of these
00040  * arrays maintain extra information about the variables and the constraints.
00041  * Each row expresses the corresponding row variable as an affine expression
00042  * of the column variables.
00043  * The first two columns in the matrix contain the common denominator of
00044  * the row and the numerator of the constant term.  The third column
00045  * in the matrix is called column 0 with respect to the col_var array.
00046  * The sample value of the tableau is the value that assigns zero
00047  * to all the column variables and the constant term of each affine
00048  * expression to the corresponding row variable.
00049  * The operations on the tableau maintain the property that the sample
00050  * value satisfies the non-negativity constraints (usually on the slack
00051  * variables).
00052  *
00053  * The first n_dead column variables have their values fixed to zero.
00054  * The corresponding tab_vars are flagged "is_zero".
00055  * Some of the rows that have have zero coefficients in all but
00056  * the dead columns are also flagged "is_zero".
00057  *
00058  * The first n_redundant rows correspond to inequality constraints
00059  * that are always satisfied for any value satisfying the non-redundant
00060  * rows.  The corresponding tab_vars are flagged "is_redundant".
00061  * A row variable that is flagged "is_zero" is also flagged "is_redundant"
00062  * since the constraint has been reduced to 0 = 0 and is therefore always
00063  * satisfied.
00064  *
00065  * Dead columns and redundant rows are detected on the fly.
00066  * However, the basic operations do not ensure that all dead columns
00067  * or all redundant rows are detected.
00068  * isl_tab_detect_equalities and isl_tab_detect_redundant can be used
00069  * to peform and exhaustive search for dead columns and redundant rows.
00070  */
00071 struct isl_tab {
00072         struct isl_mat *mat;
00073 
00074         unsigned n_row;
00075         unsigned n_col;
00076         unsigned n_dead;
00077         unsigned n_redundant;
00078 
00079         unsigned n_var;
00080         unsigned n_con;
00081         unsigned n_eq;
00082         unsigned max_con;
00083         struct isl_tab_var *var;
00084         struct isl_tab_var *con;
00085         int *row_var;   /* v >= 0 -> var v;     v < 0 -> con ~v */
00086         int *col_var;   /* v >= 0 -> var v;     v < 0 -> con ~v */
00087 
00088         struct isl_tab_undo bottom;
00089         struct isl_tab_undo *top;
00090 
00091         unsigned need_undo : 1;
00092         unsigned rational : 1;
00093         unsigned empty : 1;
00094 };
00095 
00096 void isl_tab_free(struct isl_ctx *ctx, struct isl_tab *tab);
00097 
00098 struct isl_tab *isl_tab_from_basic_map(struct isl_basic_map *bmap);
00099 struct isl_tab *isl_tab_from_basic_set(struct isl_basic_set *bset);
00100 struct isl_tab *isl_tab_from_recession_cone(struct isl_basic_map *bmap);
00101 int isl_tab_cone_is_bounded(struct isl_ctx *ctx, struct isl_tab *tab);
00102 struct isl_basic_map *isl_basic_map_update_from_tab(struct isl_basic_map *bmap,
00103         struct isl_tab *tab);
00104 struct isl_basic_set *isl_basic_set_update_from_tab(struct isl_basic_set *bset,
00105         struct isl_tab *tab);
00106 struct isl_tab *isl_tab_detect_equalities(struct isl_ctx *ctx,
00107                                 struct isl_tab *tab);
00108 struct isl_tab *isl_tab_detect_redundant(struct isl_ctx *ctx,
00109                                 struct isl_tab *tab);
00110 enum isl_lp_result isl_tab_min(struct isl_ctx *ctx, struct isl_tab *tab,
00111         isl_int *f, isl_int denom, isl_int *opt, isl_int *opt_denom);
00112 
00113 struct isl_tab *isl_tab_extend(struct isl_ctx *ctx, struct isl_tab *tab,
00114                                 unsigned n_new);
00115 struct isl_tab *isl_tab_add_ineq(struct isl_ctx *ctx,
00116         struct isl_tab *tab, isl_int *ineq);
00117 
00118 int isl_tab_is_equality(struct isl_ctx *ctx, struct isl_tab *tab, int con);
00119 int isl_tab_is_redundant(struct isl_ctx *ctx, struct isl_tab *tab, int con);
00120 
00121 struct isl_vec *isl_tab_get_sample_value(struct isl_ctx *ctx,
00122                                                 struct isl_tab *tab);
00123 
00124 enum isl_ineq_type {
00125         isl_ineq_error = -1,
00126         isl_ineq_redundant,
00127         isl_ineq_separate,
00128         isl_ineq_cut,
00129         isl_ineq_adj_eq,
00130         isl_ineq_adj_ineq,
00131 };
00132 
00133 enum isl_ineq_type isl_tab_ineq_type(struct isl_ctx *ctx, struct isl_tab *tab,
00134         isl_int *ineq);
00135 
00136 struct isl_tab_undo *isl_tab_snap(struct isl_ctx *ctx, struct isl_tab *tab);
00137 int isl_tab_rollback(struct isl_ctx *ctx, struct isl_tab *tab,
00138         struct isl_tab_undo *snap);
00139 
00140 struct isl_tab *isl_tab_relax(struct isl_ctx *ctx,
00141         struct isl_tab *tab, int con);
00142 struct isl_tab *isl_tab_select_facet(struct isl_ctx *ctx,
00143         struct isl_tab *tab, int con);
00144 
00145 void isl_tab_dump(struct isl_ctx *ctx, struct isl_tab *tab,
00146                                 FILE *out, int indent);
00147 
00148 #endif

Generated on Fri Jul 17 16:32:57 2009 for CLooG / ISL by  doxygen 1.5.9