- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Cgl-0.53.1/CoinUtils/src/CoinLpIO.hpp

Go to the documentation of this file.

    00001 // Last edit: 2/10/07
    00002 //
    00003 // Name:     CoinLpIO.hpp; Support for Lp files
    00004 // Author:   Francois Margot
    00005 //           Tepper School of Business
    00006 //           Carnegie Mellon University, Pittsburgh, PA 15213
    00007 //           email: fmargot@andrew.cmu.edu
    00008 // Date:     12/28/03
    00009 //-----------------------------------------------------------------------------
    00010 // Copyright (C) 2003, Francois Margot, International Business Machines
    00011 // Corporation and others.  All Rights Reserved.
    00012
    00013 #include <cstdio>
    00014
    00015 class CoinPackedMatrix;
    00016
    00017 typedef int COINColumnIndex;
    00018
    00089 class CoinLpIO {
    00090
    00091 public:
    00092
    00095
    00096   CoinLpIO();
    00097
    00099   ~CoinLpIO();
    00100
    00106   void freePreviousNames(const int section);
    00107
    00109   void freeAll();
    00111
    00114     inline void
    00115     convertBoundToSense(const double lower, const double upper,
    00116                         char& sense, double& right, double& range) const;
    00117
    00120
    00122   const char * getProblemName() const;
    00123
    00125   void setProblemName(const char *name);
    00126
    00128   int getNumCols() const;
    00129
    00131   int getNumRows() const;
    00132
    00134   int getNumElements() const;
    00135
    00137   const double * getColLower() const;
    00138
    00140   const double * getColUpper() const;
    00141
    00143   const double * getRowLower() const;
    00144
    00146   const double * getRowUpper() const;
    00156   const char * getRowSense() const;
    00157
    00169   const double * getRightHandSide() const;
    00170
    00184   const double * getRowRange() const;
    00185
    00187   const double * getObjCoefficients() const;
    00188
    00190   const CoinPackedMatrix * getMatrixByRow() const;
    00191
    00193   const CoinPackedMatrix * getMatrixByCol() const;
    00194
    00196   const char * getObjName() const;
    00197
    00203   void getPreviousRowNames(char const * const * prev,
    00204                            int *card_prev) const;
    00205
    00210   void getPreviousColNames(char const * const * prev,
    00211                            int *card_prev) const;
    00212
    00215   char const * const * getRowNames() const;
    00216
    00218   char const * const *getColNames() const;
    00219
    00223   const char * rowName(int index) const;
    00224
    00228   const char * columnName(int index) const;
    00229
    00233   int rowIndex(const char * name) const;
    00234
    00237   int columnIndex(const char * name) const;
    00238
    00240   double objectiveOffset() const;
    00241
    00243   inline void setObjectiveOffset(double value)
    00244   { objectiveOffset_ = value;}
    00245
    00248   bool isInteger(int columnNumber) const;
    00249
    00251   const char * integerColumns() const;
    00253
    00256
    00257   double getInfinity() const;
    00258
    00261   void setInfinity(const double);
    00262
    00264   double getEpsilon() const;
    00265
    00268   void setEpsilon(const double);
    00269
    00271   int getNumberAcross() const;
    00272
    00275   void setNumberAcross(const int);
    00276
    00278   int getDecimals() const;
    00279
    00282   void setDecimals(const int);
    00284
    00296   void setLpDataWithoutRowAndColNames(
    00297                               const CoinPackedMatrix& m,
    00298                               const double* collb, const double* colub,
    00299                               const double* obj_coeff,
    00300                               const char* integrality,
    00301                               const double* rowlb, const double* rowub);
    00302
    00315   int is_invalid_name(const char *buff, const bool ranged) const;
    00316
    00333   int are_invalid_names(char const * const *vnames,
    00334                                   const int card_vnames,
    00335                                   const bool check_ranged) const;
    00336
    00339   void setDefaultRowNames();
    00340
    00342   void setDefaultColNames();
    00343
    00363   void setLpDataRowAndColNames(char const * const * const rownames,
    00364                                char const * const * const colnames);
    00365
    00380   int writeLp(const char *filename,
    00381               const double epsilon,
    00382               const int numberAcross,
    00383               const int decimals,
    00384               const bool useRowNames = true);
    00385
    00400   int writeLp(FILE *fp,
    00401               const double epsilon,
    00402               const int numberAcross,
    00403               const int decimals,
    00404               const bool useRowNames = true);
    00405
    00408   int writeLp(const char *filename, const bool useRowNames = true);
    00409
    00412   int writeLp(FILE *fp, const bool useRowNames = true);
    00413
    00418   void readLp(const char *filename, const double epsilon);
    00419
    00424   void readLp(const char *filename);
    00425
    00431   void readLp(FILE *fp, const double epsilon);
    00432
    00437   void readLp(FILE *fp);
    00438
    00440   void print() const;
    00442
    00443 protected:
    00445   char * problemName_;
    00446
    00448   int numberRows_;
    00449
    00451   int numberColumns_;
    00452
    00454   int numberElements_;
    00455
    00457   mutable CoinPackedMatrix *matrixByColumn_;
    00458
    00460   CoinPackedMatrix *matrixByRow_;
    00461
    00463   double * rowlower_;
    00464
    00466   double * rowupper_;
    00467
    00469   double * collower_;
    00470
    00472   double * colupper_;
    00473
    00475   mutable double * rhs_;
    00476
    00480   mutable double  *rowrange_;
    00481
    00483   mutable char * rowsense_;
    00484
    00486   double * objective_;
    00487
    00489   double objectiveOffset_;
    00490
    00493   char * integerType_;
    00494
    00496   char * fileName_;
    00497
    00499   double infinity_;
    00500
    00502   double epsilon_;
    00503
    00505   int numberAcross_;
    00506
    00508   int decimals_;
    00509
    00511   char *objName_;
    00512
    00519   char **previous_names_[2];
    00520
    00525   int card_previous_names_[2];
    00526
    00531   char **names_[2];
    00532
    00533   typedef struct {
    00534     int index, next;
    00535   } CoinHashLink;
    00536
    00540   int maxHash_[2];
    00541
    00545   int numberHash_[2];
    00546
    00550   mutable CoinHashLink *hash_[2];
    00551
    00557   void startHash(char const * const * const names,
    00558                  const COINColumnIndex number,
    00559                  int section);
    00560
    00564   void stopHash(int section);
    00565
    00570   COINColumnIndex findHash(const char *name, int section) const;
    00571
    00576   void insertHash(const char *thisName, int section);
    00577
    00580   void out_coeff(FILE *fp, double v, int print_1) const;
    00581
    00585   int find_obj(FILE *fp) const;
    00586
    00592   int is_subject_to(const char *buff) const;
    00593
    00596   int first_is_number(const char *buff) const;
    00597
    00600   int is_comment(const char *buff) const;
    00601
    00603   void skip_comment(char *buff, FILE *fp) const;
    00604
    00606   void scan_next(char *buff, FILE *fp) const;
    00607
    00610   int is_free(const char *buff) const;
    00611
    00617   int is_sense(const char *buff) const;
    00618
    00628   int is_keyword(const char *buff) const;
    00629
    00632   int read_monom_obj(FILE *fp, double *coeff, char **name, int *cnt,
    00633                      char **obj_name);
    00634
    00639   int read_monom_row(FILE *fp, char *start_str, double *coeff, char **name,
    00640                      int cnt_coeff) const;
    00641
    00643   void realloc_coeff(double **coeff, char ***colNames, int *maxcoeff) const;
    00644
    00646   void realloc_row(char ***rowNames, int **start, double **rhs,
    00647                    double **rowlow, double **rowup, int *maxrow) const;
    00648
    00650   void realloc_col(double **collow, double **colup, char **is_int,
    00651                    int *maxcol) const;
    00652
    00654   void read_row(FILE *fp, char *buff, double **pcoeff, char ***pcolNames,
    00655                 int *cnt_coeff, int *maxcoeff,
    00656                      double *rhs, double *rowlow, double *rowup,
    00657                      int *cnt_row, double inf) const;
    00658
    00672   void checkRowNames();
    00673
    00682   void checkColNames();
    00683
    00684 };
    00685