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
132 inline const char *
card ( )
const {
203 double osi_strtod(
char * ptr,
char ** output,
int type);
210 double osi_strtod(
char * ptr,
char ** output);
262 virtual SbbObject * sbbObject(SbbModel * model)
const
303 virtual SbbObject * sbbObject(SbbModel * model)
const ;
435 const char *
rowName(
int index)
const;
449 int rowIndex(
const char * name)
const;
497 const double* collb,
const double* colub,
498 const double* obj,
const char* integrality,
499 const double* rowlb,
const double* rowub,
500 char const *
const *
const colnames,
501 char const *
const *
const rownames);
503 const double* collb,
const double* colub,
504 const double* obj,
const char* integrality,
505 const double* rowlb,
const double* rowub,
506 const std::vector<std::string> & colnames,
507 const std::vector<std::string> & rownames);
509 const double* collb,
const double* colub,
510 const double* obj,
const char* integrality,
511 const char* rowsen,
const double* rowrhs,
512 const double* rowrng,
513 char const *
const *
const colnames,
514 char const *
const *
const rownames);
516 const double* collb,
const double* colub,
517 const double* obj,
const char* integrality,
518 const char* rowsen,
const double* rowrhs,
519 const double* rowrng,
520 const std::vector<std::string> & colnames,
521 const std::vector<std::string> & rownames);
598 int readMps(
const char *filename,
const char *extension =
"mps");
605 int readMps(
const char *filename,
const char *extension ,
606 int & numberSets,
CoinSet **& sets);
630 int readBasis(
const char *filename,
const char *extension ,
631 double * solution,
unsigned char *rowStatus,
unsigned char *columnStatus,
632 const std::vector<std::string> & colnames,
int numberColumns,
633 const std::vector<std::string> & rownames,
int numberRows);
640 int readGms(
const char *filename,
const char *extension =
"gms",
bool convertObjective=
false);
647 int readGms(
const char *filename,
const char *extension ,
648 int & numberSets,
CoinSet **& sets);
661 int readGMPL(
const char *modelName,
const char * dataName=NULL,
bool keepNames=
false);
688 int writeMps(
const char *filename,
int compression = 0,
689 int formatType = 0,
int numberAcross = 2,
691 int numberSOS=0,
const CoinSet * setInfo=NULL)
const;
725 int * &columnStart,
int * &column,
double * &elements,
748 int * &columnStart,
int * &column,
int * &coneType,
int & numberCones);
837 const double* collb,
const double* colub,
838 const double* obj,
const char* integrality,
839 const double* rowlb,
const double* rowub);
842 const std::vector<std::string> & colnames,
843 const std::vector<std::string> & rownames);
846 char const *
const *
const colnames,
847 char const *
const *
const rownames);
864 char& sense,
double& right,
double& range)
const;
870 double& lower,
double& upper)
const;
890 void addString(
int iRow,
int iColumn,
const char * value);
892 void decodeString(
int iString,
int & iRow,
int & iColumn,
const char * & value)
const;
903 void startHash (
char **names,
const int number ,
int section );
910 int findHash (
const char *name ,
int section )
const;
1053 CoinConvertDouble(
int section,
int formatType,
double value,
char outputValue[24]);
void startHash(char **names, const int number, int section)
Creates hash list for names (section = 0 for rows, 1 columns)
void stopHash(int section)
Deletes hash storage.
CoinSet()
Default constructor.
char * fileName_
Current file name.
int allowStringElements() const
Whether to allow string elements.
void CoinMpsIOUnitTest(const std::string &mpsDir)
A function that tests the methods in the CoinMpsIO class.
int ieeeFormat_
Whether IEEE - 0 no, 1 INTEL, 2 not INTEL.
CoinMpsIO()
Default Constructor.
char * getPosition() const
get position (again so gms reader will work)
This is a simple minded model which is stored in a format which makes it easier to construct and modi...
void releaseRedundantInformation()
Release all information which can be re-calculated.
void setDefaultBound(int value)
Set default upper bound for integer variables.
CoinMessageHandler * handler_
Message handler.
char ** names_[2]
Row and column names Linked to hash table sections (0 - row names, 1 column names) ...
double * collower_
Pointer to dense vector of column lower bounds.
Base class for message handling.
const char * getRangeName() const
Return the range vector name.
int defaultBound_
Upper bound when no bounds for integers.
int maximumStringElements_
Maximum number of string elements.
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.
int readMps()
Read a problem in MPS format from a previously opened file.
char card_[MAX_CARD_LENGTH]
Current card image.
const char * getProblemName() const
Return the problem name.
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.
const char * rowName(int index) const
Returns the row name for the specified index.
const char * card() const
Whole card (for printing)
const char * integerColumns() const
Returns array[getNumCols()] specifying if a variable is integer.
int numberEntries() const
Returns number of entries.
const char * stringElement(int i) const
String element.
const char * getFileName() const
Get the current file name for the CoinMpsIO object.
char * objectiveName_
Objective row name.
char * rhsName_
Right-hand side vector name.
int dealWithFileName(const char *filename, const char *extension, CoinFileInput *&input)
Deal with a filename.
int getNumCols() const
Get number of columns.
const double * getRightHandSide() const
Get pointer to array[getNumRows()] of constraint right-hand sides.
const double * weights() const
Returns weights.
double * rowrange_
Pointer to dense vector of slack variable upper bounds for range constraints (undefined for non-range...
const int * which() const
Returns list of variables.
double value() const
Returns value in current field.
void setAllowStringElements(int yesNo)
Whether to allow string elements (0 no, 1 yes, 2 yes and try flip)
bool freeFormat() const
Sees if free format.
void setObjectiveName(const char *name)
Set objective name.
void setFileName(const char *name)
Set the current file name for the CoinMpsIO object.
void setWhichSection(COINSectionType section)
Sets current section type.
const char * rowName() const
Returns row name of current field.
int findHash(const char *name, int section) const
Finds match using hash, -1 not found.
COINSectionType section_
Which section we think we are in.
void setLanguage(CoinMessages::Language language)
Set the language for messages.
void setObjectiveOffset(double value)
Set objective offset.
Sparse Matrix Base Class.
COINSectionType whichSection() const
Returns current section type.
void freeAll()
Clears problem data from the CoinMpsIO object.
void releaseColumnInformation()
Release all column information (lower, upper, objective)
void gutsOfDestructor()
Does the heavy lifting for destruct and assignment.
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.
char rowName_[COIN_MAX_FIELD_LENGTH]
Current row name.
char ** stringElements_
String elements.
int allowStringElements_
Whether to allow string elements.
CoinMessageHandler * handler_
Message handler.
COINSectionType readToNextSection()
Read to next section.
int numberRows_
Number of rows.
bool defaultHandler_
Flag to say if the message handler is the default handler.
const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
double objectiveOffset_
Constant offset for objective value (i.e., RHS value for OBJ row)
const char * columnName() const
Returns column name of current field.
CoinFileInput * input_
File input.
const char * getBoundName() const
Return the bound vector name.
int copyStringElements(const CoinModel *model)
copies in strings from a CoinModel - returns number
int rowIndex(const char *name) const
Returns the index for the specified row name.
void CoinConvertDouble(int section, int formatType, double value, char outputValue[24])
CoinFileInput * fileInput() const
Returns file input.
char valueString_[COIN_MAX_FIELD_LENGTH]
Current element as characters (only if strings allowed)
double * weights_
Weights.
void releaseIntegerInformation()
Release integer information.
const double * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.
char * rangeName_
Range vector name.
COINMpsType mpsType() const
Only for first field on card otherwise BLANK_COLUMN e.g.
double getInfinity() const
Get infinity.
double smallElement_
Small element value.
char * rowsense_
Pointer to dense vector of row sense indicators.
#define COIN_MAX_FIELD_LENGTH
const char * getObjectiveName() const
Return the objective name.
bool isContinuous(int colNumber) const
Return true if column is a continuous variable.
int cleanCard()
Reads and cleans card - taking out trailing blanks - return 1 if EOF.
char * boundName_
Bounds vector name.
int nextGmsField(int expectedType)
Gets next field for .gms file and returns type.
CoinBigIndex cardNumber() const
Returns card number.
Very simple class for containing data on set.
int columnIndex(const char *name) const
Returns the index for the specified column name.
const char * columnName(int index) const
Returns the column name for the specified index.
CoinMessages messages()
Return the messages.
CoinBigIndex numberElements_
Number of coefficients.
int setType() const
Returns type of set - 1 =SOS1, 2 =SOS2.
CoinMessageHandler * messageHandler() const
Return the message handler.
void releaseRowInformation()
Release all row information (lower, upper)
static void strcpyAndCompress(char *to, const char *from)
remove blanks
Very simple class for containing SOS set.
void setStringsAllowed()
Sets whether strings allowed.
bool isInteger(int columnNumber) const
Return true if a column is an integer variable.
CoinMpsIO * reader_
MpsIO.
CoinPackedMatrix * matrixByColumn_
Pointer to column-wise copy of problem matrix coefficients.
const CoinPackedMatrix * getMatrixByRow() const
Get pointer to row-wise copy of the coefficient matrix.
void setMpsDataColAndRowNames(const std::vector< std::string > &colnames, const std::vector< std::string > &rownames)
Utility method used several times to implement public methods.
This is a first attempt at a message handler.
char columnName_[COIN_MAX_FIELD_LENGTH]
Current column name.
CoinMessages messages_
Messages.
double objectiveOffset() const
Returns the (constant) objective offset.
int getDefaultBound() const
Get default upper bound for integer variables.
double osi_strtod(char *ptr, char **output, int type)
type - 0 normal, 1 INTEL IEEE, 2 other IEEE
int readGms(const char *filename, const char *extension="gms", bool convertObjective=false)
Read a problem in GAMS format from the given filename.
bool stringsAllowed_
Whether strings allowed.
CoinMessages * messagesPointer()
Return the messages pointer.
bool eightChar_
If all names <= 8 characters then allow embedded blanks.
double * rowupper_
Pointer to dense vector of row upper bounds.
char * mutableCard()
Whole card - so we look at it (not const so nextBlankOr will work for gms reader) ...
CoinMpsCardReader(CoinFileInput *input, CoinMpsIO *reader)
Constructor expects file to be open This one takes gzFile if fp null.
~CoinMpsCardReader()
Destructor.
char * integerType_
Pointer to dense vector specifying if a variable is continuous (0) or integer (1).
bool convertObjective_
If .gms file should it be massaged to move objective.
int readQuadraticMps(const char *filename, int *&columnStart, int *&column, double *&elements, int checkSymmetry)
Read in a quadratic objective from the given filename.
double value_
Current value.
int getNumRows() const
Get number of rows.
int numberStringElements_
Number of string elements.
const char * getRhsName() const
Return the RHS vector name.
void releaseColumnNames()
Release column names.
Class to hold and manipulate an array of massaged messages.
CoinSet & operator=(const CoinSet &rhs)
Assignment operator.
void setInfinity(double value)
Set infinity.
double * rhs_
Pointer to dense vector of row right-hand side values.
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...
const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
int numberColumns_
Number of columns.
void newLanguage(CoinMessages::Language language)
Set the language for messages.
void setPosition(char *position)
set position (again so gms reader will work)
void setFreeFormat(bool yesNo)
Sets whether free format. Mainly for blank RHS etc.
CoinBigIndex cardNumber_
Card number.
void passInMessageHandler(CoinMessageHandler *handler)
Pass in Message handler.
CoinMessages messages_
Messages.
Very simple code for reading MPS data.
int * which_
Which variables are in set.
CoinMpsIO & operator=(const CoinMpsIO &rhs)
Assignment operator.
double getSmallElementValue() const
Small element value - elements less than this set to zero on input default is 1.0e-14.
const double * getObjCoefficients() const
Get pointer to array[getNumCols()] of objective function coefficients.
int numberHash_[2]
Number of entries in a hash table section.
const double * getRowLower() const
Get pointer to array[getNumRows()] of row lower bounds.
double * objective_
Pointer to dense vector of objective coefficients.
void releaseRowNames()
Release row names.
const CoinMpsCardReader * reader() const
Return card reader object so can see what last card was e.g. QUADOBJ.
CoinHashLink * hash_[2]
Hash tables (two sections, 0 - row names, 1 - column names)
void gutsOfCopy(const CoinMpsIO &)
Does the heavy lifting for copy and assignment.
CoinSosSet(int numberEntries, const int *which, const double *weights, int type)
Constructor.
int COINRowIndex
Large enough to contain row index (or basis)
char * problemName_
Problem name.
void decodeString(int iString, int &iRow, int &iColumn, const char *&value) const
Decode string.
double infinity_
Value to use for infinity.
void setProblemName(const char *name)
Set problem name.
void setSmallElementValue(double value)
Set infinity.
const CoinPackedMatrix * getMatrixByCol() const
Get pointer to column-wise copy of the coefficient matrix.
int numberEntries_
Number of entries.
COINSectionType nextField()
Gets next field and returns section type e.g. COIN_COLUMN_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.
double * rowlower_
Pointer to dense vector of row lower bounds.
char * position_
Current position within card image.
virtual ~CoinSet()
Destructor.
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...
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.
double * colupper_
Pointer to dense vector of column upper bounds.
bool freeFormat_
Whether free format. Just for blank RHS etc.
static char * nextBlankOr(char *image)
type - 0 normal, 1 INTEL IEEE, 2 other IEEE
virtual ~CoinSosSet()
Destructor.
const char * valueString() const
Returns value as string in current field.
Language
Supported languages.
void releaseMatrixInformation()
Release matrix information.
int numberStringElements() const
Number of string elements.
COINMpsType mpsType_
Current COINMpsType.
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.
int getNumElements() const
Get number of nonzero elements.
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 * cardReader_
Card reader.
CoinPackedMatrix * matrixByRow_
Pointer to row-wise copy of problem matrix coefficients.
int readConicMps(const char *filename, int *&columnStart, int *&column, int *&coneType, int &numberCones)
Read in a list of cones from the given filename.
void setConvertObjective(bool trueFalse)
Set whether to move objective from matrix.
const char * getRowSense() const
Get pointer to array[getNumRows()] of constraint senses.
void copyInIntegerInformation(const char *integerInformation)
Pass in an array[getNumCols()] specifying if a variable is integer.