mpq_rawlp.h

Go to the documentation of this file.
00001 #include "qs_config.h"
00002 #ifdef HAVE_LIBGMP
00003 #if HAVE_LIBGMP
00004 /****************************************************************************/
00005 /*                                                                          */
00006 /*  This file is part of QSopt_ex.                                          */
00007 /*                                                                          */
00008 /*  (c) Copyright 2006 by David Applegate, William Cook, Sanjeeb Dash,      */
00009 /*  and Daniel Espinoza                                                     */
00010 /*                                                                          */
00011 /*  Sanjeeb Dash ownership of copyright in QSopt_ex is derived from his     */
00012 /*  copyright in QSopt.                                                     */
00013 /*                                                                          */
00014 /*  This code may be used under the terms of the GNU General Public License */
00015 /*  (Version 2.1 or later) as published by the Free Software Foundation.    */
00016 /*                                                                          */
00017 /*  Alternatively, use is granted for research purposes only.               */
00018 /*                                                                          */
00019 /*  It is your choice of which of these two licenses you are operating      */
00020 /*  under.                                                                  */
00021 /*                                                                          */
00022 /*  We make no guarantees about the correctness or usefulness of this code. */
00023 /*                                                                          */
00024 /****************************************************************************/
00025 
00026 /*  RCS_INFO = "$RCSfile: mpq_rawlp.h,v $ $Revision: 1.3 $ $Date: 2003/11/05 16:57:39 $"; */
00027 #ifndef mpq___ILL_RAWLP_H_
00028 #define mpq___ILL_RAWLP_H_
00029 
00030 /****************************************************************************/
00031 /* DataStructure and Routines                                               */
00032 /*          to deal with raw lp information as read from mps or lp files    */
00033 /*          support scanning of input                                       */
00034 /*          error reporting                                                 */
00035 /****************************************************************************/
00036 
00037 #include "trace.h"
00038 #include "mpq_lpdata.h"
00039 #include "mpq_iqsutil.h"
00040 #include "mpq_format.h"
00041 #include "mpq_lpdefs.h"
00042 
00043 #define mpq_ILL_ISBLANK(p) \
00044              (((*(p))==' '||(*(p))=='\t'||(*(p))=='\r'||(*(p))=='\f') ? 1 : 0)
00045 
00046 /* 
00047  * we rely on ILLsymboltab property:
00048  *   the ith name added can be retrieved by ILLsymboltab_get(table, i) 
00049  *   as long as we never delete names from the symbol table 
00050  */
00051 typedef struct mpq_rawlpdata
00052 {
00053   char *name;
00054 
00055   char *rhsname;
00056   char *rangesname;
00057   char *boundsname;
00058 
00059   int objsense;                 /* maximize or minimize */
00060   int objindex;                 /* index of objective row */
00061 
00062   int nrows;                    /* number of rows in problem */
00063   ILLsymboltab rowtab;          /* ILLsymboltab_get(rowtab, i) name of ith row */
00064 
00065   int sensesize;                /* size of rowsense */
00066   char *rowsense;               /* rowsense[i] snese of row[i] */
00067 
00068   char *rhsind;                 /* rhsind[i] == 1 we saw an rhs for row[i] */
00069   /* size is nrows */
00070   int rhssize;                  /* size of rhs array */
00071   mpq_t *rhs;               /* rhs values for rows; size is nrows */
00072   char *rangesind;              /* ranges[i] == 1 we saw a range def for row[i] */
00073   struct mpq_colptr *ranges;        /* list of range values */
00074 
00075   int ncols;                    /* number of cols in problem */
00076   ILLsymboltab coltab;          /* ILLsymboltab_get(coltab, i) name of ith col */
00077   int colsize;                  /* size of cols array */
00078   struct mpq_colptr **cols;
00079 
00080   char *lbind;                  /* lbind[i] == 1  we saw a lower bound for col[i] */
00081   char *ubind;                  /* ubind[i] == 1  we saw a upper bound for col[i] */
00082   mpq_t *lower;             /* lower[i] = lower bound for col[i] */
00083   mpq_t *upper;             /* upper[i] = upper bound for col[i] */
00084 
00085   int intsize;                  /* size of intmarker array */
00086   char *intmarker;              /* intmarker[i] == 1  col[i] is an int var */
00087 
00088   /* sos information is tranfered into mpq_ILLmatrix lpdata->sos */
00089   char *refrow;                 /* name of reference row */
00090   int refrowind;                /* index of refrow or -1  */
00091 
00092   int is_sos_size;              /* size of is_sos_member array */
00093   int *is_sos_member;           /* for each col contains either               
00094                                  *     -1 == no sos memeber 
00095                                  *     i  == member of set #i */
00096 
00097   int nsos_member;              /* total number of sos set members */
00098   int sos_weight_size;          /* size of sos_weight array */
00099   mpq_t *sos_weight;        /* sos set elem i has weight of sos_weight[i] 
00100                                  * value comes from refrow coeficients */
00101   int sos_col_size;             /* size of sos_col array */
00102   int *sos_col;                 /* sos elem i is column sos_col[i] */
00103 
00104   int nsos;                     /* number of sos sets */
00105   int sos_setsize;              /* size of sosset array */
00106   struct mpq_sosptr *sos_set;       /* type, size, first element of sos sets 
00107                                  * first is index into sos_weight and sos_col 
00108                                  * arrays */
00109   mpq_qserror_collector *error_collector;
00110   ILLptrworld ptrworld;
00111 }
00112 mpq_rawlpdata;
00113 
00114 typedef struct mpq_colptr
00115 {
00116   mpq_t coef;
00117   struct mpq_colptr *next;
00118   int this_val;                     /* row index */
00119 }
00120 mpq_colptr;
00121 extern mpq_colptr *mpq_ILLcolptralloc (
00122   ILLptrworld * p);
00123 
00124 typedef struct mpq_sosptr
00125 {
00126   int nelem;                    /* number of set elements */
00127   int first;                    /* index of first set element in sosmemeber */
00128   char type;                    /* set type */
00129 }
00130 mpq_sosptr;
00131 extern const int mpq_ILL_SOS_TYPE1;
00132 extern const int mpq_ILL_SOS_TYPE2;
00133 
00134 extern void mpq_ILLinit_rawlpdata (
00135   mpq_rawlpdata * lp,
00136   mpq_qserror_collector * collector);
00137 extern void mpq_ILLfree_rawlpdata (
00138   mpq_rawlpdata * lp);
00139 extern void mpq_ILLraw_clear_matrix (
00140   mpq_rawlpdata * lp);
00141 
00142 extern const char *mpq_ILLraw_rowname (
00143   mpq_rawlpdata * lp,
00144   int i);
00145 extern const char *mpq_ILLraw_colname (
00146   mpq_rawlpdata * lp,
00147   int i);
00148 
00149 extern int mpq_ILLraw_add_col (
00150   mpq_rawlpdata * lp,
00151   const char *name,
00152   int intmarker);
00153 extern int mpq_ILLraw_add_row (
00154   mpq_rawlpdata * lp,
00155   const char *name,
00156   int sense,
00157   const mpq_t rhs);
00158 
00159 extern int mpq_ILLraw_add_col_coef (
00160   mpq_rawlpdata * lp,
00161   int colind,
00162   int rowind,
00163   mpq_t coef);
00164 
00165 extern int mpq_ILLraw_init_ranges (
00166   mpq_rawlpdata * lp);
00167 extern int mpq_ILLraw_init_rhs (
00168   mpq_rawlpdata * lp);
00169 
00170 extern int mpq_ILLraw_add_ranges_coef (
00171   mpq_rawlpdata * lp,
00172   int rowind,
00173   mpq_t coef);
00174 
00175 
00176 extern int mpq_ILLraw_add_sos (
00177   mpq_rawlpdata * lp,
00178   int sos_type);
00179 
00180                                                 /* add empty set with type */
00181 extern int mpq_ILLraw_add_sos_member (
00182   mpq_rawlpdata * lp,
00183   int colind);
00184 
00185                                                 /* add col to last set */
00186 extern int mpq_ILLraw_is_mem_other_sos (
00187   mpq_rawlpdata * lp,
00188   int colind);
00189 
00190 extern int mpq_ILLraw_set_rhs_name (
00191   mpq_rawlpdata * lp,
00192   const char *name,
00193   int *skip);
00194 extern int mpq_ILLraw_set_bounds_name (
00195   mpq_rawlpdata * lp,
00196   const char *name,
00197   int *skip);
00198 extern int mpq_ILLraw_set_ranges_name (
00199   mpq_rawlpdata * lp,
00200   const char *name,
00201   int *skip);
00202 extern void mpq_ILLprint_rawlpdata (
00203   mpq_rawlpdata * lp);
00204 
00205 extern char *mpq_ILLraw_unique_name (
00206   ILLsymboltab * tab,
00207   char *prefix,
00208   int i);
00209 extern int mpq_ILLraw_fill_in_rownames (
00210   mpq_rawlpdata * lp);
00211 
00212 extern int mpq_ILLraw_init_bounds (
00213   mpq_rawlpdata * lp);
00214 
00215 extern const char *mpq_ILLraw_set_lowerBound (
00216   mpq_rawlpdata * lp,
00217   int i,
00218   mpq_t bnd);
00219 extern const char *mpq_ILLraw_set_upperBound (
00220   mpq_rawlpdata * lp,
00221   int i,
00222   mpq_t bnd);
00223 extern const char *mpq_ILLraw_set_fixedBound (
00224   mpq_rawlpdata * lp,
00225   int i,
00226   mpq_t bnd);
00227 extern const char *mpq_ILLraw_set_binaryBound (
00228   mpq_rawlpdata * lp,
00229   int i);
00230 extern const char *mpq_ILLraw_set_unbound (
00231   mpq_rawlpdata * lp,
00232   int colind);
00233 extern int mpq_ILLraw_fill_in_bounds (
00234   mpq_rawlpdata * lp);
00235 
00236 extern int mpq_ILLraw_first_nondefault_bound (
00237   mpq_ILLlpdata * lp);
00238 extern int mpq_ILLraw_default_lower (
00239   mpq_ILLlpdata * lp,
00240   int i);
00241 extern int mpq_ILLraw_default_upper (
00242   mpq_ILLlpdata * lp,
00243   int i,
00244   int ri);
00245 
00246 extern int mpq_ILLrawlpdata_to_lpdata (
00247   mpq_rawlpdata * raw,
00248   mpq_ILLlpdata * lp);
00249 
00250 extern int mpq_ILLdata_error (
00251   mpq_qserror_collector * collector,
00252   const char *format,
00253   ...);
00254 extern void mpq_ILLdata_warn (
00255   mpq_qserror_collector * collector,
00256   const char *format,
00257   ...);
00258 
00259 #endif
00260 #endif
00261 #endif

Generated on Thu Mar 29 09:32:32 2012 for QSopt_ex by  doxygen 1.4.7