mt_types.h

Go to the documentation of this file.
00001 /* MTgomory "multi tableau gomory cut" provides an implementation for gomory
00002  * cuts derived from multiple tableau rows in the spirit of the work of
00003  * Andersen et al (IPCO 2007), Cornuejols (es presented in George Nemhauser
00004  * Birthday Conference in Atlanta 2007) and Gomory (presented in the same
00005  * conference).
00006  *
00007  * Copyright (C) 2007 Daniel Espinoza.
00008  * 
00009  * This library is free software; you can redistribute it and/or modify it
00010  * under the terms of the GNU Lesser General Public License as published by the
00011  * Free Software Foundation; either version 2.1 of the License, or (at your
00012  * option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful, but 
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
00016  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
00017  * License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with this library; if not, write to the Free Software Foundation,
00021  * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
00022  * */
00023 /* ========================================================================= */
00024 #ifndef __MT_TYPES_H__
00025 #define __MT_TYPES_H__
00026 #include "cplex.h"
00027 #include "EGlib.h"
00028 /** @file 
00029  * @ingroup MTgomory */
00030 /** @addtogroup MTgomory */
00031 /** @{ */
00032 /* ========================================================================= */
00033 /** @brief formulation description for a problem */
00034 typedef struct
00035 {
00036   int nrows;    /**< @brief number of rows */
00037   int ncols;    /**< @brief number of cols */
00038   int nz;       /**< @brief number of non-zeros */
00039   int rspace;   /**< @brief row space reserved */
00040   int nzspace;  /**< @brief non-zero space reserved */
00041   int cspace;   /**< @brief col space reserved */
00042   char* sense;  /**< @brief sense of rows, size #MTlp_t::rspace */
00043   double*rhs;   /**< @brief rhs of rows, size #MTlp_t::rspace */ 
00044   char*rtype;   /**< @brief array of dize #MTlp_t::rspace */
00045   int*rstat;    /**< @brief array of size #MTlp_t::rspace */
00046   int*matbeg;   /**< @brief matbeg, size #MTlp_t::rspace +1 */
00047   char*ctype;   /**< @brief array of size #MTlp_t::cspace */
00048   int*cstat;    /**< @brief array of size #MTlp_t::cspace */
00049   int*matind;   /**< @brief matind, size #MTlp_t::nzspace */
00050   double*matval;/**< @brief matval, size #MTlp_t::nzspace */
00051   double*ub;    /**< @brief upper bounds, size #MTlp_t::cspace */
00052   double*lb;    /**< @brief lower bounds, size #MTlp_t::cspace */
00053   char** colnames;/**< @brief column names, size #MTlp_t::cspace */
00054   char* ccspace;/**< @brief column char array, size #MTlp_t::ccsz */
00055   int ccsz;     /**< @brief column char array size */
00056   char** rownames;/**< @brief row names, size #MTlp_t::rspace */
00057   char* rcspace;/**< @brief row char array, size #MTlp_t::rcsz */
00058   int rcsz;     /**< @brief row char array size */  
00059 } MTlp_t;
00060 /* ========================================================================= */
00061 /** @brief structure holding a compresed matrix in row form */
00062 typedef struct
00063 {
00064   int nz;         /**< @brief number of non-zeros in the matrix */
00065   int nrows;      /**< @brief number of rows in the matrix */
00066   int ncols;      /**< @brief number of columns in the matrix */
00067   int nzspace;    /**< @brief space reserved for non-zeros */
00068   int rspace;     /**< @brief space reserved for rows */
00069   int cspace;     /**< @brief space reserved for columns */
00070   double*rowval;  /**< @brief where we store the values in the matrix, length nzspace */
00071   int*rowbeg;     /**< @brief where each row begins (length rspace+1, since 
00072                        rowbeg[nrows] store the end of the last row) */ 
00073   int*rowind;     /**< @brief which column is asociated with the asociated
00074                        position, length nzspace */
00075 } MTrowmatrix_t;
00076 /* ========================================================================= */
00077 /** @brief structure to hold a solution to an LP */
00078 typedef struct MTsol_t
00079 {
00080   int cspace;         /**< @brief column space */
00081   int rspace;         /**< @brief row space */
00082   int ncols;          /**< @brief number of columns */
00083   int nrows;          /**< @brief number of rows */
00084   double*x;           /**< @brief X values */
00085   double*slack;       /**< @brief slack values */
00086   double*pseudocost;  /**< @brief pseudocost values */
00087 } MTsol_t;
00088 
00089 /* ========================================================================= */
00090 /** @brief structure holding basic calllback information, used to control
00091  * callback behavior and statistic */
00092 typedef struct MTccbk_info_t
00093 {
00094   size_t node_cnt;    /**< @brief ID of last node visited */
00095   size_t node_cuts;/**< @brief counter of cuts added at the current node */
00096   size_t added_cuts;/**< @brief total added cuts */
00097   double root_val;/**< @brief store the best root value seen */
00098   int root_only;  /**< @brief if non-zero, add cuts at root node only */
00099   int use_cuts;   /**< @brief if non-zero, allow the cut process */ 
00100   size_t max_cuts;    /**< @brief maximum number of cuts to add per node */
00101   int max_cpr;    /**< @brief maximum number of cuts to add in each round of cut generation */
00102   int max_rows;   /**< @brief maximum number of row-tableaus to use */
00103   int cut_style;  /**< @brief how we add cuts, 1 for adding cuts for 1-k 
00104                         tableaus-rows, 0 for adding cuts only for k tableaus-rows */
00105 } MTccbk_info_t;
00106 /* ========================================================================= */
00107 /** @brief information for node solve callback */
00108 typedef struct
00109 {
00110   double xdiff;   /**< @brief accumulated difference between solutions */
00111   size_t loops;   /**< @brief rounds of extra LP optimization performed */
00112   size_t ncalls;  /**< @brief count number of calls to the function */
00113   size_t nzrd;    /**< @brief number of zero reduced costs found */
00114   size_t csz;     /**< @brief size of col-related arrays */
00115   size_t rsz;     /**< @brief size of row-related arrays */
00116   char* rfix;     /**< @brief U for fixed at upper bound, L for fixed at lower
00117                         bound, F for free (not fixed)  */
00118   char* cfix;     /**< @brief U for fixed at upper bound, L for fixed at lower
00119                         bound, F for free (not fixed)  */
00120   double*dj;      /**< @brief space of reduced costs */
00121   double*pi;      /**< @brief space for dual solution */
00122   int*rstat;      /**< @brief used to store current basis */
00123   int*cstat;      /**< @brief used to store current basis */
00124   int*matind;     /**< @brief matind for constraints */
00125   double*matval;  /**< @brief matval for constraints */
00126   double*oobj;    /**< @brief dual LP norms */
00127   double*lb;      /**< @brief LP lower bounds */
00128   double*ub;      /**< @brief LP upper bounds */
00129   double*x0;      /**< @brief Initial LP solution */
00130   double*x1;      /**< @brief final LP solution */
00131   char*sense;     /**< @brief LP inequalities sense */
00132 } MTns_ccbk_t;
00133 /* ========================================================================= */
00134 /** @brief structure to hold a cut */ 
00135 typedef struct
00136 {
00137   double rhs;       /**< @brief rhs of the inequality */
00138   double violation; /**< @brief violation */
00139   double min_abs;   /**< @brief minimum absolute value in the cut */
00140   double max_abs;   /**< @brief maximum absolute value in the cut */
00141   double* cutval;   /**< @brief values of the cut */
00142   int* cutind;      /**< @brief indices of non-zeros */
00143   double score;     /**< @brief internal score of the cut, it is defined as 1/|a|_2, but is computed over the raw cut. */
00144   int nzspace;      /**< @brief space for non-zeros */
00145   int nz;           /**< @brief actual non-zeros */
00146   char sense;       /**< @brief sense of the inequality */
00147   char form;        /**< @brief type of inequality stored 0 for complemented cuts, 1 for uncomplemented cuts */
00148 } MTcut_t;
00149 /* ========================================================================= */
00150 /** @brief basic conector for the cut heap */
00151 typedef struct
00152 {
00153   dbl_EGeHeapCn_t hcn;  /**< @brief heap connector */
00154   EGeList_t lcn;        /**< @brief list connector for free slots */
00155   MTcut_t cut;          /**< @brief compressed cut structure */
00156 } MTcutHeapCn_t;
00157 /* ========================================================================= */
00158 /** @brief types of cut score functions */
00159 typedef enum 
00160 {
00161   MTcsRAW         /**< @brief use raw cut score */,
00162   MTcsVIOL        /**< @brief cut violation */,
00163   MTcsINVLINF     /**< @brief \f$\displaystyle rhs/\|a\|_{\inf} \f$ for 
00164                        \f$ax\geq rhs\f$ inequalities, and as 
00165                        \f$\displaystyle -rhs/\|a\|_{\inf}\f$ for 
00166                        \f$ax\leq rhs\f$ inequalities.*/,
00167   MTcsINVL2       /**< @brief \f$\displaystyle rhs^2/\|a\|_2 \f$ for 
00168                        \f$ax\geq rhs\f$ inequalities, and as 
00169                        \f$\displaystyle -rhs^2/\|a\|_2\f$ for 
00170                        \f$ax\leq rhs\f$ inequalities.*/,
00171   MTcsDefault = MTcsRAW
00172 } MTcutSelection_t;
00173 /* ========================================================================= */
00174 /** @brief configuration strucutre for #MTcutHeap_t */
00175 typedef struct 
00176 {
00177   MTcutSelection_t cut_score; /**< @brief selection type for cuts */
00178   int dominance_check;        /**< @brief if set to one, check for dominated 
00179                                    cuts within the heap */
00180 } MTcutHeapControl_t;
00181 /* ========================================================================= */
00182 /** @brief simple structure (based on heaps) that holds up to certain number of
00183  * cuts, and keep (acording to a criteria) the best ones. */
00184 typedef struct 
00185 {
00186   dbl_EGeHeap_t heap;       /**< @brief where we store the cuts according to a 
00187                                  given score, defined by #MTcutHeap_t::control */
00188   EGeList_t free_cn;        /**< @brief list of free heap connectors */
00189   MTcutHeapCn_t* all_cn;    /**< @brief where we store all heap connectors */
00190   MTcut_t* next_free;       /**< @brief pointer to the next unused cut */
00191   size_t all_sz;            /**< @brief size of MTcutHeap_t::all_cn */
00192   MTcutHeapControl_t control;/**< @brief for controlling the behavior of related
00193                                  functions */
00194 } MTcutHeap_t;
00195 /* ========================================================================= */
00196 /** @brief structure holding the working information for the all callbacks
00197  * function */
00198 typedef struct 
00199 {
00200   int rowsz;      /**< @brief reserved row-space in the structure */
00201   int colsz;      /**< @brief reserved col-space in the structure */
00202   double*work;    /**< @brief array of size #MTgomory_ccbk_t::colsz+1 */
00203   double*extcut;  /**< @brief array of size #MTgomory_ccbk_t::colsz */
00204   double*base;    /**< @brief array of size #MTgomory_ccbk_t::rowsz */
00205   double*f;       /**< @brief array of size #MTgomory_ccbk_t::rowsz */
00206   MTsol_t sol;    /**< @brief current node solution */
00207   MTcut_t cut;    /**< @brief structure to hold a resulting cut */
00208   MTrowmatrix_t tb;/**< @brief store the current tableau (extended format, 
00209                        with logicals included) */
00210   MTlp_t lp;      /**< @brief LP description of the node */
00211   MTccbk_info_t info;/**< @brief Basic callback control */
00212   MTcutHeap_t cuth;/**< @brief structure holding a cut-heap for acumulation */
00213 } MTgomory_ccbk_t;
00214 /* ========================================================================= */
00215 /** @} */
00216 /* end of mt_types.h */
00217 #endif

Generated on Mon Oct 26 09:16:29 2009 for MTgomory by  doxygen 1.4.6