11 #pragma warning(disable : 4786)
34 #ifndef COIN_MAX_FIELD_LENGTH
35 #define COIN_MAX_FIELD_LENGTH 160
37 #define MAX_CARD_LENGTH 5 * COIN_MAX_FIELD_LENGTH + 80
172 inline const char *
card()
const
337 virtual SbbObject *sbbObject(SbbModel *model)
const
377 virtual SbbObject *sbbObject(SbbModel *model)
const;
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);
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);
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);
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);
688 int readMps(
const char *filename,
const char *extension =
"mps");
695 int readMps(
const char *filename,
const char *extension,
696 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);
730 int readGms(
const char *filename,
const char *extension =
"gms",
bool convertObjective =
false);
737 int readGms(
const char *filename,
const char *extension,
738 int &numberSets,
CoinSet **&sets);
751 int readGMPL(
const char *modelName,
const char *dataName = NULL,
bool keepNames =
false);
778 int writeMps(
const char *filename,
int compression = 0,
779 int formatType = 0,
int numberAcross = 2,
781 int numberSOS = 0,
const CoinSet *setInfo = NULL)
const;
817 CoinBigIndex *&columnStart,
int *&column,
double *&elements,
840 int *&columnStart,
int *&column,
int *&coneType,
int &numberCones);
928 const double *collb,
const double *colub,
929 const double *obj,
const char *integrality,
930 const double *rowlb,
const double *rowub);
933 const std::vector< std::string > &colnames,
934 const std::vector< std::string > &rownames);
937 char const *
const *
const colnames,
938 char const *
const *
const rownames);
953 char &sense,
double &right,
double &range)
const;
959 double &lower,
double &upper)
const;
979 void addString(
int iRow,
int iColumn,
const char *value);
981 void decodeString(
int iString,
int &iRow,
int &iColumn,
const char *&value)
const;
992 void startHash(
char **names,
const int number,
int section);
This is a first attempt at a message handler.
int COINRowIndex
Large enough to contain row index (or basis)
int COINColumnIndex
The following lengths are in decreasing order (for 64 bit etc) Large enough to contain element index ...
void CoinMpsIOUnitTest(const std::string &mpsDir)
A function that tests the methods in the CoinMpsIO class.
void CoinConvertDouble(int section, int formatType, double value, char outputValue[24])
#define COIN_MAX_FIELD_LENGTH
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...
Very simple code for reading MPS data.
COINSectionType whichSection() const
Returns current section type.
int cleanCard()
Reads and cleans card - taking out trailing blanks - return 1 if EOF.
bool freeFormat_
Whether free format. Just for blank RHS etc.
CoinMessageHandler * handler_
Message handler.
CoinMessages messages_
Messages.
double value_
Current value.
CoinBigIndex cardNumber_
Card number.
char * getPosition() const
get position (again so gms reader will work)
bool stringsAllowed_
Whether strings allowed.
COINMpsType mpsType_
Current COINMpsType.
double osi_strtod(char *ptr, char **output, int type)
type - 0 normal, 1 INTEL IEEE, 2 other IEEE
char card_[MAX_CARD_LENGTH]
Current card image.
bool freeFormat() const
Sees if free format.
bool eightChar_
If all names <= 8 characters then allow embedded blanks.
double value() const
Returns value in current field.
void setWhichSection(COINSectionType section)
Sets current section type.
void setFreeFormat(bool yesNo)
Sets whether free format. Mainly for blank RHS etc.
int nextGmsField(int expectedType)
Gets next field for .gms file and returns type.
void setStringsAllowed()
Sets whether strings allowed.
CoinFileInput * fileInput() const
Returns file input.
char * mutableCard()
Whole card - so we look at it (not const so nextBlankOr will work for gms reader)
static void strcpyAndCompress(char *to, const char *from)
remove blanks
const char * columnName() const
Returns column name of current field.
COINMpsType mpsType() const
Only for first field on card otherwise BLANK_COLUMN e.g.
static char * nextBlankOr(char *image)
CoinMpsIO * reader_
MpsIO.
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.
CoinMpsCardReader(CoinFileInput *input, CoinMpsIO *reader)
Constructor expects file to be open This one takes gzFile if fp null.
const char * card() const
Whole card (for printing)
COINSectionType section_
Which section we think we are in.
~CoinMpsCardReader()
Destructor.
CoinBigIndex cardNumber() const
Returns card number.
char valueString_[COIN_MAX_FIELD_LENGTH]
Current element as characters (only if strings allowed)
char * position_
Current position within card image.
const char * rowName() const
Returns row name of current field.
char rowName_[COIN_MAX_FIELD_LENGTH]
Current row name.
COINSectionType readToNextSection()
Read to next section.
const char * valueString() const
Returns value as string in current field.
void setPosition(char *position)
set position (again so gms reader will work)
char columnName_[COIN_MAX_FIELD_LENGTH]
Current column name.
CoinFileInput * input_
File input.
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.
CoinMessageHandler * handler_
Message handler.
int defaultBound_
Upper bound when no bounds for integers.
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.
const char * getProblemName() const
Return the problem name.
const double * getObjCoefficients() const
Get pointer to array[getNumCols()] of objective function coefficients.
const char * integerColumns() const
Returns array[getNumCols()] specifying if a variable is integer.
double getSmallElementValue() const
Small element value - elements less than this set to zero on input default is 1.0e-14.
void releaseColumnInformation()
Release all column information (lower, upper, objective)
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.
void releaseIntegerInformation()
Release integer information.
double getInfinity() const
Get infinity.
void newLanguage(CoinMessages::Language language)
Set the language for messages.
char * boundName_
Bounds vector name.
void stopHash(int section)
Deletes hash storage.
CoinMpsIO()
Default Constructor.
const char * rowName(int index) const
Returns the row name for the specified index.
const CoinPackedMatrix * getMatrixByRow() const
Get pointer to row-wise copy of the coefficient matrix.
bool isContinuous(int colNumber) const
Return true if column is a continuous variable.
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 double * getRowLower() const
Get pointer to array[getNumRows()] of row lower bounds.
const char * getBoundName() const
Return the bound vector name.
void releaseRedundantInformation()
Release all information which can be re-calculated.
CoinMessages * messagesPointer()
Return the messages pointer.
const char * getObjectiveName() const
Return the objective name.
const CoinPackedMatrix * getMatrixByCol() const
Get pointer to column-wise copy of the coefficient matrix.
const char * getRowSense() const
Get pointer to array[getNumRows()] of constraint senses.
int columnIndex(const char *name) const
Returns the index for the specified column name.
char * fileName_
Current file name.
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.
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...
double * colupper_
Pointer to dense vector of column upper bounds.
double * collower_
Pointer to dense vector of column lower bounds.
int numberStringElements() const
Number of string elements.
double objectiveOffset() const
Returns the (constant) objective offset.
void releaseMatrixInformation()
Release matrix information.
void setConvertObjective(bool trueFalse)
Set whether to move objective from matrix.
void setObjectiveOffset(double value)
Set objective offset.
double * rowupper_
Pointer to dense vector of row upper bounds.
CoinMpsIO & operator=(const CoinMpsIO &rhs)
Assignment operator.
int numberStringElements_
Number of string elements.
int allowStringElements() const
Whether to allow string elements.
CoinHashLink * hash_[2]
Hash tables (two sections, 0 - row names, 1 - column names)
double smallElement_
Small element value.
void releaseRowNames()
Release row names.
void setObjectiveName(const char *name)
Set objective name.
const CoinMpsCardReader * reader() const
Return card reader object so can see what last card was e.g. QUADOBJ.
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.
CoinMpsCardReader * cardReader_
Card reader.
char * rangeName_
Range vector name.
char * rhsName_
Right-hand side vector name.
const char * getRhsName() const
Return the RHS vector name.
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.
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)
int copyStringElements(const CoinModel *model)
copies in strings from a CoinModel - returns number
CoinMessageHandler * messageHandler() const
Return the message handler.
char ** stringElements_
String elements.
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 * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
const char * getFileName() const
Get the current file name for the CoinMpsIO object.
void freeAll()
Clears problem data from the CoinMpsIO object.
double * rowlower_
Pointer to dense vector of row lower bounds.
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).
double * rhs_
Pointer to dense vector of row right-hand side values.
double * objective_
Pointer to dense vector of objective coefficients.
double objectiveOffset_
Constant offset for objective value (i.e., RHS value for OBJ row)
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.
const double * getRowRange() const
Get pointer to array[getNumRows()] of row ranges.
friend void CoinMpsIOUnitTest(const std::string &mpsDir)
A function that tests the methods in the CoinMpsIO class.
void setSmallElementValue(double value)
CoinBigIndex getNumElements() const
Get number of nonzero elements.
void setProblemName(const char *name)
Set problem name.
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.
const double * getRightHandSide() const
Get pointer to array[getNumRows()] of constraint right-hand sides.
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)
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.
const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
CoinPackedMatrix * matrixByRow_
Pointer to row-wise copy of problem matrix coefficients.
int readQuadraticMps(const char *filename, CoinBigIndex *&columnStart, int *&column, double *&elements, int checkSymmetry)
Read in a quadratic objective from the given filename.
const double * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.
void passInMessageHandler(CoinMessageHandler *handler)
Pass in Message handler.
CoinMessages messages_
Messages.
CoinPackedMatrix * matrixByColumn_
Pointer to column-wise copy of problem matrix coefficients.
void releaseColumnNames()
Release column names.
int allowStringElements_
Whether to allow string elements.
bool isInteger(int columnNumber) const
Return true if a column is an integer variable.
char * rowsense_
Pointer to dense vector of row sense indicators.
int numberColumns_
Number of columns.
int numberRows_
Number of rows.
int readGms(int &numberSets, CoinSet **&sets)
Read a problem in GAMS format from a previously opened file.
CoinBigIndex numberElements_
Number of coefficients.
char * objectiveName_
Objective row name.
void decodeString(int iString, int &iRow, int &iColumn, const char *&value) const
Decode string.
CoinMessages messages()
Return the messages.
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.
const char * getRangeName() const
Return the range vector name.
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)
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.
const char * columnName(int index) const
Returns the column name for the specified index.
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.
const double * weights() const
Returns weights.
CoinSet(const CoinSet &)
Copy constructor.
int numberEntries() const
Returns number of entries.
void setSetType(int type)
Sets type of set - 1 =SOS1, 2 =SOS2.
double * modifiableWeights() const
Returns modifiable weights.
CoinSet()
Default constructor.
const int * which() const
Returns list of variables.
virtual ~CoinSet()
Destructor.
int * modifiableWhich() const
Returns modifiable list of variables.
CoinSet(int numberEntries, const int *which)
Constructor.
void setNumberEntries(int number)
Sets number of entries.
int * which_
Which variables are in set.
CoinSet & operator=(const CoinSet &rhs)
Assignment operator.
int setType() const
Returns type of set - 1 =SOS1, 2 =SOS2.
double * weights_
Weights.
int numberEntries_
Number of entries.
Very simple class for containing SOS set.
virtual ~CoinSosSet()
Destructor.
CoinSosSet(int numberEntries, const int *which, const double *weights, int type)
Constructor.