Clp 1.17.6

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoinMpsIO.hpp
Go to the documentation of this file.
1 /* $Id: CoinMpsIO.hpp 2083 2019-01-06 19:38:09Z unxusr $ */
2 // Copyright (C) 2000, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5
6 #ifndef CoinMpsIO_H
7 #define CoinMpsIO_H
8
9 #if defined(_MSC_VER)
10 // Turn off compiler warning about long names
11 #pragma warning(disable : 4786)
12 #endif
13
14 #include <vector>
15 #include <string>
16
17 #include "CoinUtilsConfig.h"
18 #include "CoinPackedMatrix.hpp"
19 #include "CoinMessageHandler.hpp"
20 #include "CoinFileIO.hpp"
21 class CoinModel;
22
27 typedef int COINColumnIndex;
28
30 typedef int COINRowIndex;
31
32 // We are allowing free format - but there is a limit!
33 // User can override by using CXXFLAGS += -DCOIN_MAX_FIELD_LENGTH=nnn
34 #ifndef COIN_MAX_FIELD_LENGTH
35 #define COIN_MAX_FIELD_LENGTH 160
36 #endif
37 #define MAX_CARD_LENGTH 5 * COIN_MAX_FIELD_LENGTH + 80
38
39 enum COINSectionType { COIN_NO_SECTION,
40 COIN_NAME_SECTION,
41 COIN_ROW_SECTION,
42 COIN_COLUMN_SECTION,
43 COIN_RHS_SECTION,
44 COIN_RANGES_SECTION,
45 COIN_BOUNDS_SECTION,
46 COIN_ENDATA_SECTION,
47 COIN_EOF_SECTION,
48 COIN_QUADRATIC_SECTION,
49 COIN_CONIC_SECTION,
50 COIN_QUAD_SECTION,
51 COIN_SOS_SECTION,
52 COIN_BASIS_SECTION,
53 COIN_UNKNOWN_SECTION
54 };
55
56 enum COINMpsType { COIN_N_ROW,
57 COIN_E_ROW,
58 COIN_L_ROW,
59 COIN_G_ROW,
60 COIN_BLANK_COLUMN,
61 COIN_S1_COLUMN,
62 COIN_S2_COLUMN,
63 COIN_S3_COLUMN,
64 COIN_INTORG,
65 COIN_INTEND,
66 COIN_SOSEND,
67 COIN_UNSET_BOUND,
68 COIN_UP_BOUND,
69 COIN_FX_BOUND,
70 COIN_LO_BOUND,
71 COIN_FR_BOUND,
72 COIN_MI_BOUND,
73 COIN_PL_BOUND,
74 COIN_BV_BOUND,
75 COIN_UI_BOUND,
76 COIN_LI_BOUND,
77 COIN_BOTH_BOUNDS_SET,
78 COIN_SC_BOUND,
79 COIN_S1_BOUND,
80 COIN_S2_BOUND,
81 COIN_BS_BASIS,
82 COIN_XL_BASIS,
83 COIN_XU_BASIS,
84 COIN_LL_BASIS,
85 COIN_UL_BASIS,
86 COIN_UNKNOWN_MPS_TYPE
87 };
88 class CoinMpsIO;
90 class CoinMpsCardReader {
91
92 public:
95 CoinMpsCardReader(CoinFileInput *input, CoinMpsIO *reader);
98
100 ~CoinMpsCardReader();
102
105 COINSectionType readToNextSection();
108 COINSectionType nextField();
122 int nextGmsField(int expectedType);
124 inline COINSectionType whichSection() const
125 {
126 return section_;
127 }
129 inline void setWhichSection(COINSectionType section)
130 {
131 section_ = section;
132 }
134 inline bool freeFormat() const
135 {
136 return freeFormat_;
137 }
139 inline void setFreeFormat(bool yesNo)
140 {
141 freeFormat_ = yesNo;
142 }
145 inline COINMpsType mpsType() const
146 {
147 return mpsType_;
148 }
150 int cleanCard();
152 inline const char *rowName() const
153 {
154 return rowName_;
155 }
157 inline const char *columnName() const
158 {
159 return columnName_;
160 }
162 inline double value() const
163 {
164 return value_;
165 }
167 inline const char *valueString() const
168 {
169 return valueString_;
170 }
172 inline const char *card() const
173 {
174 return card_;
175 }
177 inline char *mutableCard()
178 {
179 return card_;
180 }
182 inline void setPosition(char *position)
183 {
184 position_ = position;
185 }
187 inline char *getPosition() const
188 {
189 return position_;
190 }
192 inline CoinBigIndex cardNumber() const
193 {
194 return cardNumber_;
195 }
197 inline CoinFileInput *fileInput() const
198 {
199 return input_;
200 }
202 inline void setStringsAllowed()
203 {
204 stringsAllowed_ = true;
205 }
207
209 protected:
212 double value_;
215 char card_[MAX_CARD_LENGTH];
217 char *position_;
219 char *eol_;
221 COINMpsType mpsType_;
223 char rowName_[COIN_MAX_FIELD_LENGTH];
225 char columnName_[COIN_MAX_FIELD_LENGTH];
227 CoinFileInput *input_;
229 COINSectionType section_;
231 CoinBigIndex cardNumber_;
233 bool freeFormat_;
235 int ieeeFormat_;
237 bool eightChar_;
239 CoinMpsIO *reader_;
241 CoinMessageHandler *handler_;
243 CoinMessages messages_;
245 char valueString_[COIN_MAX_FIELD_LENGTH];
247 bool stringsAllowed_;
249 public:
252 double osi_strtod(char *ptr, char **output, int type);
255 static void strcpyAndCompress(char *to, const char *from);
257 static char *nextBlankOr(char *image);
259 double osi_strtod(char *ptr, char **output);
261 };
262
263 //#############################################################################
264 #ifdef USE_SBB
265 class SbbObject;
266 class SbbModel;
267 #endif
268 class CoinSet {
270
271 public:
274 CoinSet();
277 CoinSet(int numberEntries, const int *which);
278
280 CoinSet(const CoinSet &);
281
283 CoinSet &operator=(const CoinSet &rhs);
284
286 virtual ~CoinSet();
288
291 inline int numberEntries() const
293 {
294 return numberEntries_;
295 }
297 inline void setNumberEntries(int number)
298 {
299 numberEntries_ = number;
300 }
302 inline int setType() const
303 {
304 return setType_;
305 }
307 inline void setSetType(int type)
308 {
309 setType_ = type;
310 }
312 inline const int *which() const
313 {
314 return which_;
315 }
317 inline const double *weights() const
318 {
319 return weights_;
320 }
322 inline int *modifiableWhich() const
323 {
324 return which_;
325 }
327 inline double *modifiableWeights() const
328 {
329 return weights_;
330 }
332
333 #ifdef USE_SBB
334
336 virtual SbbObject *sbbObject(SbbModel *model) const
338 {
339 return NULL;
340 }
342 #endif
343
345 protected:
348 int numberEntries_;
351 int setType_;
353 int *which_;
355 double *weights_;
357 };
358
359 //#############################################################################
361 class CoinSosSet : public CoinSet {
362
363 public:
366 CoinSosSet(int numberEntries, const int *which, const double *weights, int type);
368
370 virtual ~CoinSosSet();
372
373 #ifdef USE_SBB
374
376 virtual SbbObject *sbbObject(SbbModel *model) const;
379 #endif
380
382 protected:
385
386 };
387
388 //#############################################################################
389
401 class CoinMpsIO {
402 friend void CoinMpsIOUnitTest(const std::string &mpsDir);
403
404 public:
416 int getNumCols() const;
418
420 int getNumRows() const;
421
423 CoinBigIndex getNumElements() const;
424
426 const double *getColLower() const;
427
429 const double *getColUpper() const;
430
440 const char *getRowSense() const;
441
453 const double *getRightHandSide() const;
454
468 const double *getRowRange() const;
469
471 const double *getRowLower() const;
472
474 const double *getRowUpper() const;
475
477 const double *getObjCoefficients() const;
478
480 const CoinPackedMatrix *getMatrixByRow() const;
481
483 const CoinPackedMatrix *getMatrixByCol() const;
484
486 bool isContinuous(int colNumber) const;
487
493 bool isInteger(int columnNumber) const;
494
500 int isIntegerOrSemiContinuous(int columnNumber) const;
501
507 const char *integerColumns() const;
508
513 const char *rowName(int index) const;
514
519 const char *columnName(int index) const;
520
527 int rowIndex(const char *name) const;
528
533 int columnIndex(const char *name) const;
534
539 double objectiveOffset() const;
541 inline void setObjectiveOffset(double value)
542 {
543 objectiveOffset_ = value;
544 }
545
547 const char *getProblemName() const;
548
550 const char *getObjectiveName() const;
551
553 const char *getRhsName() const;
554
556 const char *getRangeName() const;
557
559 const char *getBoundName() const;
561 inline int numberStringElements() const
562 {
563 return numberStringElements_;
564 }
566 inline const char *stringElement(int i) const
567 {
568 return stringElements_[i];
569 }
571
577
579 void setMpsData(const CoinPackedMatrix &m, const double infinity,
580 const double *collb, const double *colub,
581 const double *obj, const char *integrality,
582 const double *rowlb, const double *rowub,
583 char const *const *const colnames,
584 char const *const *const rownames);
585 void setMpsData(const CoinPackedMatrix &m, const double infinity,
586 const double *collb, const double *colub,
587 const double *obj, const char *integrality,
588 const double *rowlb, const double *rowub,
589 const std::vector< std::string > &colnames,
590 const std::vector< std::string > &rownames);
591 void setMpsData(const CoinPackedMatrix &m, const double infinity,
592 const double *collb, const double *colub,
593 const double *obj, const char *integrality,
594 const char *rowsen, const double *rowrhs,
595 const double *rowrng,
596 char const *const *const colnames,
597 char const *const *const rownames);
598 void setMpsData(const CoinPackedMatrix &m, const double infinity,
599 const double *collb, const double *colub,
600 const double *obj, const char *integrality,
601 const char *rowsen, const double *rowrhs,
602 const double *rowrng,
603 const std::vector< std::string > &colnames,
604 const std::vector< std::string > &rownames);
605
611 void copyInIntegerInformation(const char *integerInformation);
612
614 void setProblemName(const char *name);
615
617 void setObjectiveName(const char *name);
618
620
627 void setInfinity(double value);
629
631 double getInfinity() const;
632
634 void setDefaultBound(int value);
635
637 int getDefaultBound() const;
639 inline int allowStringElements() const
640 {
641 return allowStringElements_;
642 }
644 inline void setAllowStringElements(int yesNo)
645 {
646 allowStringElements_ = yesNo;
647 }
650 inline double getSmallElementValue() const
651 {
652 return smallElement_;
653 }
654 inline void setSmallElementValue(double value)
655 {
656 smallElement_ = value;
657 }
659
678 void setFileName(const char *name);
680
682 const char *getFileName() const;
683
688 int readMps(const char *filename, const char *extension = "mps");
689
695 int readMps(const char *filename, const char *extension,
696 int &numberSets, CoinSet **&sets);
697
708 int readMps();
710 int readMps(int &numberSets, CoinSet **&sets);
720 int readBasis(const char *filename, const char *extension,
721 double *solution, unsigned char *rowStatus, unsigned char *columnStatus,
722 const std::vector< std::string > &colnames, int numberColumns,
723 const std::vector< std::string > &rownames, int numberRows);
724
730 int readGms(const char *filename, const char *extension = "gms", bool convertObjective = false);
731
737 int readGms(const char *filename, const char *extension,
738 int &numberSets, CoinSet **&sets);
739
746 // Not for now int readGms();
748 int readGms(int &numberSets, CoinSet **&sets);
751 int readGMPL(const char *modelName, const char *dataName = NULL, bool keepNames = false);
752
778 int writeMps(const char *filename, int compression = 0,
779 int formatType = 0, int numberAcross = 2,
780 CoinPackedMatrix *quadratic = NULL,
781 int numberSOS = 0, const CoinSet *setInfo = NULL) const;
782
784 inline const CoinMpsCardReader *reader() const
785 {
786 return cardReader_;
787 }
788
816 int readQuadraticMps(const char *filename,
817 CoinBigIndex *&columnStart, int *&column, double *&elements,
818 int checkSymmetry);
819
839 int readConicMps(const char *filename,
840 int *&columnStart, int *&column, int *&coneType, int &numberCones);
842 inline void setConvertObjective(bool trueFalse)
843 {
844 convertObjective_ = trueFalse;
845 }
847 int copyStringElements(const CoinModel *model);
849
852 CoinMpsIO();
854
856 CoinMpsIO(const CoinMpsIO &);
857
859 CoinMpsIO &operator=(const CoinMpsIO &rhs);
860
862 ~CoinMpsIO();
864
872 void passInMessageHandler(CoinMessageHandler *handler);
873
875 void newLanguage(CoinMessages::Language language);
876
878 inline void setLanguage(CoinMessages::Language language) { newLanguage(language); }
879
881 inline CoinMessageHandler *messageHandler() const { return handler_; }
882
884 inline CoinMessages messages() { return messages_; }
886 inline CoinMessages *messagesPointer() { return &messages_; }
888
899 void releaseRedundantInformation();
900
902 void releaseRowInformation();
903
905 void releaseColumnInformation();
906
908 void releaseIntegerInformation();
909
911 void releaseRowNames();
912
914 void releaseColumnNames();
915
917 void releaseMatrixInformation();
919
920 protected:
923
925 void
926 setMpsDataWithoutRowAndColNames(
927 const CoinPackedMatrix &m, const double infinity,
928 const double *collb, const double *colub,
929 const double *obj, const char *integrality,
930 const double *rowlb, const double *rowub);
931 void
932 setMpsDataColAndRowNames(
933 const std::vector< std::string > &colnames,
934 const std::vector< std::string > &rownames);
935 void
936 setMpsDataColAndRowNames(
937 char const *const *const colnames,
938 char const *const *const rownames);
939
941 void gutsOfDestructor();
942
944 void gutsOfCopy(const CoinMpsIO &);
945
947 void freeAll();
948
951 inline void
952 convertBoundToSense(const double lower, const double upper,
953 char &sense, double &right, double &range) const;
956 inline void
957 convertSenseToBound(const char sense, const double right,
958 const double range,
959 double &lower, double &upper) const;
960
973 int dealWithFileName(const char *filename, const char *extension,
974 CoinFileInput *&input);
979 void addString(int iRow, int iColumn, const char *value);
981 void decodeString(int iString, int &iRow, int &iColumn, const char *&value) const;
983
984 // for hashing
985 typedef struct {
986 int index, next;
987 } CoinHashLink;
988
991 void startHash(char **names, const int number, int section);
994 void startHash(int section) const;
996 void stopHash(int section);
998 int findHash(const char *name, int section) const;
1000
1003 char *problemName_;
1005
1007 char *objectiveName_;
1008
1010 char *rhsName_;
1011
1013 char *rangeName_;
1014
1016 char *boundName_;
1017
1019 int numberRows_;
1020
1022 int numberColumns_;
1023
1025 CoinBigIndex numberElements_;
1026
1028 mutable char *rowsense_;
1029
1031 mutable double *rhs_;
1032
1036 mutable double *rowrange_;
1037
1039 mutable CoinPackedMatrix *matrixByRow_;
1040
1042 CoinPackedMatrix *matrixByColumn_;
1043
1045 double *rowlower_;
1046
1048 double *rowupper_;
1049
1051 double *collower_;
1052
1054 double *colupper_;
1055
1057 double *objective_;
1058
1060 double objectiveOffset_;
1061
1065 char *integerType_;
1066
1070 char **names_[2];
1072
1075 char *fileName_;
1077
1079 int numberHash_[2];
1080
1082 mutable CoinHashLink *hash_[2];
1084
1087 int defaultBound_;
1089
1091 double infinity_;
1093 double smallElement_;
1094
1096 CoinMessageHandler *handler_;
1102 bool defaultHandler_;
1104 CoinMessages messages_;
1106 CoinMpsCardReader *cardReader_;
1108 bool convertObjective_;
1110 int allowStringElements_;
1112 int maximumStringElements_;
1114 int numberStringElements_;
1116 char **stringElements_;
1118 };
1119
1120 //#############################################################################
1128 void CoinMpsIOUnitTest(const std::string &mpsDir);
1129 // Function to return number in most efficient way
1130 // section is 0 for columns, 1 for rhs,ranges and 2 for bounds
1131 /* formatType is
1132 0 - normal and 8 character names
1133 1 - extra accuracy
1134 2 - IEEE hex - INTEL
1135 3 - IEEE hex - not INTEL
1136 */
1137 void CoinConvertDouble(int section, int formatType, double value, char outputValue[24]);
1138
1139 #endif
1140
1141 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
1142 */
CoinMpsIO::getFileName
const char * getFileName() const
Get the current file name for the CoinMpsIO object.
CoinSet::modifiableWhich
int * modifiableWhich() const
Returns modifiable list of variables.
Definition: CoinMpsIO.hpp:322
COIN_LI_BOUND
Definition: CoinMpsIO.hpp:76
COIN_S1_BOUND
Definition: CoinMpsIO.hpp:79
CoinMpsIO::isIntegerOrSemiContinuous
int isIntegerOrSemiContinuous(int columnNumber) const
Return 1 if a column is an integer variable, 2 if semi-continuous.
CoinMpsCardReader::ieeeFormat_
int ieeeFormat_
Whether IEEE - 0 no, 1 INTEL, 2 not INTEL.
Definition: CoinMpsIO.hpp:235
COIN_FX_BOUND
Definition: CoinMpsIO.hpp:69
CoinMpsIO::numberStringElements_
int numberStringElements_
Number of string elements.
Definition: CoinMpsIO.hpp:1114
CoinMpsCardReader::strcpyAndCompress
static void strcpyAndCompress(char *to, const char *from)
remove blanks
CoinMpsIO::infinity_
double infinity_
Value to use for infinity.
Definition: CoinMpsIO.hpp:1091
CoinMpsIO::getRightHandSide
const double * getRightHandSide() const
Get pointer to array[getNumRows()] of constraint right-hand sides.
CoinMpsCardReader::setWhichSection
void setWhichSection(COINSectionType section)
Sets current section type.
Definition: CoinMpsIO.hpp:129
COIN_BOTH_BOUNDS_SET
Definition: CoinMpsIO.hpp:77
CoinMpsCardReader::rowName
const char * rowName() const
Returns row name of current field.
Definition: CoinMpsIO.hpp:152
COIN_UP_BOUND
Definition: CoinMpsIO.hpp:68
CoinMpsIO::getDefaultBound
int getDefaultBound() const
Get default upper bound for integer variables.
CoinSet::modifiableWeights
double * modifiableWeights() const
Returns modifiable weights.
Definition: CoinMpsIO.hpp:327
CoinSet::operator=
CoinSet & operator=(const CoinSet &rhs)
Assignment operator.
COINMpsType
COINMpsType
Definition: CoinMpsIO.hpp:56
COIN_FR_BOUND
Definition: CoinMpsIO.hpp:71
CoinMpsIO::setInfinity
void setInfinity(double value)
Set infinity.
COIN_BOUNDS_SECTION
Definition: CoinMpsIO.hpp:45
CoinMpsIO::messagesPointer
CoinMessages * messagesPointer()
Return the messages pointer.
Definition: CoinMpsIO.hpp:886
CoinMpsIO::readConicMps
int readConicMps(const char *filename, int *&columnStart, int *&column, int *&coneType, int &numberCones)
Read in a list of cones from the given filename.
CoinMpsIO::releaseIntegerInformation
void releaseIntegerInformation()
Release integer information.
CoinMpsIO::getSmallElementValue
double getSmallElementValue() const
Small element value - elements less than this set to zero on input default is 1.0e-14.
Definition: CoinMpsIO.hpp:650
CoinMpsIO::releaseColumnInformation
void releaseColumnInformation()
Release all column information (lower, upper, objective)
CoinMpsCardReader::handler_
CoinMessageHandler * handler_
Message handler.
Definition: CoinMpsIO.hpp:241
CoinMpsIO::~CoinMpsIO
~CoinMpsIO()
Destructor.
CoinMpsCardReader::cardNumber
CoinBigIndex cardNumber() const
Returns card number.
Definition: CoinMpsIO.hpp:192
CoinMpsIO::gutsOfDestructor
void gutsOfDestructor()
Does the heavy lifting for destruct and assignment.
CoinMpsCardReader::setPosition
void setPosition(char *position)
set position (again so gms reader will work)
Definition: CoinMpsIO.hpp:182
CoinSet::setSetType
void setSetType(int type)
Sets type of set - 1 =SOS1, 2 =SOS2.
Definition: CoinMpsIO.hpp:307
CoinMpsIO::readQuadraticMps
int readQuadraticMps(const char *filename, CoinBigIndex *&columnStart, int *&column, double *&elements, int checkSymmetry)
Read in a quadratic objective from the given filename.
CoinMpsIO::integerType_
char * integerType_
Pointer to dense vector specifying if a variable is continuous (0) or integer (1).
Definition: CoinMpsIO.hpp:1065
CoinMpsIO::getRangeName
const char * getRangeName() const
Return the range vector name.
CoinMpsIO::gutsOfCopy
void gutsOfCopy(const CoinMpsIO &)
Does the heavy lifting for copy and assignment.
CoinMpsIO::getRowLower
const double * getRowLower() const
Get pointer to array[getNumRows()] of row lower bounds.
COIN_MI_BOUND
Definition: CoinMpsIO.hpp:72
CoinMpsIO::getNumCols
int getNumCols() const
Get number of columns.
COIN_EOF_SECTION
Definition: CoinMpsIO.hpp:47
CoinMpsIO::readGms
int readGms(const char *filename, const char *extension="gms", bool convertObjective=false)
Read a problem in GAMS format from the given filename.
COIN_LO_BOUND
Definition: CoinMpsIO.hpp:70
CoinConvertDouble
void CoinConvertDouble(int section, int formatType, double value, char outputValue[24])
CoinSet::setNumberEntries
void setNumberEntries(int number)
Sets number of entries.
Definition: CoinMpsIO.hpp:297
COIN_XL_BASIS
Definition: CoinMpsIO.hpp:82
COIN_RANGES_SECTION
Definition: CoinMpsIO.hpp:44
CoinMpsIO::setSmallElementValue
void setSmallElementValue(double value)
Definition: CoinMpsIO.hpp:654
CoinMpsIO::CoinHashLink::next
int next
Definition: CoinMpsIO.hpp:986
CoinMpsIO::rowsense_
char * rowsense_
Pointer to dense vector of row sense indicators.
Definition: CoinMpsIO.hpp:1028
COIN_QUAD_SECTION
Definition: CoinMpsIO.hpp:50
CoinMpsIO::readGMPL
int readGMPL(const char *modelName, const char *dataName=NULL, bool keepNames=false)
Read a problem in GMPL (subset of AMPL) format from the given filenames.
CoinSet::numberEntries
int numberEntries() const
Returns number of entries.
Definition: CoinMpsIO.hpp:292
CoinMpsCardReader::valueString_
char valueString_[COIN_MAX_FIELD_LENGTH]
Current element as characters (only if strings allowed)
Definition: CoinMpsIO.hpp:245
CoinMpsIO::readMps
int readMps()
Read a problem in MPS format from a previously opened file.
CoinMpsIO::defaultHandler_
bool defaultHandler_
Flag to say if the message handler is the default handler.
Definition: CoinMpsIO.hpp:1102
CoinSet::CoinSet
CoinSet()
Default constructor.
CoinMpsIO::allowStringElements_
int allowStringElements_
Whether to allow string elements.
Definition: CoinMpsIO.hpp:1110
CoinMpsCardReader::input_
CoinFileInput * input_
File input.
Definition: CoinMpsIO.hpp:227
CoinModel
This is a simple minded model which is stored in a format which makes it easier to construct and modi...
Definition: CoinModel.hpp:181
CoinMpsIO::setConvertObjective
void setConvertObjective(bool trueFalse)
Set whether to move objective from matrix.
Definition: CoinMpsIO.hpp:842
CoinMpsIO::getMatrixByRow
const CoinPackedMatrix * getMatrixByRow() const
Get pointer to row-wise copy of the coefficient matrix.
COIN_SC_BOUND
Definition: CoinMpsIO.hpp:78
COIN_NO_SECTION
Definition: CoinMpsIO.hpp:39
CoinMpsIO::releaseMatrixInformation
void releaseMatrixInformation()
Release matrix information.
COIN_ENDATA_SECTION
Definition: CoinMpsIO.hpp:46
CoinMpsIO::convertSenseToBound
void convertSenseToBound(const char sense, const double right, const double range, double &lower, double &upper) const
A quick inlined function to convert from sense/rhs/range stryle constraint definition to lb/ub style...
CoinMpsCardReader::CoinMpsCardReader
CoinMpsCardReader(CoinFileInput *input, CoinMpsIO *reader)
Constructor expects file to be open This one takes gzFile if fp null.
CoinMpsIO::setMpsDataColAndRowNames
void setMpsDataColAndRowNames(const std::vector< std::string > &colnames, const std::vector< std::string > &rownames)
COINSectionType
COINSectionType
Definition: CoinMpsIO.hpp:39
CoinMpsCardReader::freeFormat_
bool freeFormat_
Whether free format. Just for blank RHS etc.
Definition: CoinMpsIO.hpp:233
CoinMpsIO::fileName_
char * fileName_
Current file name.
Definition: CoinMpsIO.hpp:1076
COIN_LL_BASIS
Definition: CoinMpsIO.hpp:84
COIN_UNKNOWN_SECTION
Definition: CoinMpsIO.hpp:53
CoinMpsIO::matrixByColumn_
CoinPackedMatrix * matrixByColumn_
Pointer to column-wise copy of problem matrix coefficients.
Definition: CoinMpsIO.hpp:1042
COIN_BASIS_SECTION
Definition: CoinMpsIO.hpp:52
CoinMessageHandler
Base class for message handling.
Definition: CoinMessageHandler.hpp:345
CoinSet::~CoinSet
virtual ~CoinSet()
Destructor.
COIN_INTEND
Definition: CoinMpsIO.hpp:65
CoinSet::weights
const double * weights() const
Returns weights.
Definition: CoinMpsIO.hpp:317
CoinMpsIO::numberHash_
int numberHash_[2]
Number of entries in a hash table section.
Definition: CoinMpsIO.hpp:1079
CoinMpsIO::copyInIntegerInformation
void copyInIntegerInformation(const char *integerInformation)
Pass in an array[getNumCols()] specifying if a variable is integer.
CoinMpsIO::CoinMpsIO
CoinMpsIO()
Default Constructor.
CoinMpsCardReader::section_
COINSectionType section_
Which section we think we are in.
Definition: CoinMpsIO.hpp:229
CoinMpsIO::getColUpper
const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
MAX_CARD_LENGTH
#define MAX_CARD_LENGTH
Definition: CoinMpsIO.hpp:37
CoinSosSet::CoinSosSet
CoinSosSet(int numberEntries, const int *which, const double *weights, int type)
Constructor.
COIN_G_ROW
Definition: CoinMpsIO.hpp:59
CoinMpsIO::writeMps
int writeMps(const char *filename, int compression=0, int formatType=0, int numberAcross=2, CoinPackedMatrix *quadratic=NULL, int numberSOS=0, const CoinSet *setInfo=NULL) const
Write the problem in MPS format to a file with the given filename.
COIN_BLANK_COLUMN
Definition: CoinMpsIO.hpp:60
CoinMpsIO::messageHandler
CoinMessageHandler * messageHandler() const
Return the message handler.
Definition: CoinMpsIO.hpp:881
CoinMpsIO::rowlower_
double * rowlower_
Pointer to dense vector of row lower bounds.
Definition: CoinMpsIO.hpp:1045
CoinMpsIO::getColLower
const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
CoinMpsCardReader::setFreeFormat
void setFreeFormat(bool yesNo)
Sets whether free format. Mainly for blank RHS etc.
Definition: CoinMpsIO.hpp:139
CoinMpsCardReader::reader_
CoinMpsIO * reader_
MpsIO.
Definition: CoinMpsIO.hpp:239
CoinMpsIO::releaseRedundantInformation
void releaseRedundantInformation()
Release all information which can be re-calculated.
CoinMpsIO::names_
char ** names_[2]
Row and column names Linked to hash table sections (0 - row names, 1 column names) ...
Definition: CoinMpsIO.hpp:1070
CoinMpsIO::objective_
double * objective_
Pointer to dense vector of objective coefficients.
Definition: CoinMpsIO.hpp:1057
CoinMpsIO::copyStringElements
int copyStringElements(const CoinModel *model)
copies in strings from a CoinModel - returns number
CoinMpsIO::cardReader_
CoinMpsCardReader * cardReader_
Card reader.
Definition: CoinMpsIO.hpp:1106
COIN_BS_BASIS
Definition: CoinMpsIO.hpp:81
CoinMpsIO::rhs_
double * rhs_
Pointer to dense vector of row right-hand side values.
Definition: CoinMpsIO.hpp:1031
CoinMpsCardReader::stringsAllowed_
bool stringsAllowed_
Whether strings allowed.
Definition: CoinMpsIO.hpp:247
CoinMessageHandler.hpp
This is a first attempt at a message handler.
CoinMpsIO::colupper_
double * colupper_
Pointer to dense vector of column upper bounds.
Definition: CoinMpsIO.hpp:1054
CoinMpsCardReader::osi_strtod
double osi_strtod(char *ptr, char **output, int type)
type - 0 normal, 1 INTEL IEEE, 2 other IEEE
COIN_PL_BOUND
Definition: CoinMpsIO.hpp:73
CoinMpsIO::defaultBound_
int defaultBound_
Upper bound when no bounds for integers.
Definition: CoinMpsIO.hpp:1088
CoinSosSet
Very simple class for containing SOS set.
Definition: CoinMpsIO.hpp:361
CoinMpsIO::newLanguage
void newLanguage(CoinMessages::Language language)
Set the language for messages.
CoinMpsIO::numberElements_
CoinBigIndex numberElements_
Number of coefficients.
Definition: CoinMpsIO.hpp:1025
CoinMpsIO::rowName
const char * rowName(int index) const
Returns the row name for the specified index.
CoinMpsIO::CoinMpsIOUnitTest
friend void CoinMpsIOUnitTest(const std::string &mpsDir)
A function that tests the methods in the CoinMpsIO class.
CoinSet::numberEntries_
int numberEntries_
Number of entries.
Definition: CoinMpsIO.hpp:349
CoinSosSet::~CoinSosSet
virtual ~CoinSosSet()
Destructor.
CoinMpsIO::getRowSense
const char * getRowSense() const
Get pointer to array[getNumRows()] of constraint senses.
CoinSet::which
const int * which() const
Returns list of variables.
Definition: CoinMpsIO.hpp:312
CoinMpsIO::objectiveName_
char * objectiveName_
Objective row name.
Definition: CoinMpsIO.hpp:1007
CoinMpsCardReader::mpsType_
COINMpsType mpsType_
Current COINMpsType.
Definition: CoinMpsIO.hpp:221
COIN_MAX_FIELD_LENGTH
#define COIN_MAX_FIELD_LENGTH
Definition: CoinMpsIO.hpp:35
CoinSet::which_
int * which_
Which variables are in set.
Definition: CoinMpsIO.hpp:353
CoinMpsIO
MPS IO Interface.
Definition: CoinMpsIO.hpp:401
CoinMpsIO::hash_
CoinHashLink * hash_[2]
Hash tables (two sections, 0 - row names, 1 - column names)
Definition: CoinMpsIO.hpp:1082
CoinMpsIO::convertObjective_
bool convertObjective_
If .gms file should it be massaged to move objective.
Definition: CoinMpsIO.hpp:1108
CoinFileIO.hpp
CoinSet::setType
int setType() const
Returns type of set - 1 =SOS1, 2 =SOS2.
Definition: CoinMpsIO.hpp:302
COIN_E_ROW
Definition: CoinMpsIO.hpp:57
CoinMpsIO::numberStringElements
int numberStringElements() const
Number of string elements.
Definition: CoinMpsIO.hpp:561
CoinMpsIO::getObjectiveName
const char * getObjectiveName() const
Return the objective name.
COIN_UI_BOUND
Definition: CoinMpsIO.hpp:75
COIN_S1_COLUMN
Definition: CoinMpsIO.hpp:61
CoinMpsIO::maximumStringElements_
int maximumStringElements_
Maximum number of string elements.
Definition: CoinMpsIO.hpp:1112
COIN_COLUMN_SECTION
Definition: CoinMpsIO.hpp:42
CoinMpsIO::reader
const CoinMpsCardReader * reader() const
Return card reader object so can see what last card was e.g. QUADOBJ.
Definition: CoinMpsIO.hpp:784
CoinMpsIO::setLanguage
void setLanguage(CoinMessages::Language language)
Set the language for messages.
Definition: CoinMpsIO.hpp:878
CoinMpsCardReader::eol_
char * eol_
End of card.
Definition: CoinMpsIO.hpp:219
COIN_S2_BOUND
Definition: CoinMpsIO.hpp:80
CoinMpsIO::dealWithFileName
int dealWithFileName(const char *filename, const char *extension, CoinFileInput *&input)
Deal with a filename.
CoinMpsIOUnitTest
void CoinMpsIOUnitTest(const std::string &mpsDir)
A function that tests the methods in the CoinMpsIO class.
CoinMpsCardReader::value
double value() const
Returns value in current field.
Definition: CoinMpsIO.hpp:162
CoinMpsIO::freeAll
void freeAll()
Clears problem data from the CoinMpsIO object.
CoinMpsCardReader::position_
char * position_
Current position within card image.
Definition: CoinMpsIO.hpp:217
CoinMpsIO::columnIndex
int columnIndex(const char *name) const
Returns the index for the specified column name.
CoinMpsCardReader::cleanCard
int cleanCard()
Reads and cleans card - taking out trailing blanks - return 1 if EOF.
CoinMpsIO::messages_
CoinMessages messages_
Messages.
Definition: CoinMpsIO.hpp:1104
CoinMpsIO::getBoundName
const char * getBoundName() const
Return the bound vector name.
CoinMpsCardReader::getPosition
char * getPosition() const
get position (again so gms reader will work)
Definition: CoinMpsIO.hpp:187
CoinMpsCardReader::eightChar_
bool eightChar_
If all names &lt;= 8 characters then allow embedded blanks.
Definition: CoinMpsIO.hpp:237
CoinMpsIO::isContinuous
bool isContinuous(int colNumber) const
Return true if column is a continuous variable.
CoinMpsCardReader::freeFormat
bool freeFormat() const
Sees if free format.
Definition: CoinMpsIO.hpp:134
COIN_SOS_SECTION
Definition: CoinMpsIO.hpp:51
CoinMpsIO::objectiveOffset_
double objectiveOffset_
Constant offset for objective value (i.e., RHS value for OBJ row)
Definition: CoinMpsIO.hpp:1060
CoinSet::setType_
int setType_
type of set
Definition: CoinMpsIO.hpp:351
CoinMpsIO::setMpsDataWithoutRowAndColNames
void setMpsDataWithoutRowAndColNames(const CoinPackedMatrix &m, const double infinity, const double *collb, const double *colub, const double *obj, const char *integrality, const double *rowlb, const double *rowub)
Utility method used several times to implement public methods.
CoinMpsIO::collower_
double * collower_
Pointer to dense vector of column lower bounds.
Definition: CoinMpsIO.hpp:1051
CoinMpsIO::getNumElements
CoinBigIndex getNumElements() const
Get number of nonzero elements.
CoinPackedMatrix
Sparse Matrix Base Class.
Definition: CoinPackedMatrix.hpp:79
CoinMpsCardReader
Very simple code for reading MPS data.
Definition: CoinMpsIO.hpp:90
COIN_UNKNOWN_MPS_TYPE
Definition: CoinMpsIO.hpp:86
COIN_L_ROW
Definition: CoinMpsIO.hpp:58
CoinMpsIO::rowrange_
double * rowrange_
Pointer to dense vector of slack variable upper bounds for range constraints (undefined for non-range...
Definition: CoinMpsIO.hpp:1036
CoinMpsCardReader::fileInput
CoinFileInput * fileInput() const
Returns file input.
Definition: CoinMpsIO.hpp:197
CoinMpsIO::rhsName_
char * rhsName_
Right-hand side vector name.
Definition: CoinMpsIO.hpp:1010
CoinMpsIO::addString
void addString(int iRow, int iColumn, const char *value)
Add string to list iRow==numberRows is objective, nr+1 is lo, nr+2 is up iColumn==nc is rhs (can&#39;t co...
COIN_UL_BASIS
Definition: CoinMpsIO.hpp:85
COINColumnIndex
int COINColumnIndex
Definition: CoinLpIO.hpp:27
CoinMpsCardReader::nextGmsField
int nextGmsField(int expectedType)
Gets next field for .gms file and returns type.
CoinMpsCardReader::mpsType
COINMpsType mpsType() const
Only for first field on card otherwise BLANK_COLUMN e.g.
Definition: CoinMpsIO.hpp:145
CoinMpsIO::setAllowStringElements
void setAllowStringElements(int yesNo)
Whether to allow string elements (0 no, 1 yes, 2 yes and try flip)
Definition: CoinMpsIO.hpp:644
CoinMpsIO::matrixByRow_
CoinPackedMatrix * matrixByRow_
Pointer to row-wise copy of problem matrix coefficients.
Definition: CoinMpsIO.hpp:1039
COINRowIndex
int COINRowIndex
Large enough to contain row index (or basis)
Definition: CoinMpsIO.hpp:30
CoinMpsIO::columnName
const char * columnName(int index) const
Returns the column name for the specified index.
CoinMessages::Language
Language
Supported languages.
Definition: CoinMessageHandler.hpp:148
CoinSet::weights_
double * weights_
Weights.
Definition: CoinMpsIO.hpp:355
CoinMpsIO::getObjCoefficients
const double * getObjCoefficients() const
Get pointer to array[getNumCols()] of objective function coefficients.
CoinMpsCardReader::card
const char * card() const
Whole card (for printing)
Definition: CoinMpsIO.hpp:172
CoinMpsCardReader::valueString
const char * valueString() const
Returns value as string in current field.
Definition: CoinMpsIO.hpp:167
CoinBigIndex
int CoinBigIndex
Definition: Coin_C_defines.h:136
CoinFileInput
Abstract base class for file input classes.
Definition: CoinFileIO.hpp:40
CoinMpsCardReader::readToNextSection
COINSectionType readToNextSection()
Read to next section.
COIN_ROW_SECTION
Definition: CoinMpsIO.hpp:41
CoinMpsCardReader::mutableCard
char * mutableCard()
Whole card - so we look at it (not const so nextBlankOr will work for gms reader) ...
Definition: CoinMpsIO.hpp:177
CoinMpsCardReader::card_
char card_[MAX_CARD_LENGTH]
Current card image.
Definition: CoinMpsIO.hpp:215
CoinMpsIO::stopHash
void stopHash(int section)
Deletes hash storage.
CoinMpsIO::smallElement_
double smallElement_
Small element value.
Definition: CoinMpsIO.hpp:1093
CoinMpsIO::isInteger
bool isInteger(int columnNumber) const
Return true if a column is an integer variable.
CoinMpsIO::getRhsName
const char * getRhsName() const
Return the RHS vector name.
CoinMpsIO::rowupper_
double * rowupper_
Pointer to dense vector of row upper bounds.
Definition: CoinMpsIO.hpp:1048
CoinMpsIO::rangeName_
char * rangeName_
Range vector name.
Definition: CoinMpsIO.hpp:1013
CoinMpsCardReader::rowName_
char rowName_[COIN_MAX_FIELD_LENGTH]
Current row name.
Definition: CoinMpsIO.hpp:223
COIN_CONIC_SECTION
Definition: CoinMpsIO.hpp:49
CoinMpsIO::releaseRowInformation
void releaseRowInformation()
Release all row information (lower, upper)
CoinMpsIO::getProblemName
const char * getProblemName() const
Return the problem name.
CoinMpsIO::handler_
CoinMessageHandler * handler_
Message handler.
Definition: CoinMpsIO.hpp:1096
CoinMpsIO::numberColumns_
int numberColumns_
Number of columns.
Definition: CoinMpsIO.hpp:1022
CoinMpsIO::setFileName
void setFileName(const char *name)
Set the current file name for the CoinMpsIO object.
CoinMpsIO::findHash
int findHash(const char *name, int section) const
Finds match using hash, -1 not found.
CoinMpsCardReader::nextField
COINSectionType nextField()
Gets next field and returns section type e.g. COIN_COLUMN_SECTION.
COIN_INTORG
Definition: CoinMpsIO.hpp:64
CoinMpsIO::allowStringElements
int allowStringElements() const
Whether to allow string elements.
Definition: CoinMpsIO.hpp:639
CoinMpsIO::setObjectiveOffset
void setObjectiveOffset(double value)
Set objective offset.
Definition: CoinMpsIO.hpp:541
CoinMpsIO::getMatrixByCol
const CoinPackedMatrix * getMatrixByCol() const
Get pointer to column-wise copy of the coefficient matrix.
COIN_QUADRATIC_SECTION
Definition: CoinMpsIO.hpp:48
CoinMpsIO::passInMessageHandler
void passInMessageHandler(CoinMessageHandler *handler)
Pass in Message handler.
COIN_N_ROW
Definition: CoinMpsIO.hpp:56
CoinMpsIO::CoinHashLink
Definition: CoinMpsIO.hpp:985
CoinMpsCardReader::value_
double value_
Current value.
Definition: CoinMpsIO.hpp:213
CoinMpsIO::getInfinity
double getInfinity() const
Get infinity.
CoinMpsIO::startHash
void startHash(char **names, const int number, int section)
Creates hash list for names (section = 0 for rows, 1 columns)
CoinMpsCardReader::nextBlankOr
static char * nextBlankOr(char *image)
COIN_XU_BASIS
Definition: CoinMpsIO.hpp:83
CoinMpsIO::getNumRows
int getNumRows() const
Get number of rows.
CoinMpsCardReader::setStringsAllowed
void setStringsAllowed()
Sets whether strings allowed.
Definition: CoinMpsIO.hpp:202
CoinMpsCardReader::columnName
const char * columnName() const
Returns column name of current field.
Definition: CoinMpsIO.hpp:157
CoinMpsIO::messages
CoinMessages messages()
Return the messages.
Definition: CoinMpsIO.hpp:884
CoinMpsIO::boundName_
char * boundName_
Bounds vector name.
Definition: CoinMpsIO.hpp:1016
CoinMpsIO::releaseColumnNames
void releaseColumnNames()
Release column names.
CoinMpsCardReader::columnName_
char columnName_[COIN_MAX_FIELD_LENGTH]
Current column name.
Definition: CoinMpsIO.hpp:225
CoinMpsCardReader::messages_
CoinMessages messages_
Messages.
Definition: CoinMpsIO.hpp:243
CoinMpsIO::numberRows_
int numberRows_
Number of rows.
Definition: CoinMpsIO.hpp:1019
COIN_UNSET_BOUND
Definition: CoinMpsIO.hpp:67
CoinMpsIO::getRowRange
const double * getRowRange() const
Get pointer to array[getNumRows()] of row ranges.
CoinMpsIO::stringElement
const char * stringElement(int i) const
String element.
Definition: CoinMpsIO.hpp:566
CoinMpsIO::readBasis
int readBasis(const char *filename, const char *extension, double *solution, unsigned char *rowStatus, unsigned char *columnStatus, const std::vector< std::string > &colnames, int numberColumns, const std::vector< std::string > &rownames, int numberRows)
Read a basis in MPS format from the given filename.
CoinMpsCardReader::whichSection
COINSectionType whichSection() const
Returns current section type.
Definition: CoinMpsIO.hpp:124
CoinMpsIO::integerColumns
const char * integerColumns() const
Returns array[getNumCols()] specifying if a variable is integer.
CoinMpsIO::releaseRowNames
void releaseRowNames()
Release row names.
CoinMpsCardReader::cardNumber_
CoinBigIndex cardNumber_
Card number.
Definition: CoinMpsIO.hpp:231
CoinMpsIO::convertBoundToSense
void convertBoundToSense(const double lower, const double upper, char &sense, double &right, double &range) const
A quick inlined function to convert from lb/ub style constraint definition to sense/rhs/range style...
CoinMpsCardReader::~CoinMpsCardReader
~CoinMpsCardReader()
Destructor.
CoinMpsIO::rowIndex
int rowIndex(const char *name) const
Returns the index for the specified row name.
COIN_S2_COLUMN
Definition: CoinMpsIO.hpp:62
CoinMpsIO::problemName_
char * problemName_
Problem name.
Definition: CoinMpsIO.hpp:1004
COIN_RHS_SECTION
Definition: CoinMpsIO.hpp:43
CoinUtilsConfig.h
COIN_BV_BOUND
Definition: CoinMpsIO.hpp:74
COIN_NAME_SECTION
Definition: CoinMpsIO.hpp:40
CoinMessages
Class to hold and manipulate an array of massaged messages.
Definition: CoinMessageHandler.hpp:140
CoinPackedMatrix.hpp
CoinMpsIO::setMpsData
void setMpsData(const CoinPackedMatrix &m, const double infinity, const double *collb, const double *colub, const double *obj, const char *integrality, const double *rowlb, const double *rowub, char const *const *const colnames, char const *const *const rownames)
Set the problem data.
CoinMpsIO::setObjectiveName
void setObjectiveName(const char *name)
Set objective name.
CoinMpsIO::setDefaultBound
void setDefaultBound(int value)
Set default upper bound for integer variables.
COIN_SOSEND
Definition: CoinMpsIO.hpp:66
CoinSet
Very simple class for containing data on set.
Definition: CoinMpsIO.hpp:269
CoinMpsIO::stringElements_
char ** stringElements_
String elements.
Definition: CoinMpsIO.hpp:1116
CoinMpsIO::setProblemName
void setProblemName(const char *name)
Set problem name.
COIN_S3_COLUMN
Definition: CoinMpsIO.hpp:63
CoinMpsIO::objectiveOffset
double objectiveOffset() const
Returns the (constant) objective offset.
CoinMpsIO::decodeString
void decodeString(int iString, int &iRow, int &iColumn, const char *&value) const
Decode string.
CoinMpsIO::operator=
CoinMpsIO & operator=(const CoinMpsIO &rhs)
Assignment operator.
CoinMpsIO::getRowUpper
const double * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.