CoinUtils 2.11.4
CoinMpsIO.hpp
Go to the documentation of this file.
1/* $Id$ */
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"
20#include "CoinFileIO.hpp"
21class CoinModel;
22
27typedef int COINColumnIndex;
28
30typedef 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
54};
55
87};
88class CoinMpsIO;
91
92public:
98
102
122 int nextGmsField(int expectedType);
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 }
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 }
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
209protected:
213 double value_;
219 char *eol_;
249public:
253 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
265class SbbObject;
266class SbbModel;
267#endif
269class CoinSet {
270
271public:
277 CoinSet(int numberEntries, const int *which);
278
280 CoinSet(const CoinSet &);
281
284
286 virtual ~CoinSet();
288
292 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
337 virtual SbbObject *sbbObject(SbbModel *model) const
338 {
339 return NULL;
340 }
342#endif
343
345protected:
353 int *which_;
355 double *weights_;
357};
358
359//#############################################################################
361class CoinSosSet : public CoinSet {
362
363public:
367 CoinSosSet(int numberEntries, const int *which, const double *weights, int type);
368
370 virtual ~CoinSosSet();
372
373#ifdef USE_SBB
377 virtual SbbObject *sbbObject(SbbModel *model) const;
379#endif
380
382protected:
386};
387
388//#############################################################################
389
402 friend void CoinMpsIOUnitTest(const std::string &mpsDir);
403
404public:
417 int getNumCols() const;
418
420 int getNumRows() const;
421
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
481
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 {
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
628 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 {
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
679 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
854
857
860
864
873
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_; }
888
900
903
906
909
912
915
919
920protected:
923
925 void
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
933 const std::vector< std::string > &colnames,
934 const std::vector< std::string > &rownames);
935 void
937 char const *const *const colnames,
938 char const *const *const rownames);
939
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
992 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
1005
1008
1011
1014
1017
1020
1023
1026
1028 mutable char *rowsense_;
1029
1031 mutable double *rhs_;
1032
1036 mutable double *rowrange_;
1037
1040
1043
1045 double *rowlower_;
1046
1048 double *rowupper_;
1049
1051 double *collower_;
1052
1054 double *colupper_;
1055
1057 double *objective_;
1058
1061
1066
1070 char **names_[2];
1072
1077
1080
1082 mutable CoinHashLink *hash_[2];
1084
1089
1094
1118};
1119
1120//#############################################################################
1128void 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*/
1137void CoinConvertDouble(int section, int formatType, double value, char outputValue[24]);
1138
1139#endif
1140
1141/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
1142*/
This is a first attempt at a message handler.
int COINRowIndex
Large enough to contain row index (or basis)
Definition: CoinMpsIO.hpp:30
#define MAX_CARD_LENGTH
Definition: CoinMpsIO.hpp:37
int COINColumnIndex
The following lengths are in decreasing order (for 64 bit etc) Large enough to contain element index ...
Definition: CoinMpsIO.hpp:27
COINMpsType
Definition: CoinMpsIO.hpp:56
@ COIN_L_ROW
Definition: CoinMpsIO.hpp:58
@ COIN_INTEND
Definition: CoinMpsIO.hpp:65
@ COIN_BLANK_COLUMN
Definition: CoinMpsIO.hpp:60
@ COIN_S2_BOUND
Definition: CoinMpsIO.hpp:80
@ COIN_LO_BOUND
Definition: CoinMpsIO.hpp:70
@ COIN_S2_COLUMN
Definition: CoinMpsIO.hpp:62
@ COIN_PL_BOUND
Definition: CoinMpsIO.hpp:73
@ COIN_UI_BOUND
Definition: CoinMpsIO.hpp:75
@ COIN_UP_BOUND
Definition: CoinMpsIO.hpp:68
@ COIN_S3_COLUMN
Definition: CoinMpsIO.hpp:63
@ COIN_SOSEND
Definition: CoinMpsIO.hpp:66
@ COIN_BS_BASIS
Definition: CoinMpsIO.hpp:81
@ COIN_N_ROW
Definition: CoinMpsIO.hpp:56
@ COIN_XL_BASIS
Definition: CoinMpsIO.hpp:82
@ COIN_BOTH_BOUNDS_SET
Definition: CoinMpsIO.hpp:77
@ COIN_UNSET_BOUND
Definition: CoinMpsIO.hpp:67
@ COIN_G_ROW
Definition: CoinMpsIO.hpp:59
@ COIN_INTORG
Definition: CoinMpsIO.hpp:64
@ COIN_BV_BOUND
Definition: CoinMpsIO.hpp:74
@ COIN_FX_BOUND
Definition: CoinMpsIO.hpp:69
@ COIN_S1_BOUND
Definition: CoinMpsIO.hpp:79
@ COIN_E_ROW
Definition: CoinMpsIO.hpp:57
@ COIN_LI_BOUND
Definition: CoinMpsIO.hpp:76
@ COIN_MI_BOUND
Definition: CoinMpsIO.hpp:72
@ COIN_UL_BASIS
Definition: CoinMpsIO.hpp:85
@ COIN_SC_BOUND
Definition: CoinMpsIO.hpp:78
@ COIN_LL_BASIS
Definition: CoinMpsIO.hpp:84
@ COIN_S1_COLUMN
Definition: CoinMpsIO.hpp:61
@ COIN_UNKNOWN_MPS_TYPE
Definition: CoinMpsIO.hpp:86
@ COIN_FR_BOUND
Definition: CoinMpsIO.hpp:71
@ COIN_XU_BASIS
Definition: CoinMpsIO.hpp:83
void CoinMpsIOUnitTest(const std::string &mpsDir)
A function that tests the methods in the CoinMpsIO class.
COINSectionType
Definition: CoinMpsIO.hpp:39
@ COIN_SOS_SECTION
Definition: CoinMpsIO.hpp:51
@ COIN_EOF_SECTION
Definition: CoinMpsIO.hpp:47
@ COIN_UNKNOWN_SECTION
Definition: CoinMpsIO.hpp:53
@ COIN_RHS_SECTION
Definition: CoinMpsIO.hpp:43
@ COIN_BOUNDS_SECTION
Definition: CoinMpsIO.hpp:45
@ COIN_NO_SECTION
Definition: CoinMpsIO.hpp:39
@ COIN_ROW_SECTION
Definition: CoinMpsIO.hpp:41
@ COIN_BASIS_SECTION
Definition: CoinMpsIO.hpp:52
@ COIN_QUAD_SECTION
Definition: CoinMpsIO.hpp:50
@ COIN_QUADRATIC_SECTION
Definition: CoinMpsIO.hpp:48
@ COIN_COLUMN_SECTION
Definition: CoinMpsIO.hpp:42
@ COIN_RANGES_SECTION
Definition: CoinMpsIO.hpp:44
@ COIN_NAME_SECTION
Definition: CoinMpsIO.hpp:40
@ COIN_ENDATA_SECTION
Definition: CoinMpsIO.hpp:46
@ COIN_CONIC_SECTION
Definition: CoinMpsIO.hpp:49
void CoinConvertDouble(int section, int formatType, double value, char outputValue[24])
#define COIN_MAX_FIELD_LENGTH
Definition: CoinMpsIO.hpp:35
int CoinBigIndex
Abstract base class for file input classes.
Definition: CoinFileIO.hpp:40
Base class for message handling.
Class to hold and manipulate an array of massaged messages.
Language
Supported languages.
This is a simple minded model which is stored in a format which makes it easier to construct and modi...
Definition: CoinModel.hpp:181
Very simple code for reading MPS data.
Definition: CoinMpsIO.hpp:90
COINSectionType whichSection() const
Returns current section type.
Definition: CoinMpsIO.hpp:124
int cleanCard()
Reads and cleans card - taking out trailing blanks - return 1 if EOF.
bool freeFormat_
Whether free format. Just for blank RHS etc.
Definition: CoinMpsIO.hpp:233
CoinMessageHandler * handler_
Message handler.
Definition: CoinMpsIO.hpp:241
CoinMessages messages_
Messages.
Definition: CoinMpsIO.hpp:243
char * eol_
End of card.
Definition: CoinMpsIO.hpp:219
double value_
Current value.
Definition: CoinMpsIO.hpp:213
CoinBigIndex cardNumber_
Card number.
Definition: CoinMpsIO.hpp:231
bool stringsAllowed_
Whether strings allowed.
Definition: CoinMpsIO.hpp:247
COINMpsType mpsType_
Current COINMpsType.
Definition: CoinMpsIO.hpp:221
double osi_strtod(char *ptr, char **output, int type)
type - 0 normal, 1 INTEL IEEE, 2 other IEEE
char * mutableCard()
Whole card - so we look at it (not const so nextBlankOr will work for gms reader)
Definition: CoinMpsIO.hpp:177
char card_[MAX_CARD_LENGTH]
Current card image.
Definition: CoinMpsIO.hpp:215
bool freeFormat() const
Sees if free format.
Definition: CoinMpsIO.hpp:134
char * getPosition() const
get position (again so gms reader will work)
Definition: CoinMpsIO.hpp:187
bool eightChar_
If all names <= 8 characters then allow embedded blanks.
Definition: CoinMpsIO.hpp:237
double value() const
Returns value in current field.
Definition: CoinMpsIO.hpp:162
CoinFileInput * fileInput() const
Returns file input.
Definition: CoinMpsIO.hpp:197
void setWhichSection(COINSectionType section)
Sets current section type.
Definition: CoinMpsIO.hpp:129
void setFreeFormat(bool yesNo)
Sets whether free format. Mainly for blank RHS etc.
Definition: CoinMpsIO.hpp:139
int nextGmsField(int expectedType)
Gets next field for .gms file and returns type.
void setStringsAllowed()
Sets whether strings allowed.
Definition: CoinMpsIO.hpp:202
static void strcpyAndCompress(char *to, const char *from)
remove blanks
COINMpsType mpsType() const
Only for first field on card otherwise BLANK_COLUMN e.g.
Definition: CoinMpsIO.hpp:145
const char * columnName() const
Returns column name of current field.
Definition: CoinMpsIO.hpp:157
CoinMpsIO * reader_
MpsIO.
Definition: CoinMpsIO.hpp:239
const char * rowName() const
Returns row name of current field.
Definition: CoinMpsIO.hpp:152
double osi_strtod(char *ptr, char **output)
For strings.
COINSectionType nextField()
Gets next field and returns section type e.g. COIN_COLUMN_SECTION.
int ieeeFormat_
Whether IEEE - 0 no, 1 INTEL, 2 not INTEL.
Definition: CoinMpsIO.hpp:235
static char * nextBlankOr(char *image)
CoinMpsCardReader(CoinFileInput *input, CoinMpsIO *reader)
Constructor expects file to be open This one takes gzFile if fp null.
COINSectionType section_
Which section we think we are in.
Definition: CoinMpsIO.hpp:229
~CoinMpsCardReader()
Destructor.
const char * card() const
Whole card (for printing)
Definition: CoinMpsIO.hpp:172
CoinBigIndex cardNumber() const
Returns card number.
Definition: CoinMpsIO.hpp:192
char valueString_[COIN_MAX_FIELD_LENGTH]
Current element as characters (only if strings allowed)
Definition: CoinMpsIO.hpp:245
char * position_
Current position within card image.
Definition: CoinMpsIO.hpp:217
char rowName_[COIN_MAX_FIELD_LENGTH]
Current row name.
Definition: CoinMpsIO.hpp:223
COINSectionType readToNextSection()
Read to next section.
const char * valueString() const
Returns value as string in current field.
Definition: CoinMpsIO.hpp:167
void setPosition(char *position)
set position (again so gms reader will work)
Definition: CoinMpsIO.hpp:182
char columnName_[COIN_MAX_FIELD_LENGTH]
Current column name.
Definition: CoinMpsIO.hpp:225
CoinFileInput * input_
File input.
Definition: CoinMpsIO.hpp:227
MPS IO Interface.
Definition: CoinMpsIO.hpp:401
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.
int isIntegerOrSemiContinuous(int columnNumber) const
Return 1 if a column is an integer variable, 2 if semi-continuous.
bool convertObjective_
If .gms file should it be massaged to move objective.
Definition: CoinMpsIO.hpp:1108
CoinMessageHandler * handler_
Message handler.
Definition: CoinMpsIO.hpp:1096
int defaultBound_
Upper bound when no bounds for integers.
Definition: CoinMpsIO.hpp:1088
const CoinPackedMatrix * getMatrixByRow() const
Get pointer to row-wise copy of the coefficient matrix.
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't co...
int dealWithFileName(const char *filename, const char *extension, CoinFileInput *&input)
Deal with a filename.
int maximumStringElements_
Maximum number of string elements.
Definition: CoinMpsIO.hpp:1112
double getSmallElementValue() const
Small element value - elements less than this set to zero on input default is 1.0e-14.
Definition: CoinMpsIO.hpp:650
void releaseColumnInformation()
Release all column information (lower, upper, objective)
CoinMessageHandler * messageHandler() const
Return the message handler.
Definition: CoinMpsIO.hpp:881
int readMps(const char *filename, const char *extension="mps")
Read a problem in MPS format from the given filename.
void setLanguage(CoinMessages::Language language)
Set the language for messages.
Definition: CoinMpsIO.hpp:878
void releaseIntegerInformation()
Release integer information.
const double * getObjCoefficients() const
Get pointer to array[getNumCols()] of objective function coefficients.
double getInfinity() const
Get infinity.
void newLanguage(CoinMessages::Language language)
Set the language for messages.
char * boundName_
Bounds vector name.
Definition: CoinMpsIO.hpp:1016
const CoinPackedMatrix * getMatrixByCol() const
Get pointer to column-wise copy of the coefficient matrix.
void stopHash(int section)
Deletes hash storage.
CoinMpsIO()
Default Constructor.
bool isContinuous(int colNumber) const
Return true if column is a continuous variable.
const char * getRhsName() const
Return the RHS vector name.
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, const std::vector< std::string > &colnames, const std::vector< std::string > &rownames)
const char * columnName(int index) const
Returns the column name for the specified index.
void releaseRedundantInformation()
Release all information which can be re-calculated.
const char * getRowSense() const
Get pointer to array[getNumRows()] of constraint senses.
const char * getProblemName() const
Return the problem name.
int columnIndex(const char *name) const
Returns the index for the specified column name.
char * fileName_
Current file name.
Definition: CoinMpsIO.hpp:1076
void setInfinity(double value)
Set infinity.
void setDefaultBound(int value)
Set default upper bound for integer variables.
bool defaultHandler_
Flag to say if the message handler is the default handler.
Definition: CoinMpsIO.hpp:1102
CoinMpsIO(const CoinMpsIO &)
Copy constructor.
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.
double * rowrange_
Pointer to dense vector of slack variable upper bounds for range constraints (undefined for non-range...
Definition: CoinMpsIO.hpp:1036
double * colupper_
Pointer to dense vector of column upper bounds.
Definition: CoinMpsIO.hpp:1054
double * collower_
Pointer to dense vector of column lower bounds.
Definition: CoinMpsIO.hpp:1051
const double * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.
int numberStringElements() const
Number of string elements.
Definition: CoinMpsIO.hpp:561
double objectiveOffset() const
Returns the (constant) objective offset.
void releaseMatrixInformation()
Release matrix information.
void setConvertObjective(bool trueFalse)
Set whether to move objective from matrix.
Definition: CoinMpsIO.hpp:842
void setObjectiveOffset(double value)
Set objective offset.
Definition: CoinMpsIO.hpp:541
double * rowupper_
Pointer to dense vector of row upper bounds.
Definition: CoinMpsIO.hpp:1048
const char * getFileName() const
Get the current file name for the CoinMpsIO object.
int numberStringElements_
Number of string elements.
Definition: CoinMpsIO.hpp:1114
CoinMpsIO & operator=(const CoinMpsIO &rhs)
Assignment operator.
int allowStringElements() const
Whether to allow string elements.
Definition: CoinMpsIO.hpp:639
const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
CoinHashLink * hash_[2]
Hash tables (two sections, 0 - row names, 1 - column names)
Definition: CoinMpsIO.hpp:1082
const double * getRowRange() const
Get pointer to array[getNumRows()] of row ranges.
double smallElement_
Small element value.
Definition: CoinMpsIO.hpp:1093
void releaseRowNames()
Release row names.
void setObjectiveName(const char *name)
Set objective name.
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.
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.
char * problemName_
Problem name.
Definition: CoinMpsIO.hpp:1004
CoinMpsCardReader * cardReader_
Card reader.
Definition: CoinMpsIO.hpp:1106
char * rangeName_
Range vector name.
Definition: CoinMpsIO.hpp:1013
const char * integerColumns() const
Returns array[getNumCols()] specifying if a variable is integer.
char * rhsName_
Right-hand side vector name.
Definition: CoinMpsIO.hpp:1010
void gutsOfDestructor()
Does the heavy lifting for destruct and assignment.
void startHash(char **names, const int number, int section)
Creates hash list for names (section = 0 for rows, 1 columns)
const char * stringElement(int i) const
String element.
Definition: CoinMpsIO.hpp:566
int readMps(int &numberSets, CoinSet **&sets)
and
char ** names_[2]
Row and column names Linked to hash table sections (0 - row names, 1 column names)
Definition: CoinMpsIO.hpp:1070
int copyStringElements(const CoinModel *model)
copies in strings from a CoinModel - returns number
char ** stringElements_
String elements.
Definition: CoinMpsIO.hpp:1116
int getDefaultBound() const
Get default upper bound for integer variables.
void copyInIntegerInformation(const char *integerInformation)
Pass in an array[getNumCols()] specifying if a variable is integer.
const double * getRightHandSide() const
Get pointer to array[getNumRows()] of constraint right-hand sides.
void freeAll()
Clears problem data from the CoinMpsIO object.
double * rowlower_
Pointer to dense vector of row lower bounds.
Definition: CoinMpsIO.hpp:1045
int getNumCols() const
Get number of columns.
void startHash(int section) const
This one does it when names are already in.
char * integerType_
Pointer to dense vector specifying if a variable is continuous (0) or integer (1).
Definition: CoinMpsIO.hpp:1065
double * rhs_
Pointer to dense vector of row right-hand side values.
Definition: CoinMpsIO.hpp:1031
double * objective_
Pointer to dense vector of objective coefficients.
Definition: CoinMpsIO.hpp:1057
double objectiveOffset_
Constant offset for objective value (i.e., RHS value for OBJ row)
Definition: CoinMpsIO.hpp:1060
void setMpsDataColAndRowNames(const std::vector< std::string > &colnames, const std::vector< std::string > &rownames)
int numberHash_[2]
Number of entries in a hash table section.
Definition: CoinMpsIO.hpp:1079
friend void CoinMpsIOUnitTest(const std::string &mpsDir)
A function that tests the methods in the CoinMpsIO class.
void setSmallElementValue(double value)
Definition: CoinMpsIO.hpp:654
const char * getRangeName() const
Return the range vector name.
CoinBigIndex getNumElements() const
Get number of nonzero elements.
void setProblemName(const char *name)
Set problem name.
const char * rowName(int index) const
Returns the row name for the specified index.
int readGms(const char *filename, const char *extension="gms", bool convertObjective=false)
Read a problem in GAMS format from the given filename.
int readConicMps(const char *filename, int *&columnStart, int *&column, int *&coneType, int &numberCones)
Read in a list of cones from the given filename.
void releaseRowInformation()
Release all row information (lower, upper)
void setAllowStringElements(int yesNo)
Whether to allow string elements (0 no, 1 yes, 2 yes and try flip)
Definition: CoinMpsIO.hpp:644
void setMpsData(const CoinPackedMatrix &m, const double infinity, const double *collb, const double *colub, const double *obj, const char *integrality, const char *rowsen, const double *rowrhs, const double *rowrng, const std::vector< std::string > &colnames, const std::vector< std::string > &rownames)
void gutsOfCopy(const CoinMpsIO &)
Does the heavy lifting for copy and assignment.
CoinPackedMatrix * matrixByRow_
Pointer to row-wise copy of problem matrix coefficients.
Definition: CoinMpsIO.hpp:1039
CoinMessages * messagesPointer()
Return the messages pointer.
Definition: CoinMpsIO.hpp:886
const CoinMpsCardReader * reader() const
Return card reader object so can see what last card was e.g. QUADOBJ.
Definition: CoinMpsIO.hpp:784
int readQuadraticMps(const char *filename, CoinBigIndex *&columnStart, int *&column, double *&elements, int checkSymmetry)
Read in a quadratic objective from the given filename.
void passInMessageHandler(CoinMessageHandler *handler)
Pass in Message handler.
CoinMessages messages_
Messages.
Definition: CoinMpsIO.hpp:1104
CoinPackedMatrix * matrixByColumn_
Pointer to column-wise copy of problem matrix coefficients.
Definition: CoinMpsIO.hpp:1042
const double * getRowLower() const
Get pointer to array[getNumRows()] of row lower bounds.
void releaseColumnNames()
Release column names.
const char * getBoundName() const
Return the bound vector name.
int allowStringElements_
Whether to allow string elements.
Definition: CoinMpsIO.hpp:1110
bool isInteger(int columnNumber) const
Return true if a column is an integer variable.
const char * getObjectiveName() const
Return the objective name.
char * rowsense_
Pointer to dense vector of row sense indicators.
Definition: CoinMpsIO.hpp:1028
int numberColumns_
Number of columns.
Definition: CoinMpsIO.hpp:1022
int numberRows_
Number of rows.
Definition: CoinMpsIO.hpp:1019
const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
int readGms(int &numberSets, CoinSet **&sets)
Read a problem in GAMS format from a previously opened file.
CoinBigIndex numberElements_
Number of coefficients.
Definition: CoinMpsIO.hpp:1025
char * objectiveName_
Objective row name.
Definition: CoinMpsIO.hpp:1007
void decodeString(int iString, int &iRow, int &iColumn, const char *&value) const
Decode string.
CoinMessages messages()
Return the messages.
Definition: CoinMpsIO.hpp:884
int findHash(const char *name, int section) const
Finds match using hash, -1 not found.
void setMpsData(const CoinPackedMatrix &m, const double infinity, const double *collb, const double *colub, const double *obj, const char *integrality, const char *rowsen, const double *rowrhs, const double *rowrng, char const *const *const colnames, char const *const *const rownames)
int getNumRows() const
Get number of rows.
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.
int rowIndex(const char *name) const
Returns the index for the specified row name.
void setFileName(const char *name)
Set the current file name for the CoinMpsIO object.
int readGms(const char *filename, const char *extension, int &numberSets, CoinSet **&sets)
Read a problem in GAMS format from the given filename.
int readMps()
Read a problem in MPS format from a previously opened file.
void setMpsDataColAndRowNames(char const *const *const colnames, char const *const *const rownames)
~CoinMpsIO()
Destructor.
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.
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.
double infinity_
Value to use for infinity.
Definition: CoinMpsIO.hpp:1091
int readMps(const char *filename, const char *extension, int &numberSets, CoinSet **&sets)
Read a problem in MPS format from the given filename.
Sparse Matrix Base Class.
Very simple class for containing data on set.
Definition: CoinMpsIO.hpp:269
int * modifiableWhich() const
Returns modifiable list of variables.
Definition: CoinMpsIO.hpp:322
CoinSet(const CoinSet &)
Copy constructor.
int numberEntries() const
Returns number of entries.
Definition: CoinMpsIO.hpp:292
void setSetType(int type)
Sets type of set - 1 =SOS1, 2 =SOS2.
Definition: CoinMpsIO.hpp:307
int setType_
type of set
Definition: CoinMpsIO.hpp:351
const double * weights() const
Returns weights.
Definition: CoinMpsIO.hpp:317
CoinSet & operator=(const CoinSet &rhs)
Assignment operator.
CoinSet()
Default constructor.
virtual ~CoinSet()
Destructor.
double * modifiableWeights() const
Returns modifiable weights.
Definition: CoinMpsIO.hpp:327
const int * which() const
Returns list of variables.
Definition: CoinMpsIO.hpp:312
CoinSet(int numberEntries, const int *which)
Constructor.
void setNumberEntries(int number)
Sets number of entries.
Definition: CoinMpsIO.hpp:297
int * which_
Which variables are in set.
Definition: CoinMpsIO.hpp:353
int setType() const
Returns type of set - 1 =SOS1, 2 =SOS2.
Definition: CoinMpsIO.hpp:302
double * weights_
Weights.
Definition: CoinMpsIO.hpp:355
int numberEntries_
Number of entries.
Definition: CoinMpsIO.hpp:349
Very simple class for containing SOS set.
Definition: CoinMpsIO.hpp:361
virtual ~CoinSosSet()
Destructor.
CoinSosSet(int numberEntries, const int *which, const double *weights, int type)
Constructor.